forked from QuickLendX/quicklendx-protocol
-
Notifications
You must be signed in to change notification settings - Fork 0
118 lines (95 loc) · 2.94 KB
/
Copy pathbackend-ci.yml
File metadata and controls
118 lines (95 loc) · 2.94 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
name: Backend CI
on:
push:
branches: ["main"]
paths:
- 'backend/**'
pull_request:
branches: ["main"]
paths:
- 'backend/**'
release:
types: [published]
workflow_dispatch:
env:
NODE_VERSION: '20'
jobs:
security_scan:
name: Dependency Vulnerability Scan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
cache-dependency-path: backend/package-lock.json
- name: Install dependencies
run: npm ci
working-directory: backend
- name: Create npm audit report JSON
run: npm audit --json > audit-report.json || true
working-directory: backend
- name: Enforce vulnerability gate
run: npm run security:scan
working-directory: backend
- name: Upload audit report artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: backend-audit-report
path: backend/audit-report.json
retention-days: 14
test:
name: Test and Coverage
runs-on: ubuntu-latest
needs: security_scan
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
cache-dependency-path: backend/package-lock.json
- name: Install dependencies
run: npm ci
working-directory: backend
- name: Type check
run: npx tsc --noEmit
working-directory: backend
- name: Run tests with coverage
run: npm run test:coverage
working-directory: backend
- name: Run performance regression tests
run: npx jest "perf/perf.test.ts" --no-coverage
working-directory: backend
sbom:
name: Generate SBOM Artifact
runs-on: ubuntu-latest
needs: security_scan
if: github.event_name == 'pull_request' || github.event_name == 'release' || github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
cache-dependency-path: backend/package-lock.json
- name: Install dependencies
run: npm ci
working-directory: backend
- name: Generate CycloneDX SBOM
run: npm run sbom:generate
working-directory: backend
- name: Validate generated SBOM
run: npm run sbom:check
working-directory: backend
- name: Upload SBOM artifact
uses: actions/upload-artifact@v4
with:
name: backend-sbom-${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || github.ref_name }}
path: backend/sbom/backend-sbom.cdx.json
retention-days: 90