-
Notifications
You must be signed in to change notification settings - Fork 99
94 lines (80 loc) · 2.31 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
name: CI
on:
push:
branches:
- main
tags:
- v*
pull_request:
jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
go-version:
- "1.19"
- "1.20"
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
- name: Ensure coverage is reported for every package
run: |
find pkg -type d -print0 | while IFS= read -r -d '' dir; do
go_file=$(ls -1 $dir | grep '\.go$' | grep -v '_test\.go$' | head -n1)
if [[ $go_file ]]; then
package_line=$(grep '^package' ${dir}/${go_file} | head -n1)
echo "${package_line}_test" >$dir/package_coverage_test.go
fi
done
- name: Run unit tests
run: make test
- name: Upload coverage reports to Codecov
if: ${{ github.repository == 'kubewharf/kubeadmiral' && matrix.go-version == '1.19' }}
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.out
flags: unittests
fail_ci_if_error: true
verbose: true
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: "1.19"
# https://github.com/golangci/golangci-lint-action/issues/244
# without `cache: false`, the action might intermittently fail
cache: false
- uses: golangci/golangci-lint-action@v3
with:
version: v1.53.3
only-new-issues: true
args: >
--timeout=8m
--max-issues-per-linter=10
--max-same-issues=10
--uniq-by-line=false
verify-codegen:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: "1.19"
- run: |
make generate -B
git diff --exit-code && exit 0
echo "Codegen is not up to date. Please run 'make generate' and commit the changes." >&2
exit 1
typos:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: crate-ci/typos@master
with:
config: hack/typos.toml