-
Notifications
You must be signed in to change notification settings - Fork 0
250 lines (210 loc) · 7.55 KB
/
Copy pathci.yml
File metadata and controls
250 lines (210 loc) · 7.55 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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
# .github/workflows/ci.yml
#
# GalaxyQuest — Main CI/CD Pipeline
#
# Runs on every push to main and on every pull request targeting main.
#
# Jobs:
# lint-php — PHP linting with custom architecture rules
# lint-js — ESLint with Galaxy architecture rules
# phpunit — PHPUnit unit tests (PHP 8.2 + MySQL 8.4 service)
# vitest — Vitest JavaScript unit tests
# playwright-smoke — Playwright end-to-end smoke test (full Docker stack)
# docker-build — Build & push versioned Docker image to GHCR (main only)
name: CI/CD Pipeline
on:
push:
branches:
- main
- master
pull_request:
branches:
- main
- master
# Default: restrict all jobs to read-only access; individual jobs that need
# extra permissions (e.g. docker-build → packages: write) override this.
permissions:
contents: read
jobs:
# ── PHP Architecture Linting ────────────────────────────────────────────────
lint-php:
name: PHP Architecture Validation
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up PHP 8.2
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: pdo, pdo_sqlite
coverage: none
- name: Install PHP CodeSniffer
run: composer require --dev squizlabs/php_codesniffer --prefer-dist --no-interaction
- name: Validate PHP architecture with custom ruleset
run: vendor/bin/phpcs --standard=ruleset.xml src/ tests/ --exclude=tests/bootstrap.php
continue-on-error: true
# ── JavaScript Architecture Linting ─────────────────────────────────────────
lint-js:
name: JavaScript Architecture Validation
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Validate JavaScript architecture with custom ESLint config
run: npx eslint js/features/galaxy/ --config .eslintrc.galaxy.js --format=stylish || echo "Note: ESLint validation completed (warnings/errors logged)"
# ── PHP Unit Tests ──────────────────────────────────────────────────────────
phpunit:
name: PHPUnit Tests
runs-on: ubuntu-latest
permissions:
contents: read
services:
mysql:
image: mysql:8.4
env:
MYSQL_DATABASE: galaxyquest
MYSQL_USER: galaxyquest_user
MYSQL_PASSWORD: galaxyquest_dev
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping -h localhost -proot"
--health-interval=5s
--health-timeout=5s
--health-retries=20
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up PHP 8.2
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: pdo_mysql, gd
coverage: none
- name: Install Composer dependencies
run: composer install --no-interaction --prefer-dist --no-progress
- name: Initialise database schema and migrations
run: |
mysql -h 127.0.0.1 -u galaxyquest_user -pgalaxquest_dev galaxyquest \
< sql/schema.sql
# Apply all incremental migration files in alphabetical order so
# that new migrations are picked up automatically.
for f in sql/migrate_*.sql; do
[ -e "$f" ] || continue
echo "Applying $f …"
mysql -h 127.0.0.1 -u galaxyquest_user -pgalaxquest_dev galaxyquest < "$f"
done
- name: Run PHPUnit
env:
DB_HOST: 127.0.0.1
DB_PORT: 3306
DB_NAME: galaxyquest
DB_USER: galaxyquest_user
DB_PASS: galaxyquest_dev
run: vendor/bin/phpunit --no-coverage
# ── JavaScript Unit Tests ───────────────────────────────────────────────────
vitest:
name: Vitest Unit Tests
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run Vitest
run: npx vitest run --reporter=verbose
# ── End-to-End Smoke Test ───────────────────────────────────────────────────
playwright-smoke:
name: Playwright E2E Smoke Test
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Install Playwright Chromium browser
run: npx playwright install chromium --with-deps
- name: Start application stack (web + db + tts)
run: docker compose up -d --wait
timeout-minutes: 10
- name: Seed E2E test user
run: |
docker compose exec -T web php scripts/ensure_default_e2e_user.php \
--username=default_user \
--password=User!23456 \
--email=default_user@local.test
- name: Run view-flow smoke test
env:
GQ_BASE_URL: http://localhost:8080
run: |
npx playwright test tests/e2e/view-flow.spec.js \
--reporter=list \
--project=chromium
- name: Upload Playwright report on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: playwright-smoke-report
path: playwright-report/
retention-days: 7
docker-build:
name: Build & Publish Docker Image
runs-on: ubuntu-latest
# Only publish images for pushes to main (not PRs)
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: [phpunit, vitest]
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=sha,prefix=sha-
type=ref,event=branch
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}