-
Notifications
You must be signed in to change notification settings - Fork 874
195 lines (185 loc) · 5.84 KB
/
testing.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
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
191
192
193
194
195
name: Testing
on:
push:
branches:
- 'master'
- 'release-*'
pull_request:
branches:
- 'master'
- 'release-*'
workflow_dispatch:
inputs:
debug_enabled:
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
required: false
default: false
env:
# Golang version to use across CI steps
GOLANG_VERSION: '1.22'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
event_file:
name: 'Event File'
runs-on: ubuntu-latest
steps:
- name: Upload
uses: actions/upload-artifact@v4
with:
name: Event File
path: ${{ github.event_path }}
test-unit:
name: Run unit tests
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v5.1.0
with:
go-version: ${{ env.GOLANG_VERSION }}
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v4
- name: Restore go build cache
uses: actions/cache@v4
with:
path: ~/.cache/go-build
key: ${{ runner.os }}-go-build-v1-${{ github.run_id }}
- name: Download all Go modules
run: |
go mod download
- name: Test
run: make test-unit
- name: Upload Unit Test Results
if: always()
uses: actions/upload-artifact@v4
with:
name: Unit Test Results
path: |
junit-unit-test.xml
- name: Generate code coverage artifacts
uses: actions/upload-artifact@v4
with:
name: coverage-output-unit
path: coverage-output-unit
test-e2e:
strategy:
fail-fast: false
matrix:
kubernetes:
- version: 1.26
latest: false
- version: 1.27
latest: false
- version: 1.28
latest: false
- version: 1.29
latest: true
name: Run end-to-end tests
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v5.1.0
with:
go-version: '1.22'
- uses: actions/checkout@v4
- name: Setup k3s
env:
INSTALL_K3S_CHANNEL: v${{ matrix.kubernetes.version }}
run: |
curl -sfL https://get.k3s.io | sh -
sudo mkdir ~/.kube
sudo cp /etc/rancher/k3s/k3s.yaml ~/.kube/config
sudo chmod 755 ~/.kube/config
kubectl version
kubectl create ns argo-rollouts
- uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Download cache
run: go mod download
- name: Install CRDs
run: |
kubectl apply -k manifests/crds
kubectl apply -f test/e2e/crds
- name: Start controller
run: make start-e2e 2>&1 | sed -r "s/[[:cntrl:]]\[[0-9]{1,3}m//g" > /tmp/e2e-controller.log &
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled == 'true'}}
- name: Run e2e tests
run: |
make test-e2e
if: ${{ !(github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled == 'true') }}
- name: Stop e2e tests controller
run: |
pgrep -f go-build -a
pkill -f go-build
sleep 5
echo "done stopping process"
ls -lah coverage-output-e2e/
if: ${{ !(github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled == 'true' && matrix.kubernetes.latest)}}
- name: Output Rerun Overview
run: |
[[ -f rerunreport.txt ]] && cat rerunreport.txt || echo "No rerun report found"
- name: Upload E2E Test Results
if: always()
uses: actions/upload-artifact@v4
with:
name: E2E Test Results (k8s ${{ matrix.kubernetes.version }})
path: |
junit-e2e-test.xml
- name: Upload e2e-controller logs
uses: actions/upload-artifact@v4
with:
name: e2e-controller-k8s-${{ matrix.kubernetes.version }}.log
path: /tmp/e2e-controller.log
if: ${{ always() }}
- name: Upload code coverage artifacts
uses: actions/upload-artifact@v4
with:
name: coverage-output-e2e
path: coverage-output-e2e
if: ${{ matrix.kubernetes.latest }}
coverage-process:
name: Process Coverage Files
runs-on: ubuntu-latest
needs:
- test-unit
- test-e2e
steps:
- name: Set up Go
uses: actions/setup-go@v5.1.0
with:
go-version: ${{ env.GOLANG_VERSION }}
id: go
- uses: actions/checkout@v4
- name: Get e2e code coverage
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: coverage-output-e2e
path: coverage-output-e2e
- name: Get unit test code coverage
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: coverage-output-unit
path: coverage-output-unit
- name: combine-go-coverage
run: |
go tool covdata textfmt -i=coverage-output-unit/,coverage-output-e2e/ -o full-coverage.out
- name: Upload code coverage information to codecov.io
uses: codecov/codecov-action@05f5a9cfad807516dbbef9929c4a42df3eb78766 # v5.0.3
with:
file: full-coverage.out
fail_ci_if_error: false
codecov_yml_path: .codecov.yml
disable_search: true
verbose: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}