-
Notifications
You must be signed in to change notification settings - Fork 124
152 lines (128 loc) · 3.57 KB
/
backend.yml
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
on:
pull_request:
paths:
- backend/**
name: Backend
jobs:
golangci:
name: golang-lint
runs-on: ubuntu-latest
defaults:
run:
working-directory: backend
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: backend/go.mod
cache-dependency-path: backend/go.sum
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
args: --timeout=5m
working-directory: backend
buf:
name: buf-lint
runs-on: ubuntu-latest
defaults:
run:
working-directory: backend
steps:
- uses: actions/checkout@v4
- name: Retrieve Buf Version
run: |
VER=$(cat BUF_VERSION)
echo "BUF_VERSION=$VER" >> $GITHUB_ENV
- name: Setup Buf
uses: bufbuild/[email protected]
with:
version: ${{ env.BUF_VERSION }}
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Buf Lint
uses: bufbuild/buf-lint-action@v1
with:
input: backend
test:
name: test
runs-on: ubuntu-latest
defaults:
run:
working-directory: backend
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: backend/go.mod
cache-dependency-path: backend/go.sum
- name: Test
run: |
go test -race -coverprofile=coverage.out -covermode=atomic ./...
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
sqlcdiff:
name: sqlc-diff
runs-on: ubuntu-latest
defaults:
run:
working-directory: backend
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Retrieve SQLC Version
run: |
VER=$(cat SQLC_VERSION)
echo "SQLC_VERSION=$VER" >> $GITHUB_ENV
- uses: sqlc-dev/setup-sqlc@v4
with:
sqlc-version: ${{ env.SQLC_VERSION }}
- run: sqlc diff
sqlcvet:
name: sqlc-vet
runs-on: ubuntu-latest
defaults:
run:
working-directory: backend
services:
postgres:
image: "postgres:15"
ports:
- 5432:5432
env:
POSTGRES_DB: nucleus
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Patch sqlc.yaml with db-prepare lint
uses: mikefarah/[email protected]
with:
cmd: sh ./backend/hack/sqlc-prepare-patch.sh postgresql://postgres:postgres@localhost:5432/nucleus ./backend/sqlc.yaml
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: backend/go.mod
cache-dependency-path: backend/go.sum
- name: Install golang-migrate
run: make install-go-tools
- name: Run migrations on database
env:
PG_PASSWORD: postgres
run: ./hack/migrate.sh up
- name: Retrieve SQLC Version
run: |
VER=$(cat SQLC_VERSION)
echo "SQLC_VERSION=$VER" >> $GITHUB_ENV
- uses: sqlc-dev/setup-sqlc@v4
with:
sqlc-version: ${{ env.SQLC_VERSION }}
- run: sqlc vet