Repository navigation
168 lines (151 loc) · 5.85 KB
/
Copy pathtests.yml
File metadata and controls
168 lines (151 loc) · 5.85 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
168
name: Tests
# Unit + integration test suites (see tests/COVERAGE-PLAN.md). Complements the existing gates:
# version-check (tag == VERSION), smoke (boots/migrates/serves), release-zip (vendored ZIP).
# This one runs the actual PHPUnit suites on every push to main and every PR.
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
concurrency:
group: tests-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
# Fast, no services — the bulk of coverage. Full PHP matrix (mirrors smoke.yml).
unit:
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
php: ['8.1', '8.3', '8.4', '8.5']
steps:
- uses: actions/checkout@v4
- name: Set up PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: mbstring, intl, curl, zip, gd, sodium, apcu
ini-values: apc.enable_cli=1, memory_limit=512M
tools: composer:v2
coverage: none
- name: Install dependencies
run: composer install --no-interaction --no-progress --prefer-dist
- name: Unit suite
run: composer test:unit
# The client half of localization. Plain node + assert, no package.json: Tiger.t() is one function
# every module's JavaScript goes through, and a test that needs no toolchain is one that still runs.
javascript:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- name: Syntax-check the theme's browser assets
run: |
for f in themes/puma/assets/js/*.js; do node --check "$f"; done
- name: Tiger.t() contract
run: node tests/js/tiger.i18n.test.js
- name: TigerButton busy state
run: node tests/js/tiger.button.test.js
# Needs a database — one PHP version is enough; the schema, not the interpreter, is under test.
integration:
runs-on: ubuntu-latest
timeout-minutes: 15
services:
mariadb:
image: mariadb:10.11
env:
MARIADB_ROOT_PASSWORD: root
MARIADB_DATABASE: tiger_test
ports: ['3306:3306']
options: >-
--health-cmd="healthcheck.sh --connect --innodb_initialized"
--health-interval=10s
--health-timeout=5s
--health-retries=15
env:
TIGER_TEST_DB_HOST: 127.0.0.1
TIGER_TEST_DB_PORT: 3306
TIGER_TEST_DB_NAME: tiger_test
TIGER_TEST_DB_USER: root
TIGER_TEST_DB_PASS: root
steps:
- uses: actions/checkout@v4
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
extensions: mbstring, intl, pdo_mysql, curl, zip, gd, sodium, apcu
ini-values: apc.enable_cli=1, memory_limit=512M
tools: composer:v2
coverage: none
- name: Install dependencies
run: composer install --no-interaction --no-progress --prefer-dist
- name: Integration suite (real MariaDB schema)
run: composer test:integration
# Full suite under pcov → a coverage summary on every PR (report-only; we ratchet MIN_COVERAGE up as
# the backfill climbs toward the 90% target). Separate from the gating jobs so pcov never slows them.
coverage:
runs-on: ubuntu-latest
timeout-minutes: 20
services:
mariadb:
image: mariadb:10.11
env:
MARIADB_ROOT_PASSWORD: root
MARIADB_DATABASE: tiger_test
ports: ['3306:3306']
options: >-
--health-cmd="healthcheck.sh --connect --innodb_initialized"
--health-interval=10s
--health-timeout=5s
--health-retries=15
env:
TIGER_TEST_DB_HOST: 127.0.0.1
TIGER_TEST_DB_PORT: 3306
TIGER_TEST_DB_NAME: tiger_test
TIGER_TEST_DB_USER: root
TIGER_TEST_DB_PASS: root
# The floor we enforce today (report-only warning above it). Bump this as coverage climbs so it
# can only go UP — the ratchet that gets us to 90% without ever regressing.
MIN_COVERAGE: '72'
steps:
- uses: actions/checkout@v4
- name: Set up PHP (pcov)
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
extensions: mbstring, intl, pdo_mysql, curl, zip, gd, sodium, apcu
ini-values: apc.enable_cli=1, memory_limit=512M
tools: composer:v2
coverage: pcov
- name: Install dependencies
run: composer install --no-interaction --no-progress --prefer-dist
- name: Full suite with coverage
run: |
vendor/bin/phpunit --coverage-text=coverage.txt --coverage-clover=clover.xml --colors=never
- name: Publish coverage summary
if: always()
run: |
# The overall line-coverage % from Clover (covered / total elements).
PCT=$(php -r '
$x = simplexml_load_file("clover.xml");
$m = $x->project->metrics;
$c = (int)$m["coveredstatements"]; $t = (int)$m["statements"];
printf("%.1f", $t ? 100*$c/$t : 0);
')
echo "## Code coverage: ${PCT}% lines" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
echo "Floor (MIN_COVERAGE): ${MIN_COVERAGE}% — target: 90%." >> "$GITHUB_STEP_SUMMARY"
echo '```' >> "$GITHUB_STEP_SUMMARY"
sed -n '/Summary:/,/^$/p' coverage.txt >> "$GITHUB_STEP_SUMMARY"
echo '```' >> "$GITHUB_STEP_SUMMARY"
echo "Line coverage: ${PCT}% (floor ${MIN_COVERAGE}%, target 90%)"
# Report-only fail guard against the floor, so coverage can never silently regress below it.
php -r 'exit((float)$argv[1] + 1e-9 < (float)$argv[2] ? 1 : 0);' "$PCT" "$MIN_COVERAGE" \
|| { echo "::error::Coverage ${PCT}% fell below the ${MIN_COVERAGE}% floor"; exit 1; }