-
Notifications
You must be signed in to change notification settings - Fork 13
115 lines (97 loc) · 2.96 KB
/
ci.yaml
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
name: CI
on:
workflow_dispatch:
pull_request:
push:
branches:
- downstream
- main
jobs:
validate-pr:
name: Validate PR
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
- name: Verify generated Manifests are up to date
run: make verify-manifests
unit-tests:
name: Unit Tests
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Display build environment
run: printenv
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Install kubebuilder
run : |
os=$(go env GOOS)
arch=$(go env GOARCH)
curl -L "https://github.com/kubernetes-sigs/kubebuilder/releases/download/v2.3.1/kubebuilder_2.3.1_${os}_${arch}.tar.gz" | tar -xz -C /tmp/
sudo mv /tmp/kubebuilder_2.3.1_${os}_${arch} /usr/local/kubebuilder
export PATH=$PATH:/usr/local/kubebuilder/bin
- name: Run tests
run: |
make generate manifests
go test ./... -v -coverprofile cover.out -covermode=atomic
- name: Upload test coverage file
uses: actions/upload-artifact@v4
with:
name: coverage
path: cover.out
coverage:
name: Coverage
needs: unit-tests
runs-on: ubuntu-22.04
steps:
- name: Checkout
# this checkout is required for the coverage report. If we don't do this, then
# the uploaded report is invalid and codecov doesn't know how to process it.
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download coverage result from unit-tests
uses: actions/download-artifact@v4
with:
name: coverage
- name: Upload coverage
uses: codecov/codecov-action@v3
with:
file: ./cover.out
flags: unittests
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
sonarcloud:
name: SonarCloud
needs: [validate-pr,unit-tests]
runs-on: ubuntu-20.04
steps:
- name: Checkout
# this checkout is required for the coverage report. If we don't do this, then
# the uploaded report is invalid and codecov doesn't know how to process it.
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download coverage result from unit-tests
uses: actions/download-artifact@v4
with:
name: coverage
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}