-
-
Notifications
You must be signed in to change notification settings - Fork 6
167 lines (157 loc) · 5.16 KB
/
pr-ci.yml
File metadata and controls
167 lines (157 loc) · 5.16 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
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:
- uses: actions/checkout@v4
- name: Filter
id: filter
uses: dorny/paths-filter@v3
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:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
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:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
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:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
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:
- uses: actions/checkout@v4
- 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:
- uses: actions/checkout@v4
- name: Set up Temurin JDK
uses: actions/setup-java@v4
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: 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.'