-
Notifications
You must be signed in to change notification settings - Fork 540
174 lines (153 loc) · 4.68 KB
/
lint-and-tests.yml
File metadata and controls
174 lines (153 loc) · 4.68 KB
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
name: Linter and Unit Tests
on:
workflow_dispatch: # Allows manual trigger
push:
branches: [ "main", "release-*" ]
paths:
- '.github/workflows/**'
- 'pkg/**'
- 'test/**'
- 'cmd/**'
- 'api/**'
- 'go.mod'
- 'go.sum'
- 'Makefile'
- '.golangci.yml'
pull_request:
branches: [ "main" ]
paths:
- '.github/workflows/**'
- 'pkg/**'
- 'test/**'
- 'cmd/**'
- 'api/**'
- 'go.mod'
- 'go.sum'
- 'Makefile'
- '.golangci.yml'
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22'
- name: Lint
run: make lint-all
verify:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22'
- name: Verify Codegen
run: bash ${GITHUB_WORKSPACE}/hack/verify-codegen.sh
- name: Generate CRDs
run: make manifests
- name: Verify CRD Synchronization
run: bash ${GITHUB_WORKSPACE}/hack/verify-crd-sync.sh
test:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
issues: write
id-token: write
pull-requests: write
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22'
- name: Install ZMQ dependencies
run: sudo apt-get update && sudo apt-get install -y libkrb5-dev libzmq3-dev
# github action has errors, requires debugging
# - name: Cache Go modules
# uses: actions/cache@v3
# with:
# path: |
# ~/.cache/go-build
# ~/go/pkg/mod
# key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
# restore-keys: |
# ${{ runner.os }}-go-
- name: Run Unit Tests
run: make test
- name: upload cover profile artifact
uses: actions/upload-artifact@v4
with:
name: cover.out
path: cover.out
if-no-files-found: error
retention-days: 1
- name: Run Race Condition Tests
run: make test-race-condition
- name: Run Integration Tests
run: make test-integration
check-coverage:
runs-on: ubuntu-latest
needs: test
permissions:
packages: write
contents: read
issues: write
id-token: write
pull-requests: write
steps:
- name: checkout
uses: actions/checkout@v4
- name: download cover.out
uses: actions/download-artifact@v4
with:
name: cover.out
- name: download artifact (main.breakdown)
id: download-main-breakdown
uses: dawidd6/action-download-artifact@v9
with:
branch: main
workflow_conclusion: success
name: main.breakdown
if_no_artifact_found: warn
- name: check test coverage
id: coverage
uses: vladopajic/go-test-coverage@v2
continue-on-error: true # Should fail after coverage comment is posted
with:
config: ./.github/.testcoverage.yml
profile: cover.out
# temporary overrides until we reach our goal of 90%
threshold-file: 0
threshold-package: 0
threshold-total: 25
breakdown-file-name: ${{ github.ref_name == 'main' && 'main.breakdown' || '' }}
diff-base-breakdown-file-name: ${{ steps.download-main-breakdown.outputs.found_artifact == 'true' && 'main.breakdown' || '' }}
- name: upload artifact (main.breakdown)
uses: actions/upload-artifact@v4
if: github.ref_name == 'main'
with:
name: main.breakdown
path: main.breakdown # as specified via `breakdown-file-name`
if-no-files-found: error
- name: "finally check coverage"
if: steps.coverage.outcome == 'failure'
shell: bash
run: echo "coverage check failed" && exit 1
# getting error: https://github.com/thollander/actions-comment-pull-request?tab=readme-ov-file#permissions
# requires a change from pull_request to pull_request_target.
# - name: post coverage report
# uses: thollander/actions-comment-pull-request@v3
# with:
# # github-token: ${{ secrets.GITHUB_TOKEN }}
# comment-tag: coverage-report
# message: |
# go-test-coverage report:
# ```
# ${{ fromJSON(steps.coverage.outputs.report) }}```