-
Notifications
You must be signed in to change notification settings - Fork 0
154 lines (131 loc) · 4.17 KB
/
Copy pathci.yml
File metadata and controls
154 lines (131 loc) · 4.17 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
name: CI
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
jobs:
lint-and-build:
name: Lint and Build
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: |
# Note: Deprecation warnings for inflight@1.0.6 and glob@7.2.3 are expected
# These come from Jest's transitive dependencies and are harmless.
# They will be resolved when Jest updates its dependencies.
if [ -f "package-lock.json" ]; then
npm ci
else
echo "package-lock.json not found, generating it with npm install"
npm install
fi
- name: Type check
run: npm run build
- name: Check for linting errors
run: |
# Run build to catch TypeScript errors
npm run build
# If you add ESLint later, uncomment:
# npm run lint
test:
name: Run Tests
runs-on: ubuntu-latest
needs: lint-and-build
permissions:
contents: read
checks: write
env:
NODE_ENV: test
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/test
REDIS_URL: redis://localhost:6379
PROPERTY_TEST_RUNS: 100
JWT_SECRET: test-secret-key-for-ci
API_KEY_SALT: test-salt-for-ci
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup PostgreSQL
run: |
docker run -d \
--name test-postgres \
-e POSTGRES_DB=test \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=postgres \
-p 5432:5432 \
postgres:14-alpine
# Wait for PostgreSQL to be ready
for i in {1..30}; do
if docker exec test-postgres pg_isready -U postgres > /dev/null 2>&1; then
echo "PostgreSQL is ready!"
break
fi
sleep 2
done
- name: Setup Redis
run: |
docker run -d \
--name test-redis \
-p 6379:6379 \
redis:7-alpine
# Wait for Redis to be ready
for i in {1..30}; do
if docker exec test-redis redis-cli ping | grep -q PONG; then
echo "Redis is ready!"
break
fi
sleep 2
done
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: |
# Note: Deprecation warnings for inflight@1.0.6 and glob@7.2.3 are expected
# These come from Jest's transitive dependencies and are harmless.
# They will be resolved when Jest updates its dependencies.
if [ -f "package-lock.json" ]; then
npm ci
else
echo "package-lock.json not found, generating it with npm install"
npm install
fi
- name: Cache Jest cache
uses: actions/cache@v4
with:
path: .jest-cache
key: jest-cache-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
restore-keys: |
jest-cache-${{ runner.os }}-
- name: Build project
run: npm run build
- name: Run tests
run: |
# Run tests with optimized settings for CI
# --maxWorkers=100% uses all available CPU cores
# --bail stops on first failure (already set in config but explicit here)
# --no-coverage skips coverage collection (faster, only collect when needed)
npm run test:ci -- --maxWorkers=100% --no-coverage
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results
path: |
junit.xml
retention-days: 30
- name: Publish test results
if: always()
uses: EnricoMi/publish-unit-test-result-action@v2
with:
files: junit.xml
check_name: Test Results