-
Notifications
You must be signed in to change notification settings - Fork 0
156 lines (128 loc) · 4.07 KB
/
ci.yml
File metadata and controls
156 lines (128 loc) · 4.07 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
name: CI
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
# ═══════════════════════════════════════════════════════════
# Stage 1 — Build + Code Quality (parallel)
# ═══════════════════════════════════════════════════════════
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 22
cache: 'npm'
- name: Install dependencies (root)
run: npm ci
- name: Install dependencies (dashboard)
working-directory: ./dashboard
run: npm ci
- name: Build dashboard
working-directory: ./dashboard
run: npm run build
audit:
name: Audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 22
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run npm audit
run: npm run audit
continue-on-error: true
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 22
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run ESLint
run: npm run lint
format:
name: Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 22
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Check Prettier formatting
run: npm run format:check
# ═══════════════════════════════════════════════════════════
# Stage 2 — Tests + Docker (depends on Stage 1)
# ═══════════════════════════════════════════════════════════
test:
name: Test
runs-on: ubuntu-latest
needs: [build, audit, lint, format]
steps:
- uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 22
cache: 'npm'
- name: Install dependencies (root)
run: npm ci
- name: Install dependencies (dashboard)
working-directory: ./dashboard
run: npm ci
- name: Run tests
run: npm test
env:
NODE_ENV: test
JWT_SECRET: test-jwt-secret-min-16-chars
ADMIN_USERNAME: admin
ADMIN_PASSWORD: admin123
docker-build:
name: Docker Build
runs-on: ubuntu-latest
needs: [build, audit, lint, format]
steps:
- uses: actions/checkout@v6
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Build Docker image
uses: docker/build-push-action@v7
with:
context: .
push: false
load: true
tags: funcdock:latest
cache-from: type=gha
- name: Validate Docker image
run: |
docker run -d --name funcdock-ci -p 3000:3000 \
-e JWT_SECRET=ci-jwt-secret-min-16-chars \
-e ADMIN_USERNAME=admin \
-e ADMIN_PASSWORD=admin123 \
-e DEPLOY_API_KEY=ci-deploy-key \
funcdock:latest
sleep 5
curl -sf http://localhost:3000/api/status -H "x-deploy-api-key: ci-deploy-key" || exit 1
docker stop funcdock-ci
docker rm funcdock-ci