-
-
Notifications
You must be signed in to change notification settings - Fork 6
202 lines (185 loc) · 7.02 KB
/
pr-ci.yml
File metadata and controls
202 lines (185 loc) · 7.02 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
name: PR CI (Templates)
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
branches: [ main ]
permissions:
contents: read
pull-requests: read
concurrency:
group: pr-ci-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
changes:
name: Detect Template Changes
runs-on: ubuntu-latest
outputs:
node: ${{ steps.filter.outputs.node }}
python: ${{ steps.filter.outputs.python }}
go: ${{ steps.filter.outputs.go }}
java: ${{ steps.filter.outputs.java }}
frontend: ${{ steps.filter.outputs.frontend }}
any: ${{ steps.filter.outputs.any }}
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
with:
egress-policy: audit
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- name: Filter
id: filter
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
with:
filters: |
node:
- 'templates/node/**'
python:
- 'templates/python/**'
go:
- 'templates/go/**'
java:
- 'templates/spring-boot/**'
frontend:
- 'templates/frontend/**'
any:
- 'templates/**'
node:
name: Node Template
needs: changes
if: needs.changes.outputs.node == 'true' || needs.changes.outputs.any == 'true'
runs-on: ubuntu-latest
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
with:
egress-policy: audit
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: '22'
cache: npm
cache-dependency-path: templates/node/package.json
- name: Install deps
working-directory: templates/node
run: npm install --no-audit --no-fund
- name: Lint (placeholder)
run: echo 'No lint config yet';
- name: Smoke run
working-directory: templates/node
run: node src/index.js & sleep 2 && curl -f http://localhost:3001/ || echo 'Sample run complete'
frontend:
name: Next.js Template
needs: changes
if: needs.changes.outputs.frontend == 'true' || needs.changes.outputs.any == 'true'
runs-on: ubuntu-latest
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
with:
egress-policy: audit
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: '20'
cache: npm
cache-dependency-path: templates/frontend/package.json
- name: Install deps
working-directory: templates/frontend
run: npm install --no-audit --no-fund
- name: Build
working-directory: templates/frontend
run: npm run build
python:
name: Python FastAPI Template
needs: changes
if: needs.changes.outputs.python == 'true' || needs.changes.outputs.any == 'true'
runs-on: ubuntu-latest
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
with:
egress-policy: audit
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: '3.12'
cache: 'pip'
cache-dependency-path: templates/python/requirements.txt
- name: Install deps
working-directory: templates/python
run: pip install -r requirements.txt
- name: Import check
working-directory: templates/python
run: python -c "import fastapi, uvicorn"
- name: FastAPI startup (smoke)
working-directory: templates/python
run: |
uvicorn app.main:app --port 3004 &
PID=$!
sleep 2
curl -f http://127.0.0.1:3004/health || (echo 'health check failed'; kill $PID; exit 1)
kill $PID || true
go:
name: Go Template
needs: changes
if: needs.changes.outputs.go == 'true' || needs.changes.outputs.any == 'true'
runs-on: ubuntu-latest
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
with:
egress-policy: audit
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- name: Build
working-directory: templates/go
run: go build -o service main.go
- name: Run & health
working-directory: templates/go
run: |
./service &
PID=$!
sleep 2
curl -f http://127.0.0.1:3002/health || (echo 'no health'; kill $PID; exit 1)
kill $PID || true
java:
name: Spring Boot Template
needs: changes
if: needs.changes.outputs.java == 'true' || needs.changes.outputs.any == 'true'
runs-on: ubuntu-latest
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
with:
egress-policy: audit
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- name: Set up Temurin JDK
uses: actions/setup-java@c1e323688fd81a25caa38c78aa6df2d33d3e20d9 # v4.8.0
with:
distribution: 'temurin'
java-version: '21'
cache: 'maven'
- name: Build (skip tests)
working-directory: templates/spring-boot
run: mvn -B -ntp package -DskipTests
summary:
name: Summary
needs: [node, frontend, python, go, java]
if: always()
runs-on: ubuntu-latest
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
with:
egress-policy: audit
- name: Report matrix
run: |
echo "Node: ${{ needs.node.result }}"
echo "Frontend: ${{ needs.frontend.result }}"
echo "Python: ${{ needs.python.result }}"
echo "Go: ${{ needs.go.result }}"
echo "Java: ${{ needs.java.result }}"
if [[ '${{ needs.node.result }}' == 'failure' || '${{ needs.frontend.result }}' == 'failure' || '${{ needs.python.result }}' == 'failure' || '${{ needs.go.result }}' == 'failure' || '${{ needs.java.result }}' == 'failure' ]]; then
echo 'One or more template jobs failed.'
exit 1
fi
echo 'All selected template jobs passed.'