-
Notifications
You must be signed in to change notification settings - Fork 1
148 lines (143 loc) · 6.07 KB
/
Copy pathqa.yml
File metadata and controls
148 lines (143 loc) · 6.07 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
name: Quality Checks
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
generated-guard:
name: Generated Types Guard
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Enforce generated-file marker (OpenAPI types)
# Catches hand-edits to files under packages/Types/lib/Generated/.
# Every .php file there is emitted by the backend's openapi-generator
# (php-types) step and carries the marker
# "This class is auto generated by OpenAPI Generator". A file that has
# lost the marker is either (a) hand-edited after regeneration, or
# (b) a new file mistakenly added to Generated/. Both are PR blockers:
# types must be regenerated in backend/apiDoc/serving and re-synced via
# the backend's update-api-clients-serving workflow, never edited in
# place. Mirrors the android-sdk precedent (.github/workflows/ci.yml).
#
# Unlike android (which greps head -1 for its marker), the PHP marker
# sits inside the file's docblock (files start with "<?php"), so the
# grep must scan the whole file. The whitelist covers ALL generated
# .php files — Model/ AND the non-Model infra (Api/, ObjectSerializer,
# Configuration, HeaderSelector, ApiException) — not just Model/.
run: |
set -euo pipefail
GEN_DIR=packages/Types/lib/Generated
MARKER="This class is auto generated by OpenAPI Generator"
if [ ! -d "$GEN_DIR" ]; then
echo "ERROR: generated directory not found: $GEN_DIR"
exit 1
fi
missing=0
while IFS= read -r -d '' file; do
if ! grep -qF "$MARKER" "$file"; then
echo "ERROR: $file is missing the OpenAPI generated-file marker."
echo " Regenerate the PHP types in backend/apiDoc/serving"
echo " (yarn generatePhpTypes) and re-sync via the backend's"
echo " update-api-clients-serving workflow. Do not hand-edit"
echo " files under $GEN_DIR."
missing=1
fi
done < <(find "$GEN_DIR" -name '*.php' -print0)
if [ "$missing" -ne 0 ]; then
exit 1
fi
echo "OK: every .php file under $GEN_DIR carries the OpenAPI generated-file marker."
lint:
name: Code Style
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2
with:
php-version: '8.4'
tools: composer:v2
coverage: none
- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: ~/.composer/cache
key: composer-${{ hashFiles('composer.json') }}
restore-keys: composer-
- run: composer install --no-interaction --no-progress
- run: composer cs-check
validate:
name: Monorepo Validation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2
with:
php-version: '8.4'
tools: composer:v2
coverage: none
- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: ~/.composer/cache
key: composer-${{ hashFiles('composer.json') }}
restore-keys: composer-
- run: composer install --no-interaction --no-progress
- run: composer build:validate
test:
name: Tests (PHP ${{ matrix.php-version }}, ${{ matrix.dependency-preference }})
runs-on: ubuntu-latest
env:
CONVERT_STAGING_SDK_KEY: ${{ secrets.CONVERT_STAGING_SDK_KEY }}
CONVERT_STAGING_SDK_KEY2: ${{ secrets.CONVERT_STAGING_SDK_KEY2 }}
CONVERT_STAGING_SDK_KEY2_SECRET: ${{ secrets.CONVERT_STAGING_SDK_KEY2_SECRET }}
strategy:
fail-fast: false
matrix:
php-version: ['8.2', '8.3', '8.4']
dependency-preference: ['prefer-lowest', 'prefer-stable']
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2
with:
php-version: ${{ matrix.php-version }}
tools: composer:v2
coverage: pcov
- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: ~/.composer/cache
key: composer-php${{ matrix.php-version }}-${{ matrix.dependency-preference }}-${{ hashFiles('composer.json') }}
restore-keys: |
composer-php${{ matrix.php-version }}-${{ matrix.dependency-preference }}-
composer-php${{ matrix.php-version }}-
- name: Install dependencies
run: composer update --${{ matrix.dependency-preference }} --prefer-stable --no-interaction --no-progress
- name: Run tests with coverage
if: matrix.php-version == '8.4' && matrix.dependency-preference == 'prefer-stable'
run: composer test:coverage:ci
- name: Enforce 85% coverage threshold
if: matrix.php-version == '8.4' && matrix.dependency-preference == 'prefer-stable'
run: |
php -r "
\$x = new SimpleXMLElement(file_get_contents('coverage.xml'));
\$m = \$x->project->metrics;
\$statements = (int)\$m['statements'];
if (\$statements === 0) { echo 'Error: zero statements in coverage report'; exit(1); }
\$pct = round(((int)\$m['coveredstatements'] / \$statements) * 100, 2);
echo \"Code coverage: {\$pct}%\n\";
exit(\$pct >= 85.0 ? 0 : 1);
"
- name: Upload coverage report
if: matrix.php-version == '8.4' && matrix.dependency-preference == 'prefer-stable'
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: coverage.xml
retention-days: 30
- name: Run tests without coverage
if: matrix.php-version != '8.4' || matrix.dependency-preference != 'prefer-stable'
run: composer test
- name: Run cross-SDK parity tests
run: composer test:cross-sdk