Update Gemfiles, add kitchen and hooks from template-formula
[arvados-formula.git] / .gitlab-ci.yml
1 # -*- coding: utf-8 -*-
2 # vim: ft=yaml
3 ---
4 ###############################################################################
5 # Define all YAML node anchors
6 ###############################################################################
7 .node_anchors:
8   # `only` (also used for `except` where applicable)
9   only_branch_main_parent_repo: &only_branch_main_parent_repo
10     - 'main@git.arvados.org/arvados-formula'
11   # `stage`
12   stage_lint: &stage_lint 'lint'
13   stage_release: &stage_release 'release'
14   stage_test: &stage_test 'test'
15   # `image`
16   image_commitlint: &image_commitlint 'myii/ssf-commitlint:11'
17   image_dindruby: &image_dindruby 'myii/ssf-dind-ruby:2.7.1-r3'
18   image_precommit: &image_precommit
19     name: 'myii/ssf-pre-commit:2.9.2'
20     entrypoint: ['/bin/bash', '-c']
21   image_rubocop: &image_rubocop 'pipelinecomponents/rubocop:latest'
22   image_semantic-release: &image_semanticrelease 'myii/ssf-semantic-release:15.14'
23   # `services`
24   services_docker_dind: &services_docker_dind
25     - 'docker:dind'
26   # `variables`
27   # https://forum.gitlab.com/t/gitlab-com-ci-caching-rubygems/5627/3
28   # https://bundler.io/v1.16/bundle_config.html
29   variables_bundler: &variables_bundler
30     BUNDLE_CACHE_PATH: '${CI_PROJECT_DIR}/.cache/bundler'
31     BUNDLE_WITHOUT: 'production'
32   # `cache`
33   cache_bundler: &cache_bundler
34     key: '${CI_JOB_STAGE}'
35     paths:
36       - '${BUNDLE_CACHE_PATH}'
37
38 ###############################################################################
39 # Define stages and global variables
40 ###############################################################################
41 stages:
42   - *stage_lint
43   - *stage_test
44   - *stage_release
45 variables:
46   DOCKER_DRIVER: 'overlay2'
47
48 ###############################################################################
49 # `lint` stage: `commitlint`, `pre-commit` & `rubocop` (latest, failure allowed)
50 ###############################################################################
51 # Disable commitlint because Arvados does not follow this standard, it has
52 # its own, see https://dev.arvados.org/projects/arvados/wiki/Coding_Standards
53 # commitlint:
54 #   stage: *stage_lint
55 #   image: *image_commitlint
56 #   script:
57 #     # Add `upstream` remote to get access to `upstream/main`
58 #     - 'git remote add upstream
59 #        https://git.arvados.org/arvados-formula.git'
60 #     - 'git fetch --all'
61 #     # Set default commit hashes for `--from` and `--to`
62 #     - 'export COMMITLINT_FROM="$(git merge-base upstream/main HEAD)"'
63 #     - 'export COMMITLINT_TO="${CI_COMMIT_SHA}"'
64 #     # `coqbot` adds a merge commit to test PRs on top of the latest commit in
65 #     # the repo; amend this merge commit message to avoid failure
66 #     - |
67 #       if [ "${GITLAB_USER_LOGIN}" = "coqbot" ] \
68 #       && [ "${CI_COMMIT_BRANCH}" != "main" ]; then
69 #         git commit --amend -m \
70 #           'chore: reword coqbot merge commit message for commitlint'
71 #         export COMMITLINT_TO=HEAD
72 #       fi
73 #     # Run `commitlint`
74 #     - 'commitlint --from "${COMMITLINT_FROM}"
75 #                   --to   "${COMMITLINT_TO}"
76 #                   --verbose'
77
78 pre-commit:
79   stage: *stage_lint
80   image: *image_precommit
81   # https://pre-commit.com/#gitlab-ci-example
82   variables:
83     PRE_COMMIT_HOME: '${CI_PROJECT_DIR}/.cache/pre-commit'
84   cache:
85     key: '${CI_JOB_NAME}'
86     paths:
87       - '${PRE_COMMIT_HOME}'
88   script:
89     - 'pre-commit run --all-files --color always --verbose'
90
91 # Use a separate job for `rubocop` other than the one potentially run by `pre-commit`
92 # - The `pre-commit` check will only be available for formulas that pass the default
93 #   `rubocop` check -- and must continue to do so
94 # - This job is allowed to fail, so can be used for all formulas
95 # - Furthermore, this job uses all of the latest `rubocop` features & cops,
96 #   which will help when upgrading the `rubocop` linter used in `pre-commit`
97 rubocop:
98   allow_failure: true
99   stage: *stage_lint
100   image: *image_rubocop
101   script:
102     - 'rubocop -d -P -S --enable-pending-cops'
103
104 ###############################################################################
105 # Define `test` template
106 ###############################################################################
107 .test_instance:
108   stage: *stage_test
109   image: *image_dindruby
110   services: *services_docker_dind
111   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'
118   script:
119     # Alternative value to consider: `${CI_JOB_NAME}`
120     - 'bin/kitchen verify "${DOCKER_ENV_CI_JOB_NAME}"'
121
122 ###############################################################################
123 # `test` stage: each instance below uses the `test` template above
124 ###############################################################################
125 ## Define the rest of the matrix based on Kitchen testing
126 # Make sure the instances listed below match up with
127 # the `platforms` defined in `kitchen.yml`
128 # Get this list with
129 # kitchen list |awk '{print $1": {extends: '.test_instance'}"}' |sort -r
130
131 workbench-ubuntu-2004-tiamat-py3: {extends: .test_instance}
132 # workbench-ubuntu-2004-master-py3: {extends: .test_instance}
133 # workbench-ubuntu-2004-3003-1-py3: {extends: .test_instance}
134 # workbench-ubuntu-2004-3002-6-py3: {extends: .test_instance}
135 # workbench-ubuntu-2004-3001-7-py3: {extends: .test_instance}
136 # workbench-ubuntu-1804-tiamat-py3: {extends: .test_instance}
137 workbench-ubuntu-1804-master-py3: {extends: .test_instance}
138 # workbench-ubuntu-1804-3003-1-py3: {extends: .test_instance}
139 # workbench-ubuntu-1804-3002-6-py3: {extends: .test_instance}
140 # workbench-ubuntu-1804-3001-7-py3: {extends: .test_instance}
141 # workbench-ubuntu-1804-3000-9-py3: {extends: .test_instance}
142 # workbench-ubuntu-1804-3000-9-py2: {extends: .test_instance}
143 # workbench-debian-11-tiamat-py3: {extends: .test_instance}
144 # workbench-debian-11-master-py3: {extends: .test_instance}
145 # Not supported by nginx/passenger repos
146 # workbench-debian-11-3003-1-py3: {extends: .test_instance}
147 # workbench-debian-11-3002-6-py3: {extends: .test_instance}
148 # workbench-debian-10-tiamat-py3: {extends: .test_instance}
149 # workbench-debian-10-master-py3: {extends: .test_instance}
150 # workbench-debian-10-3003-1-py3: {extends: .test_instance}
151 workbench-debian-10-3002-6-py3: {extends: .test_instance}
152 # workbench-debian-10-3001-7-py3: {extends: .test_instance}
153 # workbench-debian-10-3000-9-py3: {extends: .test_instance}
154 # workbench-centos-7-tiamat-py3: {extends: .test_instance}
155 # workbench-centos-7-master-py3: {extends: .test_instance}
156 # workbench-centos-7-3003-1-py3: {extends: .test_instance}
157 # workbench-centos-7-3002-6-py3: {extends: .test_instance}
158 workbench-centos-7-3001-7-py3: {extends: .test_instance}
159 # workbench-centos-7-3000-9-py3: {extends: .test_instance}
160
161 # shell-ubuntu-2004-tiamat-py3: {extends: .test_instance}
162 shell-ubuntu-2004-master-py3: {extends: .test_instance}
163 # shell-ubuntu-2004-3003-1-py3: {extends: .test_instance}
164 # shell-ubuntu-2004-3002-6-py3: {extends: .test_instance}
165 # shell-ubuntu-2004-3001-7-py3: {extends: .test_instance}
166 # shell-ubuntu-1804-tiamat-py3: {extends: .test_instance}
167 # shell-ubuntu-1804-master-py3: {extends: .test_instance}
168 shell-ubuntu-1804-3003-1-py3: {extends: .test_instance}
169 # shell-ubuntu-1804-3002-6-py3: {extends: .test_instance}
170 # shell-ubuntu-1804-3001-7-py3: {extends: .test_instance}
171 # shell-ubuntu-1804-3000-9-py3: {extends: .test_instance}
172 # shell-ubuntu-1804-3000-9-py2: {extends: .test_instance}
173 # shell-debian-11-tiamat-py3: {extends: .test_instance}
174 # shell-debian-11-master-py3: {extends: .test_instance}
175 # shell-debian-11-3003-1-py3: {extends: .test_instance}
176 # Not supported by nginx/passenger repos
177 # shell-debian-11-3002-6-py3: {extends: .test_instance}
178 # shell-debian-10-tiamat-py3: {extends: .test_instance}
179 # shell-debian-10-master-py3: {extends: .test_instance}
180 # shell-debian-10-3003-1-py3: {extends: .test_instance}
181 # shell-debian-10-3002-6-py3: {extends: .test_instance}
182 shell-debian-10-3001-7-py3: {extends: .test_instance}
183 # shell-debian-10-3000-9-py3: {extends: .test_instance}
184 shell-centos-7-tiamat-py3: {extends: .test_instance}
185 # shell-centos-7-master-py3: {extends: .test_instance}
186 # shell-centos-7-3003-1-py3: {extends: .test_instance}
187 # shell-centos-7-3002-6-py3: {extends: .test_instance}
188 # shell-centos-7-3001-7-py3: {extends: .test_instance}
189 # shell-centos-7-3000-9-py3: {extends: .test_instance}
190
191 # keepstore-ubuntu-2004-tiamat-py3: {extends: .test_instance}
192 # keepstore-ubuntu-2004-master-py3: {extends: .test_instance}
193 keepstore-ubuntu-2004-3003-1-py3: {extends: .test_instance}
194 # keepstore-ubuntu-2004-3002-6-py3: {extends: .test_instance}
195 # keepstore-ubuntu-2004-3001-7-py3: {extends: .test_instance}
196 # keepstore-ubuntu-1804-tiamat-py3: {extends: .test_instance}
197 # keepstore-ubuntu-1804-master-py3: {extends: .test_instance}
198 # keepstore-ubuntu-1804-3003-1-py3: {extends: .test_instance}
199 keepstore-ubuntu-1804-3002-6-py3: {extends: .test_instance}
200 # keepstore-ubuntu-1804-3001-7-py3: {extends: .test_instance}
201 # keepstore-ubuntu-1804-3000-9-py3: {extends: .test_instance}
202 # keepstore-ubuntu-1804-3000-9-py2: {extends: .test_instance}
203 # Not supported by nginx/passenger repos
204 # keepstore-debian-11-tiamat-py3: {extends: .test_instance}
205 # keepstore-debian-11-master-py3: {extends: .test_instance}
206 # keepstore-debian-11-3003-1-py3: {extends: .test_instance}
207 # keepstore-debian-11-3002-6-py3: {extends: .test_instance}
208 # keepstore-debian-10-tiamat-py3: {extends: .test_instance}
209 # keepstore-debian-10-master-py3: {extends: .test_instance}
210 # keepstore-debian-10-3003-1-py3: {extends: .test_instance}
211 # keepstore-debian-10-3002-6-py3: {extends: .test_instance}
212 keepstore-debian-10-3001-7-py3: {extends: .test_instance}
213 # keepstore-debian-10-3000-9-py3: {extends: .test_instance}
214 # keepstore-centos-7-tiamat-py3: {extends: .test_instance}
215 # keepstore-centos-7-master-py3: {extends: .test_instance}
216 # keepstore-centos-7-3003-1-py3: {extends: .test_instance}
217 # keepstore-centos-7-3002-6-py3: {extends: .test_instance}
218 # keepstore-centos-7-3001-7-py3: {extends: .test_instance}
219 keepstore-centos-7-3000-9-py3: {extends: .test_instance}
220
221 # api-ubuntu-2004-tiamat-py3: {extends: .test_instance}
222 # api-ubuntu-2004-master-py3: {extends: .test_instance}
223 # api-ubuntu-2004-3003-1-py3: {extends: .test_instance}
224 api-ubuntu-2004-3002-6-py3: {extends: .test_instance}
225 # api-ubuntu-2004-3001-7-py3: {extends: .test_instance}
226 # api-ubuntu-1804-tiamat-py3: {extends: .test_instance}
227 # api-ubuntu-1804-master-py3: {extends: .test_instance}
228 # api-ubuntu-1804-3003-1-py3: {extends: .test_instance}
229 # api-ubuntu-1804-3002-6-py3: {extends: .test_instance}
230 api-ubuntu-1804-3001-7-py3: {extends: .test_instance}
231 # api-ubuntu-1804-3000-9-py3: {extends: .test_instance}
232 # api-ubuntu-1804-3000-9-py2: {extends: .test_instance}
233 # api-debian-11-tiamat-py3: {extends: .test_instance}
234 # api-debian-11-master-py3: {extends: .test_instance}
235 # Not supported by nginx/passenger repos
236 # api-debian-11-3003-1-py3: {extends: .test_instance}
237 # api-debian-11-3002-6-py3: {extends: .test_instance}
238 # api-debian-10-tiamat-py3: {extends: .test_instance}
239 # api-debian-10-master-py3: {extends: .test_instance}
240 # api-debian-10-3003-1-py3: {extends: .test_instance}
241 # api-debian-10-3002-6-py3: {extends: .test_instance}
242 # api-debian-10-3001-7-py3: {extends: .test_instance}
243 api-debian-10-3000-9-py3: {extends: .test_instance}
244 api-centos-7-tiamat-py3: {extends: .test_instance}
245 # api-centos-7-master-py3: {extends: .test_instance}
246 # api-centos-7-3003-1-py3: {extends: .test_instance}
247 # api-centos-7-3002-6-py3: {extends: .test_instance}
248 # api-centos-7-3001-7-py3: {extends: .test_instance}
249 # api-centos-7-3000-9-py3: {extends: .test_instance}
250
251 ###############################################################################
252 # `release` stage: `semantic-release`
253 ###############################################################################
254 semantic-release:
255   only: *only_branch_main_parent_repo
256   stage: *stage_release
257   image: *image_semanticrelease
258   variables:
259     MAINTAINER_TOKEN: '${GH_TOKEN}'
260   script:
261     # Update `AUTHORS.md`
262     - '${HOME}/go/bin/maintainer contributor'
263     # Run `semantic-release`
264     - 'semantic-release'