forked from project-koku/koku-metrics-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
163 lines (145 loc) · 4.8 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
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
name: CI
on:
workflow_dispatch:
pull_request:
push:
branches:
- ptest
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 Dependencies
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
unit-test-ppc64le:
name: Unit Test ppc64le
runs-on: ubuntu-22.04
strategy:
matrix:
platform: [ppc64le]
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Display build environment
run: printenv
- name: Install required packages
run : |
os=linux
arch=${{ matrix.platform }}
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
curl -L "https://github.com/etcd-io/etcd/releases/download/v3.5.11/etcd-v3.5.11-${os}-${arch}.tar.gz" | tar -xz -C /tmp/
sudo mv /tmp/etcd-v3.5.11-${os}-${arch}/etcd /usr/local/kubebuilder/bin
curl -L "https://storage.googleapis.com/kubernetes-release/release/v1.24.13/kubernetes-server-${os}-${arch}.tar.gz" | tar -xz -C /tmp/
sudo mv /tmp/kubernetes/server/bin/kube-apiserver /usr/local/kubebuilder/bin
sudo mv /tmp/kubernetes/server/bin/kubectl /usr/local/kubebuilder/bin
- name: Run tests on ${{ matrix.platform }}
run: >-
docker run
--rm
--platform linux/${{ matrix.platform }}
--mount "type=bind,src=$(pwd),dst=/build"
--mount "type=bind,src=/usr/local/kubebuilder,dst=/usr/local/kubebuilder"
-w /build
ubuntu:latest '
apt install make; \
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 }}