-
Notifications
You must be signed in to change notification settings - Fork 279
222 lines (217 loc) · 7.13 KB
/
build-test.yaml
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
---
name: "Build & Test"
on: # yamllint disable-line rule:truthy
push:
branches:
- "main"
pull_request:
branches:
- "*"
merge_group:
types:
- "checks_requested"
env:
DOCKERHUB_PUBLIC_ACCESS_TOKEN: "dckr_pat_8AEETZWxu8f7FvJUk9NrpyX_ZEQ"
DOCKERHUB_PUBLIC_USER: "spicedbgithubactions"
jobs:
paths-filter:
runs-on: "buildjet-2vcpu-ubuntu-2204"
outputs:
codechange: "${{ steps.code-filter.outputs.codechange }}"
protochange: "${{ steps.proto-filter.outputs.protochange }}"
steps:
- uses: "actions/checkout@v2"
- uses: "dorny/paths-filter@v2"
id: "code-filter"
with:
filters: |
codechange:
- ".github/workflows/build-test.yaml"
- "Dockerfile"
- "go.mod"
- "go.sum"
- "cmd/**"
- "pkg/**"
- "e2e/**"
- "internal/**"
- uses: "dorny/paths-filter@v2"
id: "proto-filter"
with:
filters: |
protochange:
- "buf.gen.yaml"
- "buf.work.yaml"
- "proto/**"
- "go.mod"
build:
name: "Build Binary & Image"
runs-on: "buildjet-4vcpu-ubuntu-2204"
needs: "paths-filter"
if: |
needs.paths-filter.outputs.codechange == 'true'
steps:
- uses: "actions/checkout@v3"
- uses: "authzed/actions/setup-go@main"
- uses: "docker/login-action@v3"
with:
username: "${{ env.DOCKERHUB_PUBLIC_USER }}"
password: "${{ env.DOCKERHUB_PUBLIC_ACCESS_TOKEN }}"
- uses: "authzed/actions/go-build@main"
- name: "Image tests"
run: "go run mage.go test:image"
unit:
name: "Unit"
runs-on: "buildjet-4vcpu-ubuntu-2204"
needs: "paths-filter"
if: |
needs.paths-filter.outputs.codechange == 'true'
steps:
- uses: "actions/checkout@v3"
- uses: "authzed/actions/setup-go@main"
- name: "Unit tests"
run: "go run mage.go test:unit"
integration:
name: "Integration Tests"
runs-on: "buildjet-4vcpu-ubuntu-2204"
needs: "paths-filter"
if: |
needs.paths-filter.outputs.codechange == 'true'
steps:
- uses: "actions/checkout@v3"
- uses: "authzed/actions/setup-go@main"
- uses: "docker/login-action@v3"
with:
username: "${{ env.DOCKERHUB_PUBLIC_USER }}"
password: "${{ env.DOCKERHUB_PUBLIC_ACCESS_TOKEN }}"
- name: "Integration tests"
run: "go run mage.go test:integration"
datastore:
name: "Datastore Tests"
runs-on: "buildjet-4vcpu-ubuntu-2204"
needs: "paths-filter"
strategy:
fail-fast: false
matrix:
datastore: ["crdb", "mysql", "postgres", "spanner", "pgbouncer"]
steps:
- uses: "actions/checkout@v3"
if: |
needs.paths-filter.outputs.codechange == 'true'
- uses: "authzed/actions/setup-go@main"
if: |
needs.paths-filter.outputs.codechange == 'true'
- uses: "docker/login-action@v3"
if: |
needs.paths-filter.outputs.codechange == 'true'
with:
username: "${{ env.DOCKERHUB_PUBLIC_USER }}"
password: "${{ env.DOCKERHUB_PUBLIC_ACCESS_TOKEN }}"
- name: "Integration tests"
if: |
needs.paths-filter.outputs.codechange == 'true'
run: "go run mage.go testds:${{ matrix.datastore }}"
- name: "Integration tests"
if: |
needs.paths-filter.outputs.codechange == 'true'
run: "go run mage.go testcons:${{ matrix.datastore }}"
e2e:
name: "E2E"
runs-on: "buildjet-8vcpu-ubuntu-2204"
needs: "paths-filter"
if: |
needs.paths-filter.outputs.codechange == 'true'
steps:
- uses: "actions/checkout@v3"
- uses: "authzed/actions/setup-go@main"
with:
go-version-file: "e2e/go.mod"
cache-dependency-path: "e2e/go.sum"
- name: "Cache Binaries"
id: "cache-binaries"
uses: "buildjet/cache@v3"
with:
path: |
e2e/newenemy/cockroach
e2e/newenemy/chaosd
e2e/newenemy/watchmaker
# this key will need to be bumped when dependencies are changed
key: "cockroach-v22.1.5-chaosd-v1.1.1"
- name: "Install cockroachdb and chaosd"
if: "steps.cache-binaries.outputs.cache-hit != 'true'"
working-directory: "e2e/newenemy"
run: |
curl https://binaries.cockroachdb.com/cockroach-v22.1.5.linux-amd64.tgz | tar -xz && mv cockroach-v22.1.5.linux-amd64/cockroach ./cockroach
curl -fsSL https://mirrors.chaos-mesh.org/chaosd-v1.1.1-linux-amd64.tar.gz | tar -xz && mv chaosd-v1.1.1-linux-amd64/chaosd ./chaosd
- uses: "buildjet/cache@v3"
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: "${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}"
restore-keys: |
${{ runner.os }}-go-
- name: "Build SpiceDB"
run: |
go get -d ./...
go build -o ./e2e/newenemy/spicedb ./cmd/spicedb/...
- name: "Run e2e"
working-directory: "e2e/newenemy"
run: |
go test -v -timeout 11m ./...
- uses: "actions/upload-artifact@v2"
if: "always()"
# this upload step is really flaky, don't fail the job if it fails
continue-on-error: true
with:
name: "node-logs"
path: "e2e/newenemy/*.log"
analyzers-unit-tests:
name: "Analyzers Unit Tests"
runs-on: "buildjet-2vcpu-ubuntu-2204"
needs: "paths-filter"
if: |
needs.paths-filter.outputs.codechange == 'true'
steps:
- uses: "actions/checkout@v3"
- uses: "authzed/actions/setup-go@main"
with:
go-version-file: "tools/analyzers/go.mod"
cache-dependency-path: "tools/analyzers/go.sum"
- name: "Analyzer tests"
run: "go run mage.go test:analyzers"
development:
name: "WASM Tests"
runs-on: "buildjet-2vcpu-ubuntu-2204"
needs: "paths-filter"
if: |
needs.paths-filter.outputs.codechange == 'true'
steps:
- uses: "actions/checkout@v3"
- uses: "authzed/actions/setup-go@main"
- name: "WASM tests"
run: "go run mage.go test:wasm"
protobuf:
name: "Generate Protobufs"
runs-on: "buildjet-2vcpu-ubuntu-2204"
needs: "paths-filter"
if: |
needs.paths-filter.outputs.protochange == 'true'
steps:
- uses: "actions/checkout@v3"
- uses: "authzed/actions/setup-go@main"
- name: "Generate Protos"
run: "go run mage.go gen:proto"
- uses: "chainguard-dev/actions/nodiff@main"
with:
path: ""
fixup-command: "go run mage.go gen:proto"
- uses: "bufbuild/buf-setup-action@v1"
- uses: "bufbuild/[email protected]"
if: "github.event_name == 'pull_request'"
env:
BUF_INPUT_HTTPS_USERNAME: "${{ github.actor }}"
BUF_INPUT_HTTPS_PASSWORD: "${{ github.token }}"
with:
input: "proto/internal"
against: "https://github.com/authzed/spicedb.git#branch=main,subdir=proto/internal"
buf_token: "${{ secrets.BUF_REGISTRY_TOKEN }}"