-
Notifications
You must be signed in to change notification settings - Fork 133
133 lines (114 loc) · 3.53 KB
/
Copy pathbackend-ci.yml
File metadata and controls
133 lines (114 loc) · 3.53 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
name: Backend CI
on:
push:
paths:
- 'apps/backend/**'
- '.github/workflows/backend-ci.yml'
pull_request:
paths:
- 'apps/backend/**'
- '.github/workflows/backend-ci.yml'
jobs:
check:
name: Format · Lint · Test
runs-on: ubuntu-latest
services:
redis:
image: redis:7-alpine
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 5s
--health-timeout 3s
--health-retries 5
# The `Run migrations` step below targets DATABASE_URL, so the database
# it points at has to actually exist. Credentials/db name must match the
# DATABASE_URL declared under `env`.
postgres:
image: postgres:16-alpine
ports:
- 5432:5432
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: clicked
options: >-
--health-cmd "pg_isready -U postgres"
--health-interval 5s
--health-timeout 3s
--health-retries 10
defaults:
run:
working-directory: apps/backend
env:
DATABASE_URL: postgres://postgres:password@localhost:5432/clicked
REDIS_URL: redis://localhost:6379
OBJECT_STORE_ENDPOINT: http://localhost:9000
OBJECT_STORE_BUCKET: clicked
OBJECT_STORE_ACCESS_KEY: clicked
OBJECT_STORE_SECRET_KEY: clickedsecret
OBJECT_STORE_REGION: us-east-1
OBJECT_STORE_FORCE_PATH_STYLE: 'true'
JWT_SECRET: ci-test-secret
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install pnpm
uses: pnpm/action-setup@v4
- name: Install dependencies
run: pnpm install --frozen-lockfile
working-directory: .
- name: Start MinIO
run: |
docker run -d \
--name clicked-minio-ci \
-p 9000:9000 \
-p 9001:9001 \
-e MINIO_ROOT_USER="$OBJECT_STORE_ACCESS_KEY" \
-e MINIO_ROOT_PASSWORD="$OBJECT_STORE_SECRET_KEY" \
minio/minio:RELEASE.2025-04-22T22-12-26Z \
server /data --console-address ":9001"
- name: Wait for MinIO
run: |
for _ in $(seq 1 30); do
curl -fsS http://localhost:9000/minio/health/ready && exit 0
sleep 2
done
exit 1
- name: Seed MinIO bucket
run: |
node --input-type=module <<'NODE'
import { CreateBucketCommand, S3Client } from '@aws-sdk/client-s3';
const client = new S3Client({
endpoint: process.env.OBJECT_STORE_ENDPOINT,
region: process.env.OBJECT_STORE_REGION,
credentials: {
accessKeyId: process.env.OBJECT_STORE_ACCESS_KEY,
secretAccessKey: process.env.OBJECT_STORE_SECRET_KEY,
},
forcePathStyle: true,
});
try {
await client.send(new CreateBucketCommand({ Bucket: process.env.OBJECT_STORE_BUCKET }));
} catch (error) {
if (
error?.name !== 'BucketAlreadyOwnedByYou' &&
error?.name !== 'BucketAlreadyExists'
) {
throw error;
}
}
NODE
- name: Run migrations
run: pnpm db:migrate
- name: Format check
run: pnpm format:check
- name: Lint
run: pnpm lint
- name: Tests
run: pnpm test