-
-
Notifications
You must be signed in to change notification settings - Fork 345
306 lines (289 loc) · 8.7 KB
/
ci.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
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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
name: CI
on:
push:
branches:
- master
tags:
- "*"
pull_request:
merge_group:
# Cancel in-progress runs in current workflow.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
validate:
name: Run lints and checks
runs-on: ubuntu-latest
steps:
- uses: ory/ci/checkout@master
- uses: actions/setup-go@v3
with:
go-version: "1.23.2"
check-latest: true
- name: Update npm to a non-buggy version
run: sudo npm i -g [email protected]
- name: Lint buf
run: make buf-lint
- run: go list -json > go.list
- name: Run nancy
uses: zepatrik/nancy-github-action@3b0a989791377b50913568102c0ed5539e4eb29c
with:
githubToken: ${{ secrets.GITHUB_TOKEN }}
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3
env:
GOGC: 100
with:
args: --timeout 10m0s --issues-exit-code=0
skip-pkg-cache: true
- name: Test documentation examples
run: make test-docs-samples
- name: Test OPL typelib
run: cd contrib/namespace-type-lib && npm ci && npm test
test:
name: Run tests
runs-on: ubuntu-latest
services:
postgres:
image: postgres:11.8
env:
POSTGRES_DB: keto
POSTGRES_PASSWORD: test
POSTGRES_USER: test
ports:
- 5432:5432
mysql:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: test
ports:
- 3306:3306
env:
TEST_DATABASE_POSTGRESQL: postgres://test:test@localhost:5432/keto?sslmode=disable
TEST_DATABASE_MYSQL: mysql://root:test@(localhost:3306)/mysql?parseTime=true&multiStatements=true
TEST_DATABASE_COCKROACHDB: cockroach://root@localhost:26257/defaultdb?sslmode=disable
steps:
- run: |
docker create --name cockroach -p 26257:26257 \
cockroachdb/cockroach:v20.2.5 start-single-node --insecure
docker start cockroach
name: Start CockroachDB
- uses: ory/ci/checkout@master
- uses: actions/setup-go@v3
with:
go-version: "1.23.2"
check-latest: true
- name: Prepare Dependencies
run: |
make .bin/goveralls .bin/go-acc
- name: Test proto package
run: |
cd proto
go mod tidy
go test ./...
- name: Test Keto
run: |
source scripts/local-dependencies.sh
go-acc --ignore "internal/httpclient" -o coverage.txt ./... -- -tags sqlite
- run: |
source scripts/local-dependencies.sh
goveralls -service=github -coverprofile=coverage.txt
env:
COVERALLS_TOKEN: ${{ github.token }}
test-race:
name: Run race tests
runs-on: ubuntu-latest
steps:
- uses: ory/ci/checkout@master
- uses: actions/setup-go@v3
with:
go-version: "1.23.2"
check-latest: true
- run: |
go test -tags sqlite -race -short ./...
docs-cli:
runs-on: ubuntu-latest
name: Build CLI docs
needs:
- test
- test-race
- validate
steps:
- uses: ory/ci/docs/cli-next@master
with:
token: ${{ secrets.ORY_BOT_PAT }}
output-dir: docs/keto/cli
changelog:
name: Generate changelog
runs-on: ubuntu-latest
if:
${{ startsWith(github.ref, 'refs/tags/v') || github.ref_name == 'master'
}}
needs:
- test
- test-race
- validate
steps:
- uses: ory/ci/checkout@master
with:
fetch-depth: 0
- uses: ory/ci/changelog@master
with:
token: ${{ secrets.ORY_BOT_PAT }}
sdk-generate:
name: Generate SDKs
runs-on: ubuntu-latest
if:
${{ github.ref_type == 'tag' || github.ref_name != 'master' ||
github.event_name == 'pull_request' }}
needs:
- test
- test-race
- validate
steps:
- uses: ory/ci/sdk/generate@master
with:
token: ${{ secrets.ORY_BOT_PAT }}
sdk-release:
name: Release SDKs
runs-on: ubuntu-latest
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
needs:
- test
- test-race
- validate
- sdk-generate
- release
steps:
- uses: ory/ci/sdk/release@master
with:
token: ${{ secrets.ORY_BOT_PAT }}
swag-spec-location: spec/api.json
release:
name: Generate release
runs-on: ubuntu-latest
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
needs:
- test
- test-race
- validate
- changelog
steps:
- uses: ory/ci/releaser@master
with:
token: ${{ secrets.ORY_BOT_PAT }}
goreleaser_key: ${{ secrets.GORELEASER_KEY }}
cosign_pwd: ${{ secrets.COSIGN_PWD }}
docker_username: ${{ secrets.DOCKERHUB_USERNAME }}
docker_password: ${{ secrets.DOCKERHUB_PASSWORD }}
render-version-schema:
name: Render version schema
runs-on: ubuntu-latest
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
needs:
- release
steps:
- uses: ory/ci/releaser/render-version-schema@master
with:
token: ${{ secrets.ORY_BOT_PAT }}
schema-path: .schema/config.schema.json
newsletter-draft:
name: Draft newsletter
runs-on: ubuntu-latest
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
needs:
- release
steps:
- uses: ory/ci/newsletter@master
with:
mailchimp_list_id: f605a41b53
mailchmip_segment_id: 6479489
mailchimp_api_key: ${{ secrets.MAILCHIMP_API_KEY }}
draft: "true"
ssh_key: ${{ secrets.ORY_BOT_SSH_KEY }}
slack-approval-notification:
name: Pending approval Slack notification
runs-on: ubuntu-latest
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
needs:
- newsletter-draft
steps:
- uses: ory/ci/newsletter/slack-notify@master
with:
slack-webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }}
newsletter-send:
name: Send newsletter
runs-on: ubuntu-latest
needs:
- newsletter-draft
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
environment: production
steps:
- uses: ory/ci/newsletter@master
with:
mailchimp_list_id: f605a41b53
mailchmip_segment_id: 6479489
mailchimp_api_key: ${{ secrets.MAILCHIMP_API_KEY }}
draft: "false"
ssh_key: ${{ secrets.ORY_BOT_SSH_KEY }}
buf:
name: Run buf actions
runs-on: ubuntu-latest
steps:
- uses: ory/ci/checkout@master
with:
path: current-repo
- uses: actions/setup-go@v3
with:
go-version: "1.23.2"
check-latest: true
- uses: actions/setup-node@v3
with:
node-version: "15"
- name: Lint and Build
run: |
make buf
working-directory: current-repo
- name: Format Docs (required because buf generates the proto docs)
run: |
make format
working-directory: current-repo
- name: Push build
run: |
git config --local user.email "[email protected]"
git config --local user.name "ory-bot"
git add proto
git commit -a -m "autogen: build buf" && git push "https://${GITHUB_ACTOR}:${{ secrets.ORY_BOT_PAT }}@github.com/${GITHUB_REPOSITORY}.git" HEAD:${GITHUB_REF#"refs/heads/"} || true
working-directory: current-repo
- if: ${{ github.ref_name == 'master' || github.ref_type == 'tag' }}
uses: ory/ci/checkout@master
with:
repository: ory/docs
path: docs
fetch-depth: 0
token: ${{ secrets.ORY_BOT_PAT }}
- if: ${{ github.ref_name == 'master' || github.ref_type == 'tag' }}
name: Push generated files to ory/docs
env:
GITHUB_TOKEN: ${{ secrets.ORY_BOT_PAT }}
run: |
echo "---
title: Protocol buffers API
---
<!-- This file is generated. Please edit the .proto files instead to update the documentation -->" > "docs/docs/keto/reference/proto-api.mdx"
cat "current-repo/proto/buf.md" >> "docs/docs/keto/reference/proto-api.mdx"
cd docs
if git diff --exit-code; then
echo "No changes to commit"
exit 0
fi
git config --local user.email "[email protected]"
git config --local user.name "ory-bot"
git stash
git pull --rebase origin master
git stash apply
git add docs/keto/reference/proto-api.mdx
git commit -m "autogen: update Keto protobuf docs"
git push origin HEAD:master
shell: bash