-
Notifications
You must be signed in to change notification settings - Fork 1
165 lines (141 loc) · 4.91 KB
/
Copy pathci.yml
File metadata and controls
165 lines (141 loc) · 4.91 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
name: CI
on:
pull_request:
push:
branches:
- main
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
permissions:
contents: read
jobs:
changes:
runs-on: ubuntu-latest
outputs:
typescript: ${{ steps.filter.outputs.typescript }}
python: ${{ steps.filter.outputs.python }}
infra: ${{ steps.filter.outputs.infra }}
workflow: ${{ steps.filter.outputs.workflow }}
steps:
- uses: step-security/harden-runner@ab7a9404c0f3da075243ca237b5fac12c98deaa5 # v2
with:
egress-policy: audit
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
with:
# paths-filter runs with token: "" below, so it needs enough history
# to compare commits locally instead of calling the PR files API.
fetch-depth: 0
persist-credentials: false
- id: filter
uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4
with:
# Keep the workflow at contents:read. Empty token forces git-based
# detection and avoids requiring pull-requests:read.
token: ""
filters: |
typescript:
- "stacks/typescript/**"
- "package.json"
- "bun.lock"
- "bunfig.toml"
- "biome.json"
- "scripts/*.sh"
python:
- "stacks/python/**"
infra:
- "compose.yml"
- "docker-compose.yml"
- ".env.example"
workflow:
- ".github/workflows/**"
typescript:
needs: changes
if: needs.changes.outputs.typescript == 'true' || needs.changes.outputs.workflow == 'true'
runs-on: ubuntu-latest
steps:
- uses: step-security/harden-runner@ab7a9404c0f3da075243ca237b5fac12c98deaa5 # v2
with:
egress-policy: audit
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
with:
persist-credentials: false
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
with:
bun-version: 1.3.13
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Biome
run: bun run lint
- name: Typecheck
run: bun run typecheck
- name: Tests
run: bun run test
- name: Build
run: bun run build
python:
needs: changes
if: needs.changes.outputs.python == 'true' || needs.changes.outputs.workflow == 'true'
runs-on: ubuntu-latest
steps:
- uses: step-security/harden-runner@ab7a9404c0f3da075243ca237b5fac12c98deaa5 # v2
with:
egress-policy: audit
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
with:
persist-credentials: false
- uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0
with:
enable-cache: true
- name: Install Python
run: uv python install 3.12
- name: Install dependencies
working-directory: stacks/python
run: uv sync --locked
- name: Check Python stack
run: ./stacks/python/scripts/check-all.sh
compose:
needs: changes
if: needs.changes.outputs.infra == 'true' || needs.changes.outputs.workflow == 'true'
runs-on: ubuntu-latest
steps:
- uses: step-security/harden-runner@ab7a9404c0f3da075243ca237b5fac12c98deaa5 # v2
with:
egress-policy: audit
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
with:
persist-credentials: false
- name: Validate Compose config
run: docker compose -f compose.yml --env-file .env.example config
ci-passed:
if: always()
needs:
- changes
- typescript
- python
- compose
runs-on: ubuntu-latest
steps:
- name: Check required jobs
run: |
changes_result='${{ needs.changes.result }}'
typescript_result='${{ needs.typescript.result }}'
python_result='${{ needs.python.result }}'
compose_result='${{ needs.compose.result }}'
if [ "$changes_result" != "success" ]; then
echo "The changes job did not pass: changes=${changes_result}" >&2
exit 1
fi
# Component jobs may be skipped by the path filter. That is healthy
# only when path detection itself succeeded, which is checked above.
for result in "$typescript_result" "$python_result" "$compose_result"; do
case "$result" in
success|skipped)
;;
*)
echo "A required CI job did not pass: changes=${changes_result}, typescript=${typescript_result}, python=${python_result}, compose=${compose_result}" >&2
exit 1
;;
esac
done