-
Notifications
You must be signed in to change notification settings - Fork 0
101 lines (85 loc) · 3.92 KB
/
Copy pathtests.yml
File metadata and controls
101 lines (85 loc) · 3.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
name: Tests
on:
push:
branches:
- master
pull_request_target:
types: [opened, synchronize, reopened]
jobs:
test-all:
name: Test PHP ${{ matrix.php-version }} using broker [${{ matrix.mqtt-broker }}]
runs-on: ubuntu-latest
strategy:
matrix:
php-version: ['8.1', '8.2', '8.3', '8.4', '8.5']
mqtt-broker: ['mosquitto-1.6', 'mosquitto-2.1']
include:
- php-version: '8.5'
mqtt-broker: 'mosquitto-2.1'
run-sonarqube-analysis: true
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
tools: phpunit:9.5.0
coverage: pcov
- name: Setup problem matchers for PHP
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
- name: Setup problem matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Install Composer dependencies
run: composer install --prefer-dist
- name: Generate certificates for tests
run: |
sh create-certificates.sh
chmod u+rx,g+rx ${{ github.workspace }}/.ci/tls
chmod a+r ${{ github.workspace }}/.ci/tls/*
- name: Start Mosquitto 1.6 message broker
if: matrix.mqtt-broker == 'mosquitto-1.6'
run: |
docker run --detach --name mqtt-broker \
-p 1883:1883 -p 1884:1884 -p 8883:8883 -p 8884:8884 \
-v ${{ github.workspace }}/.ci/mosquitto.conf:/mosquitto/config/mosquitto.conf:ro \
-v ${{ github.workspace }}/.ci/mosquitto.passwd:/mosquitto/config/mosquitto.passwd:ro \
-v ${{ github.workspace }}/.ci/tls:/mosquitto-certs:ro \
--health-cmd="mosquitto_pub -h 127.0.0.1 -p 1883 -t health -n -q 0" \
--health-interval=2s --health-timeout=5s --health-retries=30 --health-start-period=5s \
eclipse-mosquitto:1.6-openssl
timeout 120 bash -c 'until [ "$(docker inspect -f {{.State.Health.Status}} mqtt-broker)" = "healthy" ]; do sleep 2; done'
- name: Start Mosquitto 2.0 message broker
if: matrix.mqtt-broker == 'mosquitto-2.1'
run: |
docker run --detach --name mqtt-broker \
-p 1883:1883 -p 1884:1884 -p 8883:8883 -p 8884:8884 \
-v ${{ github.workspace }}/.ci/mosquitto.conf:/mosquitto/config/mosquitto.conf:ro \
-v ${{ github.workspace }}/.ci/mosquitto.passwd:/mosquitto/config/mosquitto.passwd:ro \
-v ${{ github.workspace }}/.ci/tls:/mosquitto-certs:ro \
--health-cmd="mosquitto_pub -h 127.0.0.1 -p 1883 -t health -n -q 0" \
--health-interval=2s --health-timeout=5s --health-retries=30 --health-start-period=5s \
eclipse-mosquitto:2.1.2-alpine
timeout 120 bash -c 'until [ "$(docker inspect -f {{.State.Health.Status}} mqtt-broker)" = "healthy" ]; do sleep 2; done'
- name: Run phpunit tests
run: composer test
env:
MQTT_BROKER_HOST: 'localhost'
MQTT_BROKER_PORT: 1883
MQTT_BROKER_PORT_WITH_AUTHENTICATION: 1884
MQTT_BROKER_TLS_PORT: 8883
MQTT_BROKER_TLS_WITH_CLIENT_CERT_PORT: 8884
MQTT_BROKER_USERNAME: 'ci-test-user'
MQTT_BROKER_PASSWORD: ${{ secrets.CI_MOSQUITTO_CI_TEST_USER_PASSWORD }}
- name: Prepare paths for SonarQube analysis
if: matrix.run-sonarqube-analysis
run: |
sed -i "s|$GITHUB_WORKSPACE|/github/workspace|g" phpunit.coverage-clover.xml
sed -i "s|$GITHUB_WORKSPACE|/github/workspace|g" phpunit.report-junit.xml
- name: Run SonarQube analysis
uses: sonarsource/sonarqube-scan-action@v8.1.0
if: matrix.run-sonarqube-analysis
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONARCLOUD_TOKEN }}