-
Notifications
You must be signed in to change notification settings - Fork 117
132 lines (117 loc) · 3.6 KB
/
Copy pathci.yml
File metadata and controls
132 lines (117 loc) · 3.6 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
name: CI
on:
push:
branches: ["main"]
pull_request:
workflow_dispatch:
schedule:
- cron: '0 6 * * 1'
jobs:
build-and-smoke:
runs-on: ubuntu-latest
strategy:
max-parallel: 1
matrix:
# Angular 22 requires Node ^22.22.3 || ^24.15.0 || >=26.0.0
node-version: [24.18.0, 26.5.0]
services:
mongodb:
image: mongo:latest
options: >-
--health-cmd "mongosh --eval 'db.adminCommand({ ping: 1 })'"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 27017:27017
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: npm
- name: Install dependencies
run: npm ci
- name: Build
env:
DATABASE_URI: mongodb://localhost:27017/
run: npm run build
- name: Server lint tests
env:
DATABASE_URI: mongodb://localhost:27017/
run: npm run test:server
- name: Integration tests
run: npm run test:integration
- name: Seed demo data
env:
DATABASE_URI: mongodb://localhost:27017/meanStackExample?appName=mean-stack-example-ci
run: npm run seed
- name: Start API
env:
DATABASE_URI: mongodb://localhost:27017/meanStackExample?appName=mean-stack-example-ci
PORT: 5300
run: |
npm run start:server > /tmp/server.log 2>&1 &
echo $! > /tmp/server.pid
- name: Wait for API health
run: |
for i in {1..30}; do
if curl -fsS http://localhost:5300/healthcheck >/dev/null; then
echo "API is ready"
exit 0
fi
sleep 1
done
echo "API did not become ready"
cat /tmp/server.log
exit 1
- name: Smoke check employee list endpoint
run: curl -fsS http://localhost:5300/employees
- name: Stop API
if: always()
run: |
if [ -f /tmp/server.pid ]; then
kill "$(cat /tmp/server.pid)" || true
fi
notify-on-failure:
needs: build-and-smoke
if: failure()
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: File or update CI failure issue for @mongodb-developer/learning-fuel
uses: actions/github-script@v7
with:
script: |
const title = `CI failure on ${context.ref}`;
const body = [
'@mongodb-developer/learning-fuel the CI workflow failed.',
'',
`Workflow: ${context.workflow}`,
`Run: ${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`,
].join('\n');
const { data: existing } = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
labels: 'ci-failure',
});
if (existing.length > 0) {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: existing[0].number,
body,
});
} else {
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title,
body,
labels: ['ci-failure'],
});
}