-
Notifications
You must be signed in to change notification settings - Fork 69
150 lines (131 loc) · 5 KB
/
frontend-build.yml
File metadata and controls
150 lines (131 loc) · 5 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
name: Frontend Build
on:
workflow_call:
inputs:
node_version:
description: Node.js version
required: true
default: "24.x"
type: string
pull_number:
description: Pull request number when available
required: false
default: ""
type: string
permissions:
contents: read
jobs:
build:
name: Frontend Build
runs-on: ubuntu-latest
defaults:
run:
working-directory: src/frontend
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Ensure full git history for Lunaria
env:
PULL_NUMBER: ${{ inputs.pull_number }}
run: |
if [ -n "$PULL_NUMBER" ]; then
case "$PULL_NUMBER" in
(*[!0-9]*)
echo "Invalid pull_number input: '$PULL_NUMBER'" >&2
exit 1
;;
esac
pull_ref="+refs/pull/${PULL_NUMBER}/head:refs/remotes/origin/pull/${PULL_NUMBER}/head"
if [ "$(git rev-parse --is-shallow-repository)" = "true" ]; then
git fetch origin "$pull_ref" --unshallow
else
git fetch origin "$pull_ref"
fi
elif [ "$(git rev-parse --is-shallow-repository)" = "true" ]; then
git fetch --unshallow
fi
- uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5.0.0
with:
version: 10
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: ${{ inputs.node_version }}
cache: pnpm
cache-dependency-path: src/frontend/pnpm-lock.yaml
- name: Install deps
run: pnpm install --frozen-lockfile
# Build BEFORE tests so that Lunaria (i18n status) runs against a
# pristine working tree. The lint step inside test:all calls
# `astro sync` which can leave generated artifacts on disk; when
# the build ran second, Lunaria would see those as uncommitted
# changes and fail with a doubled rootDir path
# (src/frontend/src/frontend/…).
- name: Build frontend
env:
MODE: production
ASTRO_TELEMETRY_DISABLED: 1
run: pnpm build:production
# Upload before the dist sanity-check so the artifact is always
# available for debugging, even when the check step fails.
# Note: `uses` actions ignore the job-level working-directory,
# so the path is repo-root-relative (src/frontend/dist).
- name: Upload build artifact
if: ${{ always() }}
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: frontend-dist
path: src/frontend/dist
if-no-files-found: warn
retention-days: 7
- name: Check dist
run: |
if [ ! -d "dist" ]; then
echo "Frontend build failed - dist directory not found"
exit 1
fi
if [ ! -f "dist/index.html" ]; then
echo "Frontend build incomplete - index.html not found"
exit 1
fi
ls -la dist
- name: Install Playwright Chromium
run: pnpm exec playwright install --with-deps chromium
- name: Run frontend all tests
env:
ASTRO_TELEMETRY_DISABLED: 1
run: pnpm test:all
- name: Upload Playwright HTML report
if: ${{ always() }}
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: frontend-playwright-report
path: src/frontend/playwright-report
if-no-files-found: warn
retention-days: 7
- name: Upload Playwright raw results
if: ${{ always() }}
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: frontend-test-results
path: src/frontend/test-results
if-no-files-found: warn
retention-days: 7
- name: Summarize frontend quality gates
if: ${{ always() }}
run: |
{
echo '## Frontend quality reports'
echo ''
echo '- Lint gate: ESLint runs before browser and unit coverage.'
echo '- Unit contracts: static analytics delivery and route regressions.'
echo '- Browser coverage: Playwright runs on desktop, tablet, and mobile Chromium profiles.'
echo '- Accessibility gate: WCAG 2.0 A/AA audit, including color-contrast.'
echo '- Responsive gate: viewport-specific UI behavior is asserted in Playwright.'
echo '- GitHub diagnostics: Playwright github reporter emits workflow annotations.'
echo '- Artifacts: HTML report, JUnit XML, screenshots, traces, videos, and raw test outputs.'
echo ''
echo 'Artifacts:'
echo '- `frontend-playwright-report`'
echo '- `frontend-test-results`'
} >> "$GITHUB_STEP_SUMMARY"