-
Notifications
You must be signed in to change notification settings - Fork 22
71 lines (66 loc) · 1.62 KB
/
ci.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
name: CI
on:
pull_request:
branches: [main]
push:
branches: [main]
workflow_run:
workflows: [image]
types: [completed]
permissions:
contents: read
pull-requests: read
jobs:
check-changes:
runs-on: ubuntu-latest
outputs:
go: ${{ steps.filter.outputs.go }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
go:
- '**/*.go'
- go.mod
- go.sum
test:
needs: check-changes
if: ${{ needs.check-changes.outputs.go == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: magnetikonline/action-golang-cache@v5
with:
go-version-file: go.mod
- name: make test
run: |
# some tests are flaky because it's running against a dockerized obs
# instance, so just retry a few times or whatever to be certain
for _ in $(seq 1 5); do
if make test; then exit; fi
done
exit 1
- run: go tool cover -func coverall.out
generate:
needs: check-changes
if: ${{ needs.check-changes.outputs.go == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: magnetikonline/action-golang-cache@v5
with:
go-version-file: go.mod
- run: make clean && make generate
- name: Ensure generated code is already checked in
if: success()
run: |
files="$(git diff --name-only)"
if [ -z "$files" ]; then exit 0; fi
echo "Files with diffs:"
echo "$files"
echo
echo
git diff
exit 1