Repository navigation
167 lines (148 loc) · 5.27 KB
/
Copy pathtests.yml
File metadata and controls
167 lines (148 loc) · 5.27 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
name: CI
on:
push:
pull_request:
workflow_dispatch:
env:
DRIVER_URL: "http://localhost:4444/wd/hub"
defaults:
run:
shell: bash
jobs:
check_composer:
name: Check composer.json
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: shivammathur/setup-php@v2
with:
coverage: none
php-version: '8.5'
- run: composer validate --strict --no-check-lock
static_analysis:
name: Static analysis
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: shivammathur/setup-php@v2
with:
coverage: none
php-version: '8.5'
- name: Install dependencies
run: composer update --ansi --no-progress --prefer-dist --no-interaction
- run: vendor/bin/phpstan analyze
tests:
name: "Tests (PHP ${{ matrix.php }}, ${{ matrix.browser }}, Selenium ${{ matrix.selenium_version }})${{ matrix.with_coverage == true && ' with coverage' || ''}}"
runs-on: ubuntu-latest
strategy:
matrix:
browser: [ 'firefox' ]
selenium_version: [ '2.53.1' ]
php: [ '7.2', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
with_coverage: [ false ]
include:
# Cover code paths for PHP < 7.4
- browser: 'firefox'
selenium_version: '2.53.1'
php: '7.3'
with_coverage: true
# Check each browser on each supported Selenium version
- browser: 'firefox'
selenium_version: '2.53.1'
php: '8.5'
with_coverage: true
- browser: 'firefox'
selenium_version: '3'
php: '8.5'
with_coverage: true
- browser: 'chrome'
selenium_version: '2.53.1'
php: '8.5'
with_coverage: false
- browser: 'chrome'
selenium_version: '3'
php: '8.5'
with_coverage: false
# Check that unsupported Selenium version is rejected
- browser: 'firefox'
selenium_version: '4'
php: '8.5'
with_coverage: true
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 1
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
coverage: "xdebug"
php-version: "${{ matrix.php }}"
tools: composer
ini-file: 'development'
# PHP 7.1 development web server segfaults if timezone not set.
ini-values: date.timezone=Europe/Paris
- name: Install dependencies
run: |
composer update --no-interaction --prefer-dist
- name: Setup Mink test server
env:
MINK_HOST: 0.0.0.0:8002
run: |
mkdir ./logs
./vendor/bin/mink-test-server &> ./logs/mink-test-server.log &
- name: Start Selenium
run: |
SELENIUM_IMAGE=selenium/standalone-${{ matrix.browser }}:${{ matrix.selenium_version }} docker compose up --wait
- name: Wait for browser & PHP to start
run: |
curl --retry 5 --retry-all-errors --retry-delay 1 --max-time 10 --head -X GET http://localhost:4444/wd/hub/status
curl --retry 5 --retry-all-errors --retry-delay 1 --max-time 10 --head -X GET http://localhost:8002/index.html
- name: Show browser version
run: |
docker compose exec selenium sh -c 'google-chrome --version || chromium --version || microsoft-edge --version || firefox --version' 2>/dev/null
- name: Run tests with Coverage
if: "${{ matrix.with_coverage == true }}"
env:
SELENIUM_VERSION: ${{ matrix.selenium_version }}
DRIVER_URL: http://localhost:4444/wd/hub
WEB_FIXTURES_HOST: http://host.docker.internal:8002
WEB_FIXTURES_BROWSER: ${{ matrix.browser }}
DRIVER_MACHINE_BASE_PATH: /fixtures/
run: |
vendor/bin/phpunit -v --coverage-clover=coverage.xml --log-junit junit.xml
- name: Run tests without Coverage
if: "${{ matrix.with_coverage == false }}"
env:
SELENIUM_VERSION: ${{ matrix.selenium_version }}
DRIVER_URL: http://localhost:4444/wd/hub
WEB_FIXTURES_HOST: http://host.docker.internal:8002
WEB_FIXTURES_BROWSER: ${{ matrix.browser }}
DRIVER_MACHINE_BASE_PATH: /fixtures/
run: |
vendor/bin/phpunit -v --log-junit junit.xml
- name: Upload coverage to Codecov
if: ${{ matrix.with_coverage == true && !cancelled() }}
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
- name: Upload test results to Codecov
if: ${{ !cancelled() }}
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: junit.xml
report_type: test_results
- name: Extract docker logs
if: ${{ failure() }}
run: |
docker compose logs --no-color &> ./logs/selenium.log
- name: Archive logs artifacts
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: logs_php-${{ matrix.php }}_selenium-${{ matrix.selenium_version }}_${{ matrix.browser }}
path: |
logs