-
Notifications
You must be signed in to change notification settings - Fork 4
155 lines (128 loc) · 4.85 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
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
---
# DO NOT EDIT this file in a service repository.
# It should be changed in the `template` repository, and then copied to there as-is.
# All differences should be encapsulated in Makefile targets.
name: CI
on:
push:
branches:
- main
tags:
- v[0-9]+.[0-9]+.[0-9]+*
pull_request:
permissions:
contents: read
packages: write
checks: write
pull-requests: write
jobs:
test:
name: Test
timeout-minutes: 10
continue-on-error: false
runs-on: ubuntu-latest
env:
# no `-mod=readonly` to test PRs made by @dependabot;
# `git diff --exit-code` step below still checks what we need
GOPRIVATE: github.com/percona,github.com/percona-platform
GONOSUMDB: github.com/percona,github.com/percona-platform
steps:
- name: Configure git for private modules
run: echo 'machine github.com login percona-robot password ${{ secrets.ROBOT_TOKEN }}' > $HOME/.netrc
- name: Check out code into the Go module directory
uses: actions/checkout@v4
with:
lfs: true
- name: Set up Go release
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache-dependency-path: "**/go.sum"
- name: Download Go modules
run: |
pushd tools && go mod download -x
popd && go mod download -x
- name: Install development tools
run: make init
- name: Build binaries
run: make build
- name: Run tests
run: |
go clean -testcache
make test
- name: Check that there are no source code changes
run: |
# Break job if any files were changed during its run (code generation, etc), except go.sum.
# `go mod tidy` could remove old checksums from that file, and that's okay on CI,
# and actually expected for PRs made by @dependabot.
# Checksums of actually used modules are checked by previous `go` subcommands.
pushd tools && go mod tidy -v && git checkout go.sum
popd && go mod tidy -v && git checkout go.sum
git diff --exit-code
- name: Run debug commands on failure
if: ${{ failure() }}
run: |
env
go version
go env
pwd
git status
check:
name: Check
timeout-minutes: 10
if: github.event_name == 'pull_request'
continue-on-error: false
runs-on: ubuntu-latest
env:
# no `-mod=readonly` to test PRs made by @dependabot;
# `git diff --exit-code` step below still checks what we need
GOPRIVATE: github.com/percona,github.com/percona-platform
GONOSUMDB: github.com/percona,github.com/percona-platform
steps:
- name: Configure git for private modules
run: echo 'machine github.com login percona-robot password ${{ secrets.ROBOT_TOKEN }}' > $HOME/.netrc
- name: Check out code into the Go module directory
uses: actions/checkout@v4
with:
lfs: true
- name: Set up Go release
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache-dependency-path: "**/go.sum"
- name: Download Go modules
run: |
pushd tools && go mod download -x
popd && go mod download -x
- name: Install tools
run: make init
- name: Build binaries
run: make build
- name: Format sources
run: make format
- name: Run checks/linters
run: |
# use GITHUB_TOKEN because only it has access to GitHub Checks API
bin/golangci-lint run --out-format=line-number | env REVIEWDOG_GITHUB_API_TOKEN=${{ secrets.GITHUB_TOKEN }} bin/reviewdog -f=golangci-lint -reporter=github-pr-review -filter-mode=nofilter -fail-on-error=true
# run it like that until some of those issues/PRs are resolved:
# * https://github.com/quasilyte/go-consistent/issues/33
# * https://github.com/golangci/golangci-lint/issues/288
# * https://github.com/reviewdog/errorformat/pull/47 (once it is actually used by reviewdog)
bin/go-consistent -exclude=tools -pedantic ./...
- name: Check that there are no source code changes
run: |
# Break job if any files were changed during its run (tools installation, etc), except go.sum.
# `go mod tidy` could remove old checksums from that file, and that's okay on CI,
# and actually expected for PRs made by @dependabot.
# Checksums of actually used modules are checked by previous `go` subcommands.
pushd tools && go mod tidy -v && git checkout go.sum
popd && go mod tidy -v && git checkout go.sum
git diff --exit-code
- name: Run debug commands on failure
if: ${{ failure() }}
run: |
env
go version
go env
pwd
git status