-
Notifications
You must be signed in to change notification settings - Fork 84
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
273 lines (261 loc) · 11.8 KB
/
.gitlab-ci.yml
File metadata and controls
273 lines (261 loc) · 11.8 KB
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
# -*- coding: utf-8 -*-
# vim: ft=yaml
---
###############################################################################
# Define all YAML node anchors
###############################################################################
.node_anchors:
# `only` (also used for `except` where applicable)
only_branch_master_parent_repo: &only_branch_master_parent_repo
- 'master@saltstack-formulas/template-formula'
# `stage`
stage_cache: &stage_cache 'cache'
stage_lint: &stage_lint 'lint'
stage_release: &stage_release 'release'
stage_test: &stage_test 'test'
# `image`
# yamllint disable rule:line-length
image_commitlint: &image_commitlint 'techneg/ci-commitlint:v1.1.138@sha256:8bafe274971e26264dea23d5e9b29167c5219dcd4bbb0f0d5aa4e5f5cd58340d'
image_dindruby: &image_dindruby 'techneg/ci-docker-python-ruby:v2.2.108@sha256:18948a17bbdf6243c3488f248a548fd40398d5d6476f92f1edb3e4c0f35713a8'
image_dindrubybionic: &image_dindrubybionic 'techneg/ci-docker-python-ruby:v2.2.108@sha256:18948a17bbdf6243c3488f248a548fd40398d5d6476f92f1edb3e4c0f35713a8'
image_precommit: &image_precommit 'techneg/ci-pre-commit:v2.5.41@sha256:f41a4bb2423e681da526561363a95c8f7919dcbb5576a3d652d88c4a91e2a9e0'
image_rubocop: &image_rubocop 'pipelinecomponents/rubocop:latest@sha256:74850471782195453cdf91f4a5edf62b6fcc3365c124d4d975c7e87a702040d7'
image_semantic-release: &image_semanticrelease 'techneg/ci-semantic-release:v1.2.39@sha256:ad527d8dad61f4bf0caee7addfedde63ecba38b9ed12475d6fb74a6655b370b2'
# `services`
services_docker_dind: &services_docker_dind
- 'docker:29.4.1-dind@sha256:c77e5d7912f9b137cc67051fdc2991d8f5ae22c55ddf532bb836dcb693a04940'
# yamllint enable rule:line-length
# `variables`
# https://forum.gitlab.com/t/gitlab-com-ci-caching-rubygems/5627/3
# https://bundler.io/v2.3/man/bundle-config.1.html
variables_bundler: &variables_bundler
BUNDLE_PATH: '${CI_PROJECT_DIR}/.cache/bundler'
BUNDLE_DEPLOYMENT: 'true'
bundle_install: &bundle_install
- 'bundle version'
- 'bundle config list'
# `--no-cache` means don't bother caching the downloaded .gem files
- 'time bundle install --no-cache'
cache_bundler: &cache_bundler
key:
files:
- 'Gemfile.lock'
prefix: 'bundler'
paths:
- '${BUNDLE_PATH}'
# https://pre-commit.com/#gitlab-ci-example
variables_pre-commit: &variables_pre-commit
PRE_COMMIT_HOME: '${CI_PROJECT_DIR}/.cache/pre-commit'
cache_pre-commit: &cache_pre-commit
key:
files:
- '.pre-commit-config.yaml'
prefix: 'pre-commit'
paths:
- '${PRE_COMMIT_HOME}'
###############################################################################
# Define stages and global variables
###############################################################################
stages:
- *stage_cache
- *stage_lint
- *stage_test
- *stage_release
variables:
DOCKER_DRIVER: 'overlay2'
###############################################################################
# `cache` stage: build up the bundler cache required before the `test` stage
###############################################################################
build-cache:
stage: *stage_cache
image: *image_dindruby
variables: *variables_bundler
cache: *cache_bundler
script: *bundle_install
###############################################################################
# `lint` stage: `commitlint`, `pre-commit` & `rubocop` (latest, failure allowed)
###############################################################################
.lint_job:
stage: *stage_lint
needs: []
commitlint:
extends: '.lint_job'
image: *image_commitlint
script:
# Add `upstream` remote to get access to `upstream/master`
- 'git remote add upstream
https://gitlab.com/saltstack-formulas/template-formula.git'
- 'git fetch --all'
# Set default commit hashes for `--from` and `--to`
- 'export COMMITLINT_FROM="$(git merge-base upstream/master HEAD)"'
- 'export COMMITLINT_TO="${CI_COMMIT_SHA}"'
# Run `commitlint`
- 'commitlint --from "${COMMITLINT_FROM}"
--to "${COMMITLINT_TO}"
--verbose'
pre-commit:
extends: '.lint_job'
image: *image_precommit
# https://pre-commit.com/#gitlab-ci-example
variables: *variables_pre-commit
cache: *cache_pre-commit
script:
- 'pre-commit run --all-files --color always --verbose'
- 'pre-commit run --color always --hook-stage manual commitlint-ci'
# Use a separate job for `rubocop` other than the one potentially run by `pre-commit`
# - The `pre-commit` check will only be available for formulas that pass the default
# `rubocop` check -- and must continue to do so
# - This job is allowed to fail, so can be used for all formulas
# - Furthermore, this job uses all of the latest `rubocop` features & cops,
# which will help when upgrading the `rubocop` linter used in `pre-commit`
rubocop:
extends: '.lint_job'
allow_failure: true
image: *image_rubocop
script:
- 'rubocop -d -P -S --enable-pending-cops'
###############################################################################
# Define `test` template
###############################################################################
.test_instance: &test_instance
stage: *stage_test
image: *image_dindruby
services: *services_docker_dind
variables: *variables_bundler
cache:
<<: *cache_bundler
policy: 'pull'
before_script: *bundle_install
script:
- 'echo "Starting test job: ${CI_JOB_NAME}"'
- 'bin/kitchen verify "${CI_JOB_NAME}"'
###############################################################################
# Define `test` template (`allow_failure: true`)
###############################################################################
.test_instance_failure_permitted:
<<: *test_instance
allow_failure: true
# <REMOVEME
###############################################################################
# Define `test_conversion` template
###############################################################################
.test_conversion:
stage: *stage_test
image: *image_dindrubybionic
services: *services_docker_dind
variables:
<<: [*variables_bundler, *variables_pre-commit]
cache:
- <<: *cache_bundler
policy: 'pull'
- <<: *cache_pre-commit
policy: 'pull'
before_script:
- 'export CONVERTED=test-the-use_this_template-button'
- 'git clone . /tmp/"${CONVERTED}"-formula'
- 'cd /tmp/"${CONVERTED}"-formula'
- 'git config user.email "test@example.com"'
- 'git config user.name "Test Name"'
# Install `pre-commit` hooks
- 'bin/install-hooks'
# Run the conversion script with debug output
- 'DEBUG=true bin/convert-formula.sh "${CONVERTED}"'
- '[ $(git rev-list HEAD --count) -eq 2 ]'
# Quick visual check that correct files have been updated
- 'git show --pretty="" --name-status'
- !reference [.node_anchors, bundle_install]
script:
- 'bin/kitchen verify default-debian-11-master'
# REMOVEME>
###############################################################################
# `test` stage: each instance below uses the `test` template above
###############################################################################
## Define the rest of the matrix based on Kitchen testing
# Make sure the instances listed below match up with
# the `platforms` defined in `kitchen.yml`
# <REMOVEME
# NOTE: Please try to select up to six instances that add some meaningful
# testing of the formula's behaviour. If possible, try to refrain from
# the classical "chosing all the instances because I want to test on
# another/all distro/s" trap: it will just add time to the testing (see
# the discussion on #121). As an example, the set chosen below covers
# the most used distros families, systemd and non-systemd and the latest
# three supported Saltstack versions with python2 and 3.
# As for `kitchen.yml`, that should still contain all of the platforms,
# to allow for comprehensive local testing
# Ref: https://github.com/saltstack-formulas/template-formula/issues/118
# Ref: https://github.com/saltstack-formulas/template-formula/issues/121
test-formula-conversion: {extends: '.test_conversion'}
# REMOVEME>
# yamllint disable rule:line-length
# Fedora 41+ will permit failure until this PR is merged into kitchen-docker
# https://github.com/test-kitchen/kitchen-docker/pull/427 is merged
# OpenSUSE master branch will fail until zypperpkg module is back in salt core
# https://github.com/saltstack/great-module-migration/issues/14
#
almalinux-9-master: {extends: '.test_instance_failure_permitted'}
almalinux-8-master: {extends: '.test_instance_failure_permitted'}
amazonlinux-2023-master: {extends: '.test_instance_failure_permitted'}
amazonlinux-2-master: {extends: '.test_instance_failure_permitted'}
centos-stream9-master: {extends: '.test_instance_failure_permitted'}
debian-12-master: {extends: '.test_instance_failure_permitted'}
debian-11-master: {extends: '.test_instance_failure_permitted'}
fedora-41-master: {extends: '.test_instance_failure_permitted'}
fedora-40-master: {extends: '.test_instance_failure_permitted'}
opensuse-leap-156-master: {extends: '.test_instance_failure_permitted'}
opensuse-tmbl-latest-master: {extends: '.test_instance_failure_permitted'}
oraclelinux-9-master: {extends: '.test_instance_failure_permitted'}
oraclelinux-8-master: {extends: '.test_instance_failure_permitted'}
rockylinux-9-master: {extends: '.test_instance_failure_permitted'}
rockylinux-8-master: {extends: '.test_instance_failure_permitted'}
ubuntu-2404-master: {extends: '.test_instance_failure_permitted'}
ubuntu-2204-master: {extends: '.test_instance_failure_permitted'}
ubuntu-2004-master: {extends: '.test_instance_failure_permitted'}
almalinux-9-3007: {extends: '.test_instance'}
almalinux-8-3007: {extends: '.test_instance'}
amazonlinux-2023-3007: {extends: '.test_instance'}
amazonlinux-2-3007: {extends: '.test_instance_failure_permitted'}
centos-stream9-3007: {extends: '.test_instance'}
debian-12-3007: {extends: '.test_instance'}
debian-11-3007: {extends: '.test_instance'}
fedora-41-3007: {extends: '.test_instance_failure_permitted'}
fedora-40-3007: {extends: '.test_instance'}
opensuse-leap-156-3007: {extends: '.test_instance'}
opensuse-tmbl-latest-3007: {extends: '.test_instance'}
oraclelinux-9-3007: {extends: '.test_instance'}
oraclelinux-8-3007: {extends: '.test_instance'}
rockylinux-9-3007: {extends: '.test_instance'}
rockylinux-8-3007: {extends: '.test_instance'}
ubuntu-2404-3007: {extends: '.test_instance'}
ubuntu-2204-3007: {extends: '.test_instance'}
ubuntu-2004-3007: {extends: '.test_instance'}
almalinux-9-3006: {extends: '.test_instance'}
almalinux-8-3006: {extends: '.test_instance'}
amazonlinux-2023-3006: {extends: '.test_instance'}
amazonlinux-2-3006: {extends: '.test_instance_failure_permitted'}
centos-stream9-3006: {extends: '.test_instance'}
debian-12-3006: {extends: '.test_instance'}
debian-11-3006: {extends: '.test_instance'}
fedora-41-3006: {extends: '.test_instance_failure_permitted'}
fedora-40-3006: {extends: '.test_instance'}
opensuse-leap-156-3006: {extends: '.test_instance'}
opensuse-tmbl-latest-3006: {extends: '.test_instance'}
oraclelinux-9-3006: {extends: '.test_instance'}
oraclelinux-8-3006: {extends: '.test_instance'}
rockylinux-9-3006: {extends: '.test_instance'}
rockylinux-8-3006: {extends: '.test_instance'}
ubuntu-2404-3006: {extends: '.test_instance'}
ubuntu-2204-3006: {extends: '.test_instance'}
ubuntu-2004-3006: {extends: '.test_instance'}
# yamllint enable rule:line-length
###############################################################################
# `release` stage: `semantic-release`
###############################################################################
semantic-release:
stage: *stage_release
image: *image_semanticrelease
variables:
MAINTAINER_TOKEN: '${GH_TOKEN}'
script:
# Run `semantic-release`
- 'semantic-release'