Repository navigation
144 lines (116 loc) · 4.22 KB
/
Copy pathqa.yml
File metadata and controls
144 lines (116 loc) · 4.22 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
name: QA
on:
push:
branches: [main, dev]
pull_request:
permissions:
contents: read
concurrency:
group: qa-${{ github.ref }}
cancel-in-progress: true
jobs:
baseline-drift:
name: PHPStan baseline drift
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check phpstan-baseline.neon additions are justified
shell: bash
run: |
set -euo pipefail
# The full checkout (fetch-depth: 0) already has the base branch.
BASE="origin/${{ github.base_ref }}"
# Count lines added to the baseline that look like a new ignore entry.
# Commented lines (such as the example in the file header) are skipped.
# grep exits 1 when nothing matches, which pipefail would turn into a failure.
ADDED=$(git diff "$BASE"...HEAD -- phpstan-baseline.neon \
| { grep -E '^\+[[:space:]]*message:' || true; } \
| wc -l \
| tr -d ' ')
if [ "$ADDED" = "0" ]; then
echo "No new baseline entries. OK."
exit 0
fi
echo "Detected $ADDED new baseline entries; checking for matching BASELINE: blocks..."
JUSTIFIED=$(git diff "$BASE"...HEAD -- phpstan-baseline.neon \
| { grep -E '^\+\s*#\s*BASELINE:' || true; } \
| wc -l \
| tr -d ' ')
if [ "$JUSTIFIED" -lt "$ADDED" ]; then
echo "::error::phpstan-baseline.neon grew by $ADDED entries but only $JUSTIFIED BASELINE: justifications were added."
echo "Add a '# BASELINE: <reason>' comment block per new entry, optionally followed by '# Upstream: <link>'."
exit 1
fi
echo "Baseline additions are justified. OK."
php:
name: PHP ${{ matrix.php }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
steps:
- uses: actions/checkout@v4
- name: Setup PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: xdebug
tools: composer:v2
- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
- name: Cache composer dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ matrix.php }}-${{ hashFiles('composer.lock') }}
restore-keys: composer-${{ matrix.php }}-
- name: Install composer dependencies
run: composer install --prefer-dist --no-progress --no-interaction
- name: PHPCS (errors only)
run: composer lint
- name: PHPCS (warnings) - informational
continue-on-error: true
run: composer lint:strict
- name: PHPStan
run: composer stan
- name: PHPUnit - Unit
run: composer test
- name: Upload coverage
if: matrix.php == '8.3'
uses: actions/upload-artifact@v4
with:
name: coverage
path: |
coverage/
coverage.xml
if-no-files-found: ignore
integration:
name: PHPUnit - Integration (wp-env)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup PHP 7.4
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
tools: composer:v2
- name: Install composer dependencies
run: composer install --prefer-dist --no-progress --no-interaction
- uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install npm dependencies
run: npm install --no-audit --no-fund
- name: Start wp-env (test environment)
run: npm run env:test:start
# WooCommerce stores orders either in posts (legacy) or in its own
# tables (HPOS); the WooCheckout code has separate paths for both.
- name: Run integration suite (legacy order storage)
run: npm run test:integration:legacy
- name: Run integration suite (HPOS order storage)
run: npm run test:integration:hpos