-
Notifications
You must be signed in to change notification settings - Fork 6
310 lines (278 loc) · 11.2 KB
/
centreon-collect.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
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
name: Centreon collect
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
on:
workflow_dispatch:
pull_request:
paths:
- bbdo/**
- broker/**
- ccc/**
- clib/**
- connectors/**
- engine/**
- grpc/**
- packaging/**
- cmake.sh
- CMakeLists.txt
- conanfile.txt
- selinux/**
- "!.veracode-exclusions"
push:
branches:
- develop
- dev-[2-9][0-9].[0-9][0-9].x
- master
- "[2-9][0-9].[0-9][0-9].x"
paths:
- bbdo/**
- broker/**
- ccc/**
- clib/**
- connectors/**
- engine/**
- grpc/**
- packaging/**
- cmake.sh
- CMakeLists.txt
- conanfile.txt
- selinux/**
- "!.veracode-exclusions"
jobs:
get-version:
uses: ./.github/workflows/get-version.yml
create-version:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- id: version
run: |
IMG_VERSION=$(md5sum conanfile.txt | awk '{print substr($1, 0, 8)}')
echo "imgversion=$IMG_VERSION" >> $GITHUB_OUTPUT
VERSION=$(awk '$1 ~ "COLLECT_MAJOR" {maj=substr($2, 1, length($2)-1)} $1 ~ "COLLECT_MINOR" {min=substr($2, 1, length($2)-1) ; print maj "." min}' CMakeLists.txt)
PATCH=$(awk '$1 ~ "COLLECT_PATCH" {print substr($2, 1, length($2) - 1)}' CMakeLists.txt)
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "patch=$PATCH" >> $GITHUB_OUTPUT
if [[ -z "$GITHUB_HEAD_REF" ]] ; then
BRANCHNAME="$GITHUB_REF_NAME"
else
BRANCHNAME="$GITHUB_HEAD_REF"
fi
case "$BRANCHNAME" in
master | [2-9][0-9].[0-9][0-9].x | release* | hotfix*)
echo "release=1" >> $GITHUB_OUTPUT
;;
*)
echo "release=`date +%s`.`echo ${{ github.sha }} | cut -c -7`" >> $GITHUB_OUTPUT
;;
esac
shell: bash
- run: |
echo "ImgVersion is ${{ steps.version.outputs.imgversion }}"
echo "Version is ${{ steps.version.outputs.version }}.${{ steps.version.outputs.patch }}"
echo "Release is ${{ steps.version.outputs.release }}"
outputs:
imgversion: ${{ steps.version.outputs.imgversion }}
version: ${{ steps.version.outputs.version }}
patch: ${{ steps.version.outputs.patch }}
release: ${{ steps.version.outputs.release }}
centreon-collect-test:
needs: [create-version, get-version]
if: ${{ ! contains(fromJson('["stable"]'), needs.get-version.outputs.stability) }}
runs-on: [self-hosted, collect]
env:
imgversion: ${{ needs.create-version.outputs.imgversion }}
version: ${{ needs.create-version.outputs.version }}.${{ needs.create-version.outputs.patch }}
release: ${{ needs.create-version.outputs.release }}
strategy:
fail-fast: false
matrix:
image: [centos7, alma8, debian-bullseye]
name: unit test ${{ matrix.image }}
steps:
- name: Checkout sources
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Login to Registry
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
registry: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}
username: ${{ secrets.DOCKER_REGISTRY_ID }}
password: ${{ secrets.DOCKER_REGISTRY_PASSWD }}
- name: Test ${{ matrix.image }}
uses: ./.github/actions/runner-docker
with:
registry_url: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}
script_name: /src/ci/scripts/collect-unit-tests
image_name: centreon-collect-${{ matrix.image }}
image_version: ${{ env.imgversion }}
rpm-packaging:
needs: [create-version, get-version]
if: ${{ ! contains(fromJson('["stable"]'), needs.get-version.outputs.stability) }}
runs-on: [self-hosted, collect]
env:
version: ${{ needs.create-version.outputs.version }}.${{ needs.create-version.outputs.patch }}
imgversion: ${{ needs.create-version.outputs.imgversion }}
release: ${{ needs.create-version.outputs.release }}
strategy:
matrix:
include:
- image: centos7
distrib: el7
- image: alma8
distrib: el8
steps:
- name: Checkout sources
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Login to Registry
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc # v2.2.0
with:
registry: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}
username: ${{ secrets.DOCKER_REGISTRY_ID }}
password: ${{ secrets.DOCKER_REGISTRY_PASSWD }}
- name: make rpm ${{ matrix.image }}
uses: ./.github/actions/runner-docker
with:
registry_url: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}
script_name: /src/ci/scripts/collect-rpm-package
image_name: centreon-collect-${{ matrix.image }}
image_version: ${{ env.imgversion }}
env_variable: -e DISTRIB="${{ matrix.distrib }}" -e VERSION="${{ env.version }}" -e RELEASE="${{ env.release }}"
- name: sign rpm ${{ matrix.image }}
uses: ./.github/actions/package-sign
with:
script_name: rpm-signing
image_name: rpm-signing
image_version: ubuntu
registry_url: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}
registry_username: ${{ secrets.DOCKER_REGISTRY_ID }}
registry_password: ${{ secrets.DOCKER_REGISTRY_PASSWD }}
- name: Use cache RPM files
uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
env:
cache-name-rpmbuild: cache-${{ github.sha }}-${{ github.run_id }}-rpmbuild-collect-${{ matrix.distrib }}
with:
path: ./*.rpm
key: ${{ env.cache-name-rpmbuild }}
debian-packaging:
needs: [create-version, get-version]
if: ${{ ! contains(fromJson('["stable"]'), needs.get-version.outputs.stability) }}
runs-on: [self-hosted, collect]
env:
imgversion: ${{ needs.create-version.outputs.imgversion }}
version: ${{ needs.create-version.outputs.version }}.${{ needs.create-version.outputs.patch }}
release: ${{ needs.create-version.outputs.release }}
strategy:
matrix:
include:
- image: debian-bullseye
distrib: bullseye
steps:
- name: Checkout sources
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
path: centreon-collect
- name: Login to Registry
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc # v2.2.0
with:
registry: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}
username: ${{ secrets.DOCKER_REGISTRY_ID }}
password: ${{ secrets.DOCKER_REGISTRY_PASSWD }}
- name: debmake ${{ matrix.image }}
uses: ./centreon-collect/.github/actions/runner-docker
with:
registry_url: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}
script_name: /src/centreon-collect/ci/scripts/collect-deb-package
image_name: centreon-collect-${{ matrix.image }}
image_version: ${{ env.imgversion }}
env_variable: -e DISTRIB="${{ matrix.distrib }}" -e VERSION="${{ env.version }}" -e RELEASE="${{ env.release }}"
- name: Use cache DEB files
uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
env:
cache-name-debbuild: cache-${{ github.sha }}-${{ github.run_id }}-debbuild-centreon-collect-${{ matrix.distrib }}
with:
path: ./*.deb
key: ${{ env.cache-name-debbuild }}
deliver-sources:
runs-on: [self-hosted, common]
needs: [get-version, debian-packaging, rpm-packaging]
if: ${{ contains(fromJson('["stable"]'), needs.get-version.outputs.stability) && github.event_name != 'workflow_dispatch' }}
steps:
- name: Checkout sources
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
path: centreon-collect
- name: Deliver sources
uses: ./centreon-collect/.github/actions/release-sources
with:
bucket_directory: centreon-collect
module_directory: centreon-collect
module_name: centreon-collect
major_version: ${{ needs.get-version.outputs.version }}
minor_version: ${{ needs.get-version.outputs.patch }}
token_download_centreon_com: ${{ secrets.TOKEN_DOWNLOAD_CENTREON_COM }}
delivery-debian:
needs: [debian-packaging, create-version, get-version]
if: ${{ contains(fromJson('["testing", "unstable"]'), needs.get-version.outputs.stability) }}
env:
version: ${{ needs.create-version.outputs.version }}
environment: ${{ needs.get-version.outputs.environment }}
runs-on: [self-hosted, common]
name: Delivery
strategy:
matrix:
distrib: [bullseye]
steps:
- name: Checkout sources
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Publish DEB packages
uses: ./.github/actions/delivery
with:
module_name: collect
distrib: ${{ matrix.distrib }}
version: ${{ env.version }}
artifactory_token: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }}
cache_key: cache-${{ github.sha }}-${{ github.run_id }}-debbuild-centreon-collect-${{ matrix.distrib }}
delivery-centos:
needs: [rpm-packaging, create-version, get-version]
if: ${{ contains(fromJson('["testing", "unstable"]'), needs.get-version.outputs.stability) }}
env:
version: ${{ needs.create-version.outputs.version }}
environment: ${{ needs.get-version.outputs.environment }}
runs-on: [self-hosted, common]
name: Delivery
strategy:
matrix:
distrib: [el7, el8]
steps:
- name: Checkout sources
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Publish RPM packages
uses: ./.github/actions/delivery
with:
distrib: ${{ matrix.distrib }}
version: ${{ env.version }}
module_name: collect
artifactory_token: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }}
cache_key: cache-${{ github.sha }}-${{ github.run_id }}-rpmbuild-collect-${{ matrix.distrib }}
promote:
needs: [get-version]
if: ${{ contains(fromJson('["stable"]'), needs.get-version.outputs.stability) && github.event_name != 'workflow_dispatch' }}
runs-on: [self-hosted, common]
strategy:
matrix:
distrib: [el7, el8, bullseye]
steps:
- name: Checkout sources
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Promote ${{ matrix.distrib }} to stable
uses: ./.github/actions/promote-to-stable
with:
artifactory_token: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }}
module_name: collect
distrib: ${{ matrix.distrib }}
major_version: ${{ needs.get-version.outputs.version }}
minor_version: ${{ needs.get-version.outputs.patch }}
stability: ${{ needs.get-version.outputs.stability }}
repository_name: standard