-
Notifications
You must be signed in to change notification settings - Fork 0
162 lines (153 loc) · 4.17 KB
/
ci.yml
File metadata and controls
162 lines (153 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
154
155
156
157
158
159
160
161
162
name: CI
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
workflow_dispatch:
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
env:
GO_VERSION: "1.24"
NODE_VERSION: "22"
jobs:
backend-test:
name: Backend Test
runs-on: ubuntu-latest
services:
postgres:
image: postgres:17-alpine
env:
POSTGRES_DB: webencode_test
POSTGRES_USER: test
POSTGRES_PASSWORD: test
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U test -d webencode_test"
--health-interval 10s
--health-timeout 5s
--health-retries 5
nats:
image: nats:2.10-alpine
ports:
- 4222:4222
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: ${{ env.GO_VERSION }}
cache: true
cache-dependency-path: |
go.sum
go.work.sum
- name: Download Go modules
run: go mod download
- name: Run backend tests
run: go test ./... -v -race -coverprofile=coverage.out
env:
DATABASE_URL: postgres://test:test@localhost:5432/webencode_test?sslmode=disable
NATS_URL: nats://localhost:4222
- name: Upload backend coverage artifact
uses: actions/upload-artifact@v6
with:
name: go-coverage
path: coverage.out
retention-days: 7
backend-lint:
name: Backend Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: ${{ env.GO_VERSION }}
cache: true
cache-dependency-path: |
go.sum
go.work.sum
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v9
with:
version: latest
args: --timeout=5m
only-new-issues: true
frontend-quality:
name: Frontend Quality
runs-on: ubuntu-latest
defaults:
run:
working-directory: ui
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up Node
uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install dependencies
run: npm install --legacy-peer-deps
- name: Lint frontend
run: npm run lint
- name: Run frontend tests
run: npm run test:run
- name: Build frontend
run: npm run build
backend-build:
name: Backend Build
runs-on: ubuntu-latest
needs: [backend-test, backend-lint]
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: ${{ env.GO_VERSION }}
cache: true
cache-dependency-path: |
go.sum
go.work.sum
- name: Build all backend binaries
run: make build-all
- name: Upload backend build artifacts
uses: actions/upload-artifact@v6
with:
name: backend-binaries
path: build/
retention-days: 7
docker-build:
name: Docker Build
runs-on: ubuntu-latest
needs: [backend-build, frontend-quality]
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Kernel image
uses: docker/build-push-action@v6
with:
context: .
file: deploy/compose/Dockerfile.kernel
push: false
tags: webencode/kernel:latest
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build Worker image
uses: docker/build-push-action@v6
with:
context: .
file: deploy/compose/Dockerfile.worker
push: false
tags: webencode/worker:latest
cache-from: type=gha
cache-to: type=gha,mode=max