-
Notifications
You must be signed in to change notification settings - Fork 29
163 lines (129 loc) · 6.33 KB
/
test.yml
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
name: 🏃 tests
on: [ push, pull_request, workflow_call ]
jobs:
compute:
uses: ./.github/workflows/compute.yml
build:
name: 'Build COVERAGE: ${{ matrix.coverage }} - PHP: ${{ matrix.php }}'
needs: [ compute ]
strategy:
fail-fast: false
matrix:
os: ${{ fromJson(needs.compute.outputs.os) }}
coverage: ${{ fromJson(needs.compute.outputs.coverage) }}
php: ${{ fromJson(needs.compute.outputs.php) }}
exclude: ${{ fromJson(needs.compute.outputs.exclude) }}
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Store Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Store PHP code coverage version
id: version-cache
env:
COVERAGE: ${{ matrix.coverage }}
run: |
echo "version=$(echo $COVERAGE | tr -d -c 0-9)" >> $GITHUB_OUTPUT
echo "major=$(echo $COVERAGE | tr -d -c 0-9 | sed 's/.\{2\}$//')" >> $GITHUB_OUTPUT
- uses: actions/cache/restore@v4
id: restore-composer-cache
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-${{ matrix.php }}-${{ steps.version-cache.outputs.major }}-${{ matrix.coverage }}
restore-keys: |
${{ runner.os }}-${{ matrix.php }}-${{ steps.version-cache.outputs.major }}-
${{ runner.os }}-${{ matrix.php }}-
${{ runner.os }}-
- name: Set up PHP Version ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: xdebug
tools: composer:v2
- name: Environment Check
run: |
php --version
composer --version
mkdir -p .Log/coverage/ .Log/log/
- name: Validate composer.json
run: composer validate
- name: Composer install
run: composer update --with "phpunit/php-code-coverage:${{ matrix.coverage }}" --no-interaction
- name: Save composer cache
uses: actions/cache/save@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ steps.restore-composer-cache.outputs.cache-primary-key }}
- name: Lint PHP
run: php .Build/bin/parallel-lint --exclude .Build .
- name: Run PHPUnit
if: ${{ success() || failure() }}
run: find 'tests' -wholename '*Test.php' | parallel --gnu 'echo -e "\n\nRunning test suite {}"; HASH=${{ steps.version-cache.outputs.version }}_$( echo {} | md5sum | cut -d " " -f 1); .Build/bin/phpunit --log-junit .Log/log/junit_$HASH.xml --coverage-php .Log/coverage/coverage_$HASH.cov --coverage-filter src/ tests/ {}'
- name: Archive PHPUnit logs
uses: actions/upload-artifact@v4
with:
name: phpunit-logs-${{ runner.os }}-${{ matrix.php }}-${{ steps.version-cache.outputs.major }}-${{ matrix.coverage }}
path: .Log/*
retention-days: 1
merge:
name: 'Merge COVERAGE: ${{ matrix.coverage }} - PHP: ${{ matrix.php }}'
needs: [ compute, build ]
strategy:
fail-fast: false
matrix:
os: ${{ fromJson(needs.compute.outputs.os) }}
coverage: ${{ fromJson(needs.compute.outputs.major) }}
php: ${{ fromJson(needs.compute.outputs.php) }}
exclude: ${{ fromJson(needs.compute.outputs.exclude) }}
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download PHPUnit logs
uses: actions/download-artifact@v4
with:
path: .Log
pattern: phpunit-logs-${{ runner.os }}-${{ matrix.php }}-${{ matrix.coverage }}-*
merge-multiple: true
- name: Store Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- uses: actions/cache/restore@v4
id: restore-composer-cache
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-${{ matrix.php }}-${{ matrix.coverage }}
restore-keys: |
${{ runner.os }}-${{ matrix.php }}-
${{ runner.os }}-
- name: Set up PHP Version ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: xdebug
tools: composer:v2
- name: Environment Check
run: |
php --version
composer --version
- name: Validate composer.json
run: composer validate
- name: Composer install
run: composer update --with "phpunit/php-code-coverage:^${{ matrix.coverage }}.0" --no-interaction
- name: Save composer cache
uses: actions/cache/save@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ steps.restore-composer-cache.outputs.cache-primary-key }}
- name: Merge log files
run: bin/phpunit-merger log .Log/log/ .Log/junit.xml
- name: Merge coverage files
run: bin/phpunit-merger coverage .Log/coverage/ .Log/coverage.xml
- name: Archive PHPUnit logs
uses: actions/upload-artifact@v4
with:
name: phpunit-logs-merged-${{ runner.os }}-${{ matrix.php }}-${{ matrix.coverage }}
path: .Log/*
retention-days: 1