-
Notifications
You must be signed in to change notification settings - Fork 137
268 lines (252 loc) · 9 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
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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
name: CI
on:
push:
branches:
- main
- release-*
pull_request:
branches:
- "*"
permissions:
contents: read
env:
DOCKER_REGISTRY: "quay.io"
DOCKER_REPOSITORY: "dynatrace/dynatrace-operator"
jobs:
helm-test:
name: Run helm unit tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up Helm
uses: azure/setup-helm@fe7b79cd5ee1e45176fcad797de68ecaf3ca4814 # v4.2.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Run Unit tests
id: helm-unittest
run: |
make test/helm/unit
helm-lint:
name: Run helm linting
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up Helm
uses: azure/setup-helm@fe7b79cd5ee1e45176fcad797de68ecaf3ca4814 # v4.2.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Run Linting
id: helm-linting
run: |
make test/helm/lint
tests:
name: Run unit tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup Golang
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
with:
go-version-file: "${{ github.workspace }}/go.mod"
- name: Download dependencies
id: depdownload
run: |
hack/build/ci/install-cgo-dependencies.sh
- name: Run unit tests and integration tests
id: unittest
run: |
make go/test
make go/integration_test
- name: Check test coverage
id: check-code-coverage
run: |
make go/check-coverage
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@015f24e6818733317a2da2edd6290ab26238649a # v5.0.7
with:
fail_ci_if_error: true
verbose: true
files: ./coverage.txt
flags: unittests # optional
name: codecov-umbrella # optional
token: ${{ secrets.CODECOV_TOKEN }}
linting:
name: Run linting
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
with:
go-version-file: "${{ github.workspace }}/go.mod"
- name: Download dependencies
id: depdownload
run: |
hack/build/ci/install-cgo-dependencies.sh
- name: Run golangci-lint
uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 # v6.1.1
with:
# renovate depName=github.com/golangci/golangci-lint
version: v1.62.2
args: --build-tags e2e --timeout 300s --out-${NO_FUTURE}format colored-line-number
- name: Run deadcode
id: deadcode
run: |
make go/deadcode
generated-files:
name: Check generated files
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
with:
go-version-file: "${{ github.workspace }}/go.mod"
- name: Check deepcopy files
id: deepcopy
run: |
make manifests/deepcopy
git diff --exit-code
security:
name: Code security scanning alerts
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Run Snyk to check for vulnerabilities
uses: snyk/actions/golang@b98d498629f1c368650224d6d212bf7dfa89e4bf # v0.4.0
env:
SNYK_TOKEN: ${{ secrets.SNYK_API_TOKEN }}
with:
args: --severity-threshold=high
markdown-lint:
name: Lint markdown files
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Lint markdown files
uses: articulate/actions-markdownlint@87f495d21507d6844dc917a01e742eaaa45049c0 # v1.1.0
with:
config: .markdownlint.json
# renovate depName=github.com/igorshubovych/markdownlint-cli
version: v0.43.0
check-uncommitted-doc-changes:
name: Check uncommitted changes in api docs action
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
with:
go-version-file: "${{ github.workspace }}/go.mod"
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
- name: Run make doc to see uncommitted changes
run: make doc
- name: Check for uncommitted changes
id: check-changes
uses: mskri/check-uncommitted-changes-action@2b152539dd033c3a26e0dd1d8b9a0c8e4d3a8a19 # v1.0.1
- name: Evaluate if there are changes
if: steps.check-changes.outputs.outcome == failure()
run: echo "There are uncommitted changes"
prepare:
name: Prepare properties
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Prepare build parameters
id: prep
run: |
hack/build/ci/prepare-build-variables.sh
- name: Docker metadata
uses: docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96 # v5.6.1
id: meta
with:
images: dynatrace/dynatrace-operator
tags: ${{ steps.prep.outputs.docker_image_tag }}
labels: |
${{ steps.prep.outputs.docker_image_labels }}
vcs-ref=${{ github.sha }}
- name: Prepare build parameters
id: prepenv
run: |
# Set output parameters.
# Reason: global envs do not work in workflow calls
# More info: https://github.com/actions/runner/issues/480#issuecomment-1021278915
echo "registry=${{ env.DOCKER_REGISTRY }}" >> "$GITHUB_OUTPUT"
echo "repository=${{ env.DOCKER_REPOSITORY }}" >> "$GITHUB_OUTPUT"
outputs:
labels: ${{ steps.meta.outputs.labels }}
version: ${{ steps.prep.outputs.docker_image_tag }}
registry: ${{ steps.prepenv.outputs.registry }}
repository: ${{ steps.prepenv.outputs.repository }}
build:
name: Build images
runs-on: ubuntu-latest
needs: [prepare, tests, linting, generated-files]
strategy:
matrix:
platform: [amd64, arm64, ppc64le, s390x]
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Build image
if: matrix.platform == 'amd64' || github.ref_protected
uses: ./.github/actions/build-image
with:
platform: ${{ matrix.platform }}
labels: ${{ needs.prepare.outputs.labels }}
image-tag: ${{ needs.prepare.outputs.version }}
push:
name: Push images
runs-on: ubuntu-latest
needs: [prepare, build]
strategy:
matrix:
platform: [amd64, arm64, ppc64le, s390x]
if: ${{ !github.event.pull_request.head.repo.fork }}
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Login to Registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: Upload Image
if: matrix.platform == 'amd64' || github.ref_protected
uses: ./.github/actions/upload-image
with:
platform: ${{ matrix.platform }}
labels: ${{ needs.prepare.outputs.labels }}
version: ${{ needs.prepare.outputs.version }}
registry: ${{ needs.prepare.outputs.registry }}
repository: ${{ needs.prepare.outputs.repository }}
manifest:
name: Create manifest
needs: [prepare, push]
runs-on: ubuntu-latest
env:
COMBINED: ${{ github.ref_protected }}
if: ${{ !github.event.pull_request.head.repo.fork }}
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Login to Registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: Create Manifests
uses: ./.github/actions/create-manifests
with:
version: ${{ needs.prepare.outputs.version }}
registry: ${{ needs.prepare.outputs.registry }}
repository: ${{ needs.prepare.outputs.repository }}
combined: ${{ env.COMBINED }}