-
Notifications
You must be signed in to change notification settings - Fork 0
164 lines (137 loc) · 3.94 KB
/
ci.yml
File metadata and controls
164 lines (137 loc) · 3.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
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
name: CI/CD Pipeline
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
jobs:
# Job 1: Code Quality Checks
quality:
name: Code Quality
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
# - name: Run ESLint
# run: npm run lint
# continue-on-error: true
- name: TypeScript type check
run: npm run typecheck
# Job 2: Run Tests
test:
name: Tests
runs-on: ubuntu-latest
needs: quality
services:
# PostgreSQL test database
postgres:
image: postgres:16-alpine
env:
POSTGRES_USER: devmetrics
POSTGRES_PASSWORD: test_password
POSTGRES_DB: devmetrics_test
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5433:5432
# Redis test instance
redis:
image: redis:7-alpine
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6380:6379
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run tests with coverage
run: npm run test:coverage
env:
NODE_ENV: test
TEST_DATABASE_URL: postgresql://devmetrics:test_password@localhost:5433/devmetrics_test
DATABASE_URL: postgresql://devmetrics:test_password@localhost:5433/devmetrics_test
TEST_REDIS_URL: redis://localhost:6380
REDIS_URL: redis://localhost:6380
API_KEY_SECRET: test-secret-key-for-ci-only-minimum-32-chars
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_API_URL: https://api.github.com
CACHE_TTL_SHORT: 300
CACHE_TTL_MEDIUM: 900
CACHE_TTL_LONG: 3600
# - name: Upload coverage to Codecov
# uses: codecov/codecov-action@v4
# with:
# files: ./coverage/lcov.info
# flags: unittests
# name: codecov-umbrella
# fail_ci_if_error: false
# env:
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
# - name: Comment coverage on PR
# if: github.event_name == 'pull_request'
# uses: romeovs/lcov-reporter-action@v0.3.1
# with:
# github-token: ${{ secrets.GITHUB_TOKEN }}
# lcov-file: ./coverage/lcov.info
# Job 3: Build Check
build:
name: Build
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build TypeScript
run: npm run build
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
retention-days: 7
# Job 4: Security Audit
security:
name: Security Audit
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Run npm audit
run: npm audit --audit-level=moderate
continue-on-error: true
- name: Check for vulnerable dependencies
run: |
npm install -g npm-check-updates
ncu --doctor --doctorTest "npm test"
continue-on-error: true