-
Notifications
You must be signed in to change notification settings - Fork 0
133 lines (127 loc) · 4.13 KB
/
Copy pathquality.yml
File metadata and controls
133 lines (127 loc) · 4.13 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
name: Quality and performance
on:
pull_request:
push:
branches: [main]
jobs:
backend:
runs-on: ubuntu-latest
defaults:
run:
working-directory: backend
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
cache-dependency-path: backend/package-lock.json
- run: npm ci
- run: npm audit --omit=dev --audit-level=high
- run: npm test
- run: npm run validate:regions
- run: npm run build
frontend:
runs-on: ubuntu-latest
defaults:
run:
working-directory: frontend
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
cache-dependency-path: frontend/package-lock.json
- run: npm ci
- run: npm run check-regions
- run: npm run lint
- run: npm test -- --watchAll=false
env:
CI: "true"
- name: Verify committed Cantabria artifacts
run: git diff --exit-code -- src/data/beaches.json src/data/region.json public/manifest.json public/index.html public/icon.png
# Gate on the contributed DATA, separate from the engine's tests: it is what
# a region PR actually changes, and what can break every other region.
region-data:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
defaults:
run:
working-directory: backend
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
cache-dependency-path: backend/package-lock.json
- run: npm ci
# Schema, catalogue (coordinates, duplicate ids, forbidden beaches) and
# that every flag reference has a declared operator.
- run: npm run validate:regions
- name: Quota budget
id: budget
# Shared quotas: a region that does not fit degrades everyone, not just
# itself. Captured before failing so the PR gets the table either way.
run: |
set +e
npm run --silent quota:budget > budget.md
echo "estado=$?" >> "$GITHUB_OUTPUT"
cat budget.md
# Only the text. The destination PR is NOT shipped here: the privileged
# commenter takes it from the run's own metadata, so an artifact written
# by PR code cannot choose where that comment lands.
- name: Upload budget report
if: github.event_name == 'pull_request'
uses: actions/upload-artifact@v4
with:
name: region-quota-budget
path: backend/budget.md
retention-days: 2
- name: Fail if over budget
if: steps.budget.outputs.estado != '0'
run: |
echo "The regions do not fit together on the free tiers; see the budget above." >&2
exit 1
regions:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.detect.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- id: detect
run: |
matrix=$(find regions -mindepth 2 -maxdepth 2 -name region.json \
-printf '%h\n' | xargs -n1 basename | sort | jq -R . | jq -sc .)
echo "matrix=$matrix" >> "$GITHUB_OUTPUT"
region-build:
needs: [frontend, regions]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
region: ${{ fromJson(needs.regions.outputs.matrix) }}
defaults:
run:
working-directory: frontend
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
cache-dependency-path: frontend/package-lock.json
- run: npm ci
- run: npm run build
env:
CI: "false"
GENERATE_SOURCEMAP: "false"
REACT_APP_REGION: ${{ matrix.region }}
# Defined-but-empty on purpose: silences the origin in .env.production
# (it belongs to the region deployed from the repo checkout), so no
# region inherits another region's public domain here.
REACT_APP_SITE_ORIGIN: ""
- run: npm run perf:budget