-
Notifications
You must be signed in to change notification settings - Fork 11
263 lines (251 loc) · 8.64 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
name: CI
concurrency: ci-${{ github.ref }}
on:
push:
tags-ignore:
- "*"
branches:
- "main"
pull_request:
release:
types: [published]
workflow_dispatch:
env:
PACKAGE_NAME: trento-agent
OBS_USER: ${{ secrets.OBS_USER }}
OBS_PASS: ${{ secrets.OBS_PASS }}
OBS_PROJECT: ${{ secrets.OBS_PROJECT }}
TARGET_PROJECT: ${{ secrets.TARGET_PROJECT }}
FOLDER: packaging/suse
REPOSITORY: ${{ github.repository }}
jobs:
generate-docs:
runs-on: ubuntu-20.04
if: (github.event_name == 'push' && github.ref == 'refs/heads/main')
steps:
- name: trigger docs update in sum.golang.org and pkg.go.dev
uses: essentialkaos/godoc-action@v1
static-analysis:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v3
with:
go-version: 1.18
- uses: actions/[email protected]
id: go-cache
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: go vet check
run: make vet-check
- name: go fmt check
run: make fmt-check
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.48.0
skip-cache: true
args: "--timeout=3m"
test:
runs-on: ubuntu-20.04
env:
RABBITMQ_URL: amqp://guest:guest@localhost:5672
services:
rabbitmq:
image: rabbitmq
env:
RABBITMQ_DEFAULT_USER: guest
RABBITMQ_DEFAULT_PASS: guest
ports:
- 5672:5672
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v3
with:
go-version: 1.18
- uses: actions/[email protected]
id: go-cache
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: test
run: make test-coverage
- name: install goveralls
run: go install github.com/mattn/goveralls@latest
- name: send coverage
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: goveralls -coverprofile=covprofile -service=github
test-plugins:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v3
with:
go-version: 1.18
- uses: actions/[email protected]
id: go-cache
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: build dummy plugin
run: |
mkdir /tmp/plugins
go build -o /tmp/plugins/dummy ./plugin_examples/dummy.go
- name: build trento binary
run: make build
- name: run facts list command
run: |
./trento-agent facts list --plugins-folder /tmp/plugins 2>&1 | grep -q "dummy"
- name: run facts gather command
run: |
./trento-agent facts gather --gatherer dummy --argument 1 --plugins-folder /tmp/plugins 2>&1 | grep -q 'Name: 1'
build-static-binary:
runs-on: ubuntu-20.04
needs: [static-analysis, test, test-plugins]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v3
with:
go-version: 1.18
- uses: actions/[email protected]
id: go-cache
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: build
run: make -j4 cross-compiled
- name: compress
run: |
set -x
find ./build -maxdepth 1 -mindepth 1 -type d -exec sh -c 'tar -zcf build/trento-agent-$(basename {}).tgz -C {} trento-agent -C $(pwd)/packaging/systemd trento-agent.service' \;
- uses: actions/upload-artifact@v3
with:
name: trento-binaries
path: |
build/trento-agent-amd64.tgz
build/trento-agent-arm64.tgz
build/trento-agent-ppc64le.tgz
build/trento-agent-s390x.tgz
release-rolling:
needs: [build-static-binary]
if: (github.event_name == 'push' && github.ref == 'refs/heads/main')
runs-on: ubuntu-20.04
steps:
- uses: actions/download-artifact@v3
with:
name: trento-binaries
- uses: "marvinpinto/[email protected]"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "rolling"
prerelease: true
title: "Cutting Edge"
files: |
trento-agent-amd64.tgz
trento-agent-arm64.tgz
trento-agent-ppc64le.tgz
trento-agent-s390x.tgz
# This job doesn't actually make release, but rather reacts to a manual one, made via the GitHub UI.
# In the future, we might want to reuse the same mechanism of the rolling ones to automate everything here as well.
release-tag:
needs: [build-static-binary]
if: github.event.release
runs-on: ubuntu-20.04
steps:
- uses: actions/download-artifact@v3
with:
name: trento-binaries
- uses: AButler/[email protected]
with:
files: "trento-*"
repo-token: ${{ secrets.GITHUB_TOKEN }}
obs-commit:
needs: [static-analysis, test, test-plugins]
runs-on: ubuntu-20.04
if: github.ref == 'refs/heads/main' || github.event_name == 'release'
container:
image: ghcr.io/trento-project/continuous-delivery:main
env:
OSC_CHECKOUT_DIR: /tmp/trento-agent-package
options: -u 0:0
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: configure OSC
run: |
mkdir -p $HOME/.config/osc
cp /home/osc/.config/osc/oscrc $HOME/.config/osc
/scripts/init_osc_creds.sh
- name: prepare _service file
run: |
git config --global --add safe.directory /__w/agent/agent
VERSION=$(./hack/get_version_from_git.sh)
sed -i 's~%%REVISION%%~${{ github.sha }}~' $FOLDER/_service && \
sed -i 's~%%REPOSITORY%%~${{ github.repository }}~' $FOLDER/_service && \
sed -i 's~%%VERSION%%~'"${VERSION}"'~' $FOLDER/_service
- name: create vendor dependencies archive
# note the following tar options to strip all the things that could make the archive different without the content actually changing
# to make it easier to identify when dependencies changed
run: |
go mod vendor
tar --sort=name --owner=root:0 --group=root:0 --mtime='UTC 1970-01-01' -c vendor | gzip -n > vendor.tar.gz
- name: checkout and prepare OBS package
run: |
osc checkout $OBS_PROJECT trento-agent -o $OSC_CHECKOUT_DIR
cp $FOLDER/_service $OSC_CHECKOUT_DIR
rm -v $OSC_CHECKOUT_DIR/*.tar.gz
pushd $OSC_CHECKOUT_DIR
osc service manualrun
cp /__w/agent/agent/vendor.tar.gz .
- name: prepare trento-agent.changes file
# The .changes file is updated only in release creation. This current task should be improved
# in order to add the current rolling release notes
if: github.event_name == 'release'
run: |
git config --global --add safe.directory /__w/agent/agent
VERSION=$(./hack/get_version_from_git.sh)
TAG=$(echo $VERSION | cut -f1 -d+)
hack/gh_release_to_obs_changeset.py $REPOSITORY -a [email protected] -t $TAG -f $OSC_CHECKOUT_DIR/trento-agent.changes
- name: commit changes into OBS
run: |
pushd $OSC_CHECKOUT_DIR
osc ar
osc commit -m "GitHub Actions automated update to reference ${{ github.sha }}"
obs-submit:
needs: obs-commit
runs-on: ubuntu-20.04
if: github.event.release
container:
image: ghcr.io/trento-project/continuous-delivery:main
options: -u 0:0
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: configure OSC
run: |
mkdir -p $HOME/.config/osc
cp /home/osc/.config/osc/oscrc $HOME/.config/osc
/scripts/init_osc_creds.sh
- name: prepare _service file
run: |
git config --global --add safe.directory /__w/agent/agent
VERSION=$(./hack/get_version_from_git.sh)
sed -i 's~%%REVISION%%~${{ github.sha }}~' $FOLDER/_service && \
sed -i 's~%%REPOSITORY%%~${{ github.repository }}~' $FOLDER/_service && \
sed -i 's~%%VERSION%%~'"${VERSION}"'~' $FOLDER/_service
- name: submit package
run: /scripts/submit.sh