-
Notifications
You must be signed in to change notification settings - Fork 131
190 lines (160 loc) · 5.65 KB
/
main.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
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
name: Main
on:
push:
branches:
- main
- v3
- pmm-*
tags:
- v[0-9]+.[0-9]+.[0-9]+*
pull_request:
jobs:
check:
name: Checks
runs-on: ubuntu-22.04
env:
PMM_ENCRYPTION_KEY_PATH: pmm-encryption.key
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Go release
uses: actions/setup-go@v5
with:
go-version-file: ${{ github.workspace }}/go.mod
cache: false
- name: Enable Go build cache
uses: actions/cache@v4
with:
path: ~/.cache/go-build
key: ${{ runner.os }}-go-build-${{ github.ref }}-${{ hashFiles('**') }}
restore-keys: |
${{ runner.os }}-go-build-${{ github.ref }}-
${{ runner.os }}-go-build-
- name: Enable Go modules cache
uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-modules-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-modules-
- name: Download Go modules
run: |
pushd tools && go mod download -x
popd && go mod download -x
- name: Install development tools
run: make init
- name: Generate files
run: make gen
- name: Check build
run: make release
- name: Check files are formatted and no source code changes
run: |
make format
pushd tools && go mod tidy -v
popd && go mod tidy -v
git status
git diff --exit-code
- name: Update API compatibility descriptors
run: |
# log if descriptors changed, useful for "update descriptors" PRs
make -C api descriptors
git diff --text
- name: Run check-license
run: |
# run license checker on configured files
bin/license-eye -c .licenserc.yaml header check
- name: Run go-sumtype
run: bin/go-sumtype ./...
- name: Run API linter
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.ROBOT_TOKEN || secrets.GITHUB_TOKEN }}
run: |
if out=$(bin/buf lint -v api); code="$?"; test "$code" -eq 0; then
echo "$out"
exit 0
fi
echo "API linter exited with code: $code"
echo "$out"
## buf uses exit code 100 for linter warnings
if [ "$code" -ne 100 ] || ${{ github.event.pull_request == null }}; then
exit $code
fi
# One may need to suppress passing to reviewdog because of https://github.com/reviewdog/reviewdog/issues/1696
echo "$out" | bin/reviewdog -f=buf -reporter=github-pr-review -fail-on-error=true
- name: Run code linters
uses: reviewdog/action-golangci-lint@v2
with:
github_token: ${{ secrets.ROBOT_TOKEN || secrets.GITHUB_TOKEN }}
go_version_file: ${{ github.workspace }}/go.mod
reporter: github-pr-review
fail_on_error: true
cache: false
golangci_lint_flags: "-c=.golangci.yml"
golangci_lint_version: v1.55.2 # Version should match specified in Makefile
- name: Run go-consistent
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.ROBOT_TOKEN || secrets.GITHUB_TOKEN }}
run: |
if out=$(bin/go-consistent -pedantic -exclude "tests" ./...); exit_code=$?; [ $exit_code -eq 0 ]; then
echo "$out"
exit 0
fi
if [ $exit_code -gt 1 ] || ${{ github.event.pull_request == null }}; then
echo "$out"
exit $exit_code
fi
echo "$out" | bin/reviewdog -f=go-consistent -reporter=github-pr-review -fail-on-error=true
- name: Test common API
run: make test-common
- name: Run debug commands on failure
if: ${{ failure() }}
run: |
env | sort
go env | sort
git status
merge-gatekeeper:
needs: [ check ]
name: Merge Gatekeeper
if: ${{ always() }}
runs-on: ubuntu-22.04
steps:
- name: Run Merge Gatekeeper
uses: upsidr/[email protected]
with:
self: Merge Gatekeeper
token: ${{ secrets.GITHUB_TOKEN }}
interval: 45
timeout: 1200
ignored: "license/snyk (Percona Github Org), security/snyk (Percona Github Org)"
ref: ${{ github.event.pull_request.head.sha || github.sha }}
workflow_success:
needs: [ merge-gatekeeper ]
name: Slack Notification success
runs-on: ubuntu-22.04
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_TOKEN_PMM_CI }}
SLACK_CHANNEL: "pmm-ci"
SLACK_USERNAME: "Build bot"
SLACK_ICON_EMOJI: ":octocat:"
SLACK_COLOR: "#00FF00"
SLACK_TITLE: "Finished ${{ github.event.repository.name }} workflow"
SLACK_MESSAGE: "${{ github.event.inputs.repo || github.repository }}:${{ github.event.inputs.branch || github.head_ref }}"
steps:
- name: Slack Notification
uses: rtCamp/[email protected]
workflow_failure:
if: ${{ failure() }}
needs: [ merge-gatekeeper ]
name: Slack Notification failure
runs-on: ubuntu-22.04
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_TOKEN_PMM_CI }}
SLACK_CHANNEL: "pmm-ci"
SLACK_USERNAME: "Build bot"
SLACK_ICON_EMOJI: ":octocat:"
SLACK_COLOR: "#FF0000"
SLACK_TITLE: "Finished ${{ github.event.repository.name }} workflow"
SLACK_MESSAGE: "Workflow failed: ${{ github.event.inputs.repo || github.repository }}:${{ github.event.inputs.branch || github.head_ref }}"
steps:
- name: Slack Notification
uses: rtCamp/[email protected]