-
Notifications
You must be signed in to change notification settings - Fork 14
263 lines (229 loc) · 7.5 KB
/
Copy pathmerrymaker-go.yml
File metadata and controls
263 lines (229 loc) · 7.5 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
name: Merrymaker Go CI
on:
push:
paths:
- "services/merrymaker-go/**"
- ".github/workflows/merrymaker-go.yml"
pull_request:
paths:
- "services/merrymaker-go/**"
- ".github/workflows/merrymaker-go.yml"
permissions:
contents: read
concurrency:
group: mmk-go-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
GOFLAGS: -buildvcs=false
jobs:
lint:
name: GolangCI-Lint
runs-on: ubuntu-latest
defaults:
run:
working-directory: services/merrymaker-go
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Setup Go
uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
with:
go-version-file: services/merrymaker-go/go.mod
check-latest: true
cache: true
cache-dependency-path: services/merrymaker-go/go.sum
- name: Setup Bun
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
with:
bun-version: "1.3.13"
- name: Build frontend assets (embed targets)
working-directory: services/merrymaker-go/frontend
run: |
bun install --frozen-lockfile
bun run build
- name: Run golangci-lint
uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0
with:
version: v2.10.1
working-directory: services/merrymaker-go
gosec:
name: GoSec
runs-on: ubuntu-latest
defaults:
run:
working-directory: services/merrymaker-go
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Setup Go
uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
with:
go-version-file: services/merrymaker-go/go.mod
check-latest: true
cache: true
cache-dependency-path: services/merrymaker-go/go.sum
- name: Setup Bun
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
with:
bun-version: "1.3.13"
- name: Build frontend assets (embed targets)
working-directory: services/merrymaker-go/frontend
run: |
bun install --frozen-lockfile
bun run build
- name: Install gosec
# GOTOOLCHAIN=auto allows Go to fetch a newer toolchain if gosec@latest
# requires a Go version newer than the one declared in go.mod.
env:
GOTOOLCHAIN: auto
run: go install github.com/securego/gosec/v2/cmd/gosec@latest
- name: Run gosec
# Pre-existing findings (G101/G124/G202/G706/G710) tracked via Security tab.
# Remove continue-on-error once remediation PRs are merged.
continue-on-error: true
run: gosec ./...
test:
name: Go Tests (integration)
runs-on: ubuntu-latest
defaults:
run:
working-directory: services/merrymaker-go
services:
postgres:
image: postgres:15
env:
POSTGRES_DB: merrymaker
POSTGRES_USER: merrymaker
POSTGRES_PASSWORD: merrymaker
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB"
--health-interval 5s
--health-timeout 5s
--health-retries 10
redis:
image: redis:7-alpine
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 5s
--health-timeout 5s
--health-retries 10
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Setup Go
uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
with:
go-version-file: services/merrymaker-go/go.mod
check-latest: true
cache: true
cache-dependency-path: services/merrymaker-go/go.sum
- name: Setup Bun
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
with:
bun-version: "1.3.13"
- name: Build frontend assets (embed targets)
working-directory: services/merrymaker-go/frontend
run: |
bun install --frozen-lockfile
bun run build
- name: Install DB clients
run: sudo apt-get update && sudo apt-get install -y postgresql-client redis-tools
- name: Wait for Postgres
run: |
for i in {1..30}; do
if pg_isready -h 127.0.0.1 -p 5432 -U merrymaker >/dev/null 2>&1; then
exit 0
fi
sleep 2
done
echo "Postgres did not become ready in time" >&2
exit 1
- name: Wait for Redis
run: |
for i in {1..30}; do
if redis-cli -h 127.0.0.1 -p 6379 ping >/dev/null 2>&1; then
exit 0
fi
sleep 2
done
echo "Redis did not become ready in time" >&2
exit 1
- name: Run Go tests
env:
TEST_DB_HOST: 127.0.0.1
TEST_DB_PORT: "5432"
TEST_DB_USER: merrymaker
TEST_DB_PASSWORD: merrymaker
TEST_DB_NAME: merrymaker
TEST_DB_EPHEMERAL: "1"
DB_SSL_MODE: disable
TEST_REQUIRE_INFRA: "1"
REDIS_ADDR: 127.0.0.1:6379
run: go test ./...
frontend:
name: Frontend Lint & Test
runs-on: ubuntu-latest
defaults:
run:
working-directory: services/merrymaker-go/frontend
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Setup Bun
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
with:
bun-version: "1.3.13"
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Lint frontend
run: bun run lint
- name: Test frontend
run: bun run test
puppeteer-worker:
name: Puppeteer Worker Tests
runs-on: ubuntu-latest
env:
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: "true"
PUPPETEER_EXECUTABLE_PATH: "/usr/bin/google-chrome"
NODE_OPTIONS: "--max-old-space-size=4096"
TMPDIR: /home/runner/work/_temp
services:
redis:
image: redis:7-alpine
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 5s
--health-timeout 5s
--health-retries 10
defaults:
run:
working-directory: services/puppeteer-worker
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Setup Node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: "24"
cache: npm
cache-dependency-path: services/puppeteer-worker/package-lock.json
- name: Install Google Chrome
run: |
sudo apt-get update
sudo apt-get install -y wget fonts-liberation
wget -q https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo apt-get install -y ./google-chrome-stable_current_amd64.deb
rm -f google-chrome-stable_current_amd64.deb
google-chrome --version
- name: Install dependencies
run: npm ci
- name: Lint (Biome)
run: npm run lint
- name: Test
run: npm test