-
Notifications
You must be signed in to change notification settings - Fork 0
109 lines (84 loc) · 3.22 KB
/
ci.yml
File metadata and controls
109 lines (84 loc) · 3.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
name: CI
on:
pull_request:
push:
branches:
- main
jobs:
validate:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
cache-dependency-path: |
backend/package-lock.json
frontend/package-lock.json
- name: Install frontend dependencies
working-directory: frontend
run: npm ci
- name: Install backend dependencies
working-directory: backend
run: npm ci
- name: Validate committed public docs config (before local overrides)
run: node scripts/validate-committed-docs-config.mjs
- name: Check docs and release helper syntax
run: |
node --check docs/bookmarklet.js
node --check docs/config.js
node --check docs/install.js
node --check scripts/write-public-config.mjs
node --check scripts/validate-public-docs.mjs
node --check scripts/validate-committed-docs-config.mjs
node --check scripts/lib/public-origin.mjs
- name: Verify docs screenshot script syntax
run: node --check scripts/capture-docs-screenshots.mjs
- name: Validate local docs/bookmarklet config
run: |
APP_ENV=local node scripts/write-public-config.mjs
APP_ENV=local node scripts/validate-public-docs.mjs
- name: Validate staging docs/bookmarklet config
run: |
APP_ENV=staging BOOKMARKLET_APP_ORIGIN=https://staging.example.com node scripts/write-public-config.mjs
APP_ENV=staging BOOKMARKLET_APP_ORIGIN=https://staging.example.com node scripts/validate-public-docs.mjs
- name: Validate production docs/bookmarklet config
run: |
APP_ENV=production BOOKMARKLET_APP_ORIGIN=https://crawler.example.com node scripts/write-public-config.mjs
APP_ENV=production BOOKMARKLET_APP_ORIGIN=https://crawler.example.com node scripts/validate-public-docs.mjs
- name: Lint backend
working-directory: backend
run: npm run lint
- name: Run backend tests
working-directory: backend
run: npm test
- name: Lint frontend
working-directory: frontend
run: npm run lint
- name: Run frontend tests
working-directory: frontend
run: npm test
- name: Build production Docker image
run: docker build --tag site-crawler-ci:${{ github.sha }} .
- name: Smoke test production Docker image
run: |
set -euo pipefail
image="site-crawler-ci:${{ github.sha }}"
container="site-crawler-ci"
cleanup() {
docker rm -f "$container" >/dev/null 2>&1 || true
}
trap cleanup EXIT
docker run -d --name "$container" -p 127.0.0.1:8080:8080 "$image"
for attempt in $(seq 1 30); do
if curl --silent --show-error --fail http://127.0.0.1:8080/healthz >/tmp/site-crawler-healthz.json; then
cat /tmp/site-crawler-healthz.json
exit 0
fi
sleep 1
done
docker logs "$container"
exit 1