99 only_branch_master_parent_repo : &only_branch_master_parent_repo
1010 - ' master@saltstack-formulas/vault-formula'
1111 # `stage`
12+ stage_cache : &stage_cache 'cache'
1213 stage_lint : &stage_lint 'lint'
1314 stage_release : &stage_release 'release'
1415 stage_test : &stage_test 'test'
2627 # yamllint enable rule:line-length
2728 # `variables`
2829 # https://forum.gitlab.com/t/gitlab-com-ci-caching-rubygems/5627/3
29- # https://bundler.io/v1.16/bundle_config .html
30+ # https://bundler.io/v2.3/man/bundle-config.1 .html
3031 variables_bundler : &variables_bundler
31- BUNDLE_CACHE_PATH : ' ${CI_PROJECT_DIR}/.cache/bundler'
32- BUNDLE_WITHOUT : ' production'
33- # `cache`
32+ BUNDLE_PATH : ' ${CI_PROJECT_DIR}/.cache/bundler'
33+ BUNDLE_DEPLOYMENT : ' true'
34+ bundle_install : &bundle_install
35+ - ' bundle version'
36+ - ' bundle config list'
37+ # `--no-cache` means don't bother caching the downloaded .gem files
38+ - ' time bundle install --no-cache'
3439 cache_bundler : &cache_bundler
35- key : ' ${CI_JOB_STAGE}'
40+ key :
41+ files :
42+ - ' Gemfile.lock'
43+ prefix : ' bundler'
3644 paths :
37- - ' ${BUNDLE_CACHE_PATH}'
45+ - ' ${BUNDLE_PATH}'
46+ # https://pre-commit.com/#gitlab-ci-example
47+ variables_pre-commit : &variables_pre-commit
48+ PRE_COMMIT_HOME : ' ${CI_PROJECT_DIR}/.cache/pre-commit'
49+ cache_pre-commit : &cache_pre-commit
50+ key :
51+ files :
52+ - ' .pre-commit-config.yaml'
53+ prefix : ' pre-commit'
54+ paths :
55+ - ' ${PRE_COMMIT_HOME}'
3856
3957# ##############################################################################
4058# Define stages and global variables
4159# ##############################################################################
4260stages :
61+ - *stage_cache
4362 - *stage_lint
4463 - *stage_test
4564 - *stage_release
4665variables :
4766 DOCKER_DRIVER : ' overlay2'
4867
68+
69+ # ##############################################################################
70+ # `cache` stage: build up the bundler cache required before the `test` stage
71+ # ##############################################################################
72+ build-cache :
73+ stage : *stage_cache
74+ image : *image_dindruby
75+ variables : *variables_bundler
76+ cache : *cache_bundler
77+ script : *bundle_install
78+
4979# ##############################################################################
5080# `lint` stage: `commitlint`, `pre-commit` & `rubocop` (latest, failure allowed)
5181# ##############################################################################
52- commitlint :
82+ .lint_job :
5383 stage : *stage_lint
84+ needs : []
85+
86+ commitlint :
87+ extends : ' .lint_job'
5488 image : *image_commitlint
5589 script :
5690 # Add `upstream` remote to get access to `upstream/master`
@@ -75,15 +109,11 @@ commitlint:
75109 --verbose'
76110
77111pre-commit :
78- stage : *stage_lint
112+ extends : ' .lint_job '
79113 image : *image_precommit
80114 # https://pre-commit.com/#gitlab-ci-example
81- variables :
82- PRE_COMMIT_HOME : ' ${CI_PROJECT_DIR}/.cache/pre-commit'
83- cache :
84- key : ' ${CI_JOB_NAME}'
85- paths :
86- - ' ${PRE_COMMIT_HOME}'
115+ variables : *variables_pre-commit
116+ cache : *cache_pre-commit
87117 script :
88118 - ' pre-commit run --all-files --color always --verbose'
89119 - ' pre-commit run --color always --hook-stage manual commitlint-ci'
@@ -95,8 +125,8 @@ pre-commit:
95125# - Furthermore, this job uses all of the latest `rubocop` features & cops,
96126# which will help when upgrading the `rubocop` linter used in `pre-commit`
97127rubocop :
128+ extends : ' .lint_job'
98129 allow_failure : true
99- stage : *stage_lint
100130 image : *image_rubocop
101131 script :
102132 - ' rubocop -d -P -S --enable-pending-cops'
@@ -109,12 +139,10 @@ rubocop:
109139 image : *image_dindruby
110140 services : *services_docker_dind
111141 variables : *variables_bundler
112- cache : *cache_bundler
113- before_script :
114- # TODO: This should work from the env vars above automatically
115- - ' bundle config set path "${BUNDLE_CACHE_PATH}"'
116- - ' bundle config set without "${BUNDLE_WITHOUT}"'
117- - ' bundle install'
142+ cache :
143+ << : *cache_bundler
144+ policy : ' pull'
145+ before_script : *bundle_install
118146 script :
119147 # Alternative value to consider: `${CI_JOB_NAME}`
120148 - ' bin/kitchen verify "${DOCKER_ENV_CI_JOB_NAME}"'
@@ -145,20 +173,20 @@ rockylinux-8-master: {extends: '.test_instance_failure_permitted'}
145173ubuntu-2404-master : {extends: '.test_instance_failure_permitted'}
146174ubuntu-2204-master : {extends: '.test_instance_failure_permitted'}
147175ubuntu-2004-master : {extends: '.test_instance_failure_permitted'}
148- debian-12-3007-2 : {extends: '.test_instance'}
149- debian-11-3007-2 : {extends: '.test_instance'}
150- rockylinux-9-3007-2 : {extends: '.test_instance'}
151- rockylinux-8-3007-2 : {extends: '.test_instance'}
152- ubuntu-2404-3007-2 : {extends: '.test_instance'}
153- ubuntu-2204-3007-2 : {extends: '.test_instance'}
154- ubuntu-2004-3007-2 : {extends: '.test_instance'}
155- debian-12-3006-10 : {extends: '.test_instance'}
156- debian-11-3006-10 : {extends: '.test_instance'}
157- rockylinux-9-3006-10 : {extends: '.test_instance'}
158- rockylinux-8-3006-10 : {extends: '.test_instance'}
159- ubuntu-2404-3006-10 : {extends: '.test_instance'}
160- ubuntu-2204-3006-10 : {extends: '.test_instance'}
161- ubuntu-2004-3006-10 : {extends: '.test_instance'}
176+ debian-12-3007-3 : {extends: '.test_instance'}
177+ debian-11-3007-3 : {extends: '.test_instance'}
178+ rockylinux-9-3007-3 : {extends: '.test_instance'}
179+ rockylinux-8-3007-3 : {extends: '.test_instance'}
180+ ubuntu-2404-3007-3 : {extends: '.test_instance'}
181+ ubuntu-2204-3007-3 : {extends: '.test_instance'}
182+ ubuntu-2004-3007-3 : {extends: '.test_instance'}
183+ debian-12-3006-11 : {extends: '.test_instance'}
184+ debian-11-3006-11 : {extends: '.test_instance'}
185+ rockylinux-9-3006-11 : {extends: '.test_instance'}
186+ rockylinux-8-3006-11 : {extends: '.test_instance'}
187+ ubuntu-2404-3006-11 : {extends: '.test_instance'}
188+ ubuntu-2204-3006-11 : {extends: '.test_instance'}
189+ ubuntu-2004-3006-11 : {extends: '.test_instance'}
162190# yamllint enable rule:line-length
163191
164192# ##############################################################################
0 commit comments