-
Notifications
You must be signed in to change notification settings - Fork 1
64 lines (53 loc) · 1.66 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
name: ci
on:
push:
branches: ["main"]
pull_request:
branches: ["**"]
types:
- opened
- reopened
- synchronize
- ready_for_review
permissions:
contents: "read"
jobs:
check-code-regeneration:
runs-on: ubuntu-latest
if: ${{ !github.event.pull_request.draft }}
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: Set up go
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version: 1.21
- name: Install gen dependencies
run: |
go install github.com/mailru/easyjson/...@latest
go install github.com/hashicorp/copywrite@latest
- name: Ensure the code has been properly regenerated with 'go generate ./...'
run: |
go generate ./...
readonly changed_files="$(git diff --stat)"
if [[ "${changed_files}" != "" ]]; then
readonly changes="$(git diff)"
echo "Found differences after running 'go generate ./...'"
echo "Please run 'go generate ./...' & commit the changed files:"
echo "${changed_files}"
echo "Here are the differences:"
echo "${changes}"
exit 1
fi
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: Set up go
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version: 1.21
- name: Build
run: go build -v ./...
- name: Test
run: go test -v ./...
# TODO @dvcorreia: add linting workflow