forked from nginx/agent
-
Notifications
You must be signed in to change notification settings - Fork 0
253 lines (241 loc) · 7.53 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
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
name: CI
on:
push:
branches:
- 'main'
- 'release-*'
paths-ignore:
- "**.md"
- "docs/**"
- "hugo/**"
pull_request:
types:
- opened
- reopened
- synchronize
env:
GOLANGCI_LINT_VERSION: 'v1.50.1'
NFPM_VERSION: 'v2.18.1'
jobs:
lint:
name: Lint
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version-file: 'go.mod'
- name: Lint Agent Code
uses: golangci/golangci-lint-action@v3
with:
version: "${{ env.GOLANGCI_LINT_VERSION }}"
args: -c ./scripts/.golangci.yml
skip-pkg-cache: true
- name: Lint SDK Code
uses: golangci/golangci-lint-action@v3
with:
version: "${{ env.GOLANGCI_LINT_VERSION }}"
working-directory: sdk
args: -c ../scripts/.golangci.yml
skip-pkg-cache: true
unit-test:
name: Unit Tests
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version-file: 'go.mod'
- name: Run Unit Tests
run: make unit-test
- name: Upload Test Coverage
uses: codecov/codecov-action@v3
with:
files: ./build/test/coverage.out
component-test:
name: Component Tests
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version-file: 'go.mod'
- name: Run Component Tests
run: make component-test
integration-tests:
runs-on: ubuntu-22.04
name: Integration Tests
strategy:
matrix:
container:
- image: "rockylinux"
version: "8"
- image: "rockylinux"
version: "9"
- image: "almalinux"
version: "8"
- image: "almalinux"
version: "9"
- image: "amazonlinux"
version: "2"
- image: "oraclelinux"
version: "7"
- image: "oraclelinux"
version: "8"
- image: "oraclelinux"
version: "9"
- image: "ubuntu"
version: "22.04"
- image: "alpine"
version: "3.14"
- image: "alpine"
version: "3.15"
- image: "alpine"
version: "3.16"
- image: "alpine"
version: "3.17"
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version-file: 'go.mod'
- name: Run Integration Tests
run: |
go install github.com/goreleaser/nfpm/v2/cmd/nfpm@${{ env.NFPM_VERSION }}
OS_RELEASE="${{ matrix.container.image }}" OS_VERSION="${{ matrix.container.version }}" \
make integration-test
performance-test:
name: Performance Tests
if: "!github.event.pull_request.head.repo.fork"
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Set up Docker Build
uses: docker/setup-buildx-action@v2
- name: Build Docker Image
uses: docker/build-push-action@v3
with:
file: test/docker/Dockerfile
tags: nginx-agent-benchmark:1.0.0
context: '.'
push: false
load: true
no-cache: true
secrets: |
"nginx-crt=${{ secrets.NGINX_CRT }}"
"nginx-key=${{ secrets.NGINX_KEY }}"
- name: Run Performance Tests
run: docker run -v ${GITHUB_WORKSPACE}:/home/nginx/ --rm nginx-agent-benchmark:1.0.0
build-signed-snapshot:
name: Build signed snapshot
runs-on: ubuntu-22.04
if: ${{ !startsWith(github.ref_name, 'release-') && !github.event.pull_request.head.repo.fork }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-go@v3
with:
go-version-file: 'go.mod'
- name: Setup build environment
run: |
sudo apt-get update
sudo apt-get install -y gpgv1 monkeysphere
go install github.com/goreleaser/nfpm/v2/cmd/nfpm@${{ env.NFPM_VERSION }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build Docker Image
uses: docker/build-push-action@v3
with:
file: scripts/packages/packager/Dockerfile
tags: build-signed-packager:1.0.0
context: '.'
push: false
load: true
no-cache: true
build-args: |
package_type=signed-package
- name: Build Packages
env:
INDIGO_GPG_AGENT: ${{ secrets.INDIGO_GPG_AGENT }}
NFPM_SIGNING_KEY_FILE: .key.asc
run: |
echo "$INDIGO_GPG_AGENT" | base64 --decode > .key.asc
make clean package
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: nginx-agent-snapshots
path: ./build/packages/nginx-agent.tar.gz
retention-days: 3
- name: Azure Login
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Azure Upload Snapshot
uses: azure/CLI@v1
with:
inlineScript: |
az storage blob upload --auth-mode=login -f ./build/packages/nginx-agent.tar.gz -c ${{ secrets.AZURE_CONTAINER_NAME }} \
--account-name ${{ secrets.AZURE_ACCOUNT_NAME }} --overwrite -n nginx-agent/${GITHUB_REF##*/}/nginx-agent.tar.gz
- name: Azure Logout
run: |
az logout
if: always()
build-unsigned-snapshot:
name: Build unsigned snapshot
runs-on: ubuntu-22.04
if: ${{ !startsWith(github.ref_name, 'release-') && github.event.pull_request.head.repo.fork }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-go@v3
with:
go-version-file: 'go.mod'
- name: Setup build environment
run: |
go install github.com/goreleaser/nfpm/v2/cmd/nfpm@${{ env.NFPM_VERSION }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build Docker Image
uses: docker/build-push-action@v3
with:
file: scripts/packages/packager/Dockerfile
tags: build-local-packager:1.0.0
context: '.'
push: false
load: true
no-cache: true
build-args: |
package_type=local-package
- name: Build Packages
run: |
make clean local-deb-package local-rpm-package local-txz-package local-apk-package
tar -cf ./build/nginx-agent-snapshots.tar.gz ./build/*.deb ./build/*.rpm ./build/*.pkg ./build/*.apk
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: nginx-agent-snapshots
path: ./build/nginx-agent-snapshots.tar.gz
retention-days: 3
build-example:
name: Build Grafana Dashboard Example
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version-file: 'go.mod'
- name: Setup build environment
run: |
go install github.com/goreleaser/nfpm/v2/cmd/nfpm@${{ env.NFPM_VERSION }}
- name: Build Grafana example
run: make build-grafana-example
- name: Clean Grafana example
run: make clean-grafana-example
trigger-release-workflow:
if: ${{ startsWith(github.ref_name, 'release-') && !github.event.pull_request.head.repo.fork }}
needs: [ lint, unit-test, component-test, performance-test, integration-tests ]
uses: ./.github/workflows/release-branch.yml
secrets: inherit