2d6bc2dc7073a578f224d22059d29fbf0ece4253
[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.3-py3: {extends: .test_instance}
134 # workbench-ubuntu-2004-3002.7-py3: {extends: .test_instance}
135 # workbench-ubuntu-2004-3001.8-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.3-py3: {extends: .test_instance}
139 # workbench-ubuntu-1804-3002.7-py3: {extends: .test_instance}
140 # workbench-ubuntu-1804-3001.8-py3: {extends: .test_instance}
141 # workbench-debian-11-tiamat-py3: {extends: .test_instance}
142 # workbench-debian-11-master-py3: {extends: .test_instance}
143 workbench-debian-11-3003.3-py3: {extends: .test_instance}
144 # workbench-debian-11-3002.7-py3: {extends: .test_instance}
145 # workbench-debian-10-tiamat-py3: {extends: .test_instance}
146 # workbench-debian-10-master-py3: {extends: .test_instance}
147 # workbench-debian-10-3003.3-py3: {extends: .test_instance}
148 workbench-debian-10-3002.7-py3: {extends: .test_instance}
149 # workbench-debian-10-3001.8-py3: {extends: .test_instance}
150 # workbench-centos-7-tiamat-py3: {extends: .test_instance}
151 # workbench-centos-7-master-py3: {extends: .test_instance}
152 # workbench-centos-7-3003.3-py3: {extends: .test_instance}
153 # workbench-centos-7-3002.7-py3: {extends: .test_instance}
154 workbench-centos-7-3001.8-py3: {extends: .test_instance}
155
156 # shell-ubuntu-2004-tiamat-py3: {extends: .test_instance}
157 shell-ubuntu-2004-master-py3: {extends: .test_instance}
158 # shell-ubuntu-2004-3003.3-py3: {extends: .test_instance}
159 # shell-ubuntu-2004-3002.7-py3: {extends: .test_instance}
160 # shell-ubuntu-2004-3001.8-py3: {extends: .test_instance}
161 # shell-ubuntu-1804-tiamat-py3: {extends: .test_instance}
162 # shell-ubuntu-1804-master-py3: {extends: .test_instance}
163 shell-ubuntu-1804-3003.3-py3: {extends: .test_instance}
164 # shell-ubuntu-1804-3002.7-py3: {extends: .test_instance}
165 # shell-ubuntu-1804-3001.8-py3: {extends: .test_instance}
166 # shell-debian-11-tiamat-py3: {extends: .test_instance}
167 # shell-debian-11-master-py3: {extends: .test_instance}
168 # shell-debian-11-3003.3-py3: {extends: .test_instance}
169 shell-debian-11-3002.7-py3: {extends: .test_instance}
170 # shell-debian-10-tiamat-py3: {extends: .test_instance}
171 # shell-debian-10-master-py3: {extends: .test_instance}
172 # shell-debian-10-3003.3-py3: {extends: .test_instance}
173 # shell-debian-10-3002.7-py3: {extends: .test_instance}
174 shell-debian-10-3001.8-py3: {extends: .test_instance}
175 shell-centos-7-tiamat-py3: {extends: .test_instance}
176 # shell-centos-7-master-py3: {extends: .test_instance}
177 # shell-centos-7-3003.3-py3: {extends: .test_instance}
178 # shell-centos-7-3002.7-py3: {extends: .test_instance}
179 # shell-centos-7-3001.8-py3: {extends: .test_instance}
180
181 # keepstore-ubuntu-2004-tiamat-py3: {extends: .test_instance}
182 # keepstore-ubuntu-2004-master-py3: {extends: .test_instance}
183 keepstore-ubuntu-2004-3003.3-py3: {extends: .test_instance}
184 # keepstore-ubuntu-2004-3002.7-py3: {extends: .test_instance}
185 # keepstore-ubuntu-2004-3001.8-py3: {extends: .test_instance}
186 # keepstore-ubuntu-1804-tiamat-py3: {extends: .test_instance}
187 # keepstore-ubuntu-1804-master-py3: {extends: .test_instance}
188 # keepstore-ubuntu-1804-3003.3-py3: {extends: .test_instance}
189 keepstore-ubuntu-1804-3002.7-py3: {extends: .test_instance}
190 # keepstore-ubuntu-1804-3001.8-py3: {extends: .test_instance}
191 keepstore-debian-11-tiamat-py3: {extends: .test_instance}
192 # keepstore-debian-11-master-py3: {extends: .test_instance}
193 # keepstore-debian-11-3003.3-py3: {extends: .test_instance}
194 # keepstore-debian-11-3002.7-py3: {extends: .test_instance}
195 # keepstore-debian-10-tiamat-py3: {extends: .test_instance}
196 # keepstore-debian-10-master-py3: {extends: .test_instance}
197 # keepstore-debian-10-3003.3-py3: {extends: .test_instance}
198 # keepstore-debian-10-3002.7-py3: {extends: .test_instance}
199 keepstore-debian-10-3001.8-py3: {extends: .test_instance}
200 # keepstore-centos-7-tiamat-py3: {extends: .test_instance}
201 # keepstore-centos-7-master-py3: {extends: .test_instance}
202 # keepstore-centos-7-3003.3-py3: {extends: .test_instance}
203 # keepstore-centos-7-3002.7-py3: {extends: .test_instance}
204 # keepstore-centos-7-3001.8-py3: {extends: .test_instance}
205
206 # api-ubuntu-2004-tiamat-py3: {extends: .test_instance}
207 # api-ubuntu-2004-master-py3: {extends: .test_instance}
208 # api-ubuntu-2004-3003.3-py3: {extends: .test_instance}
209 api-ubuntu-2004-3002.7-py3: {extends: .test_instance}
210 # api-ubuntu-2004-3001.8-py3: {extends: .test_instance}
211 # api-ubuntu-1804-tiamat-py3: {extends: .test_instance}
212 # api-ubuntu-1804-master-py3: {extends: .test_instance}
213 # api-ubuntu-1804-3003.3-py3: {extends: .test_instance}
214 # api-ubuntu-1804-3002.7-py3: {extends: .test_instance}
215 api-ubuntu-1804-3001.8-py3: {extends: .test_instance}
216 # api-debian-11-tiamat-py3: {extends: .test_instance}
217 # api-debian-11-master-py3: {extends: .test_instance}
218 api-debian-11-3003.3-py3: {extends: .test_instance}
219 # api-debian-11-3002.7-py3: {extends: .test_instance}
220 # api-debian-10-tiamat-py3: {extends: .test_instance}
221 # api-debian-10-master-py3: {extends: .test_instance}
222 # api-debian-10-3003.3-py3: {extends: .test_instance}
223 # api-debian-10-3002.7-py3: {extends: .test_instance}
224 # api-debian-10-3001.8-py3: {extends: .test_instance}
225 api-centos-7-tiamat-py3: {extends: .test_instance}
226 # api-centos-7-master-py3: {extends: .test_instance}
227 # api-centos-7-3003.3-py3: {extends: .test_instance}
228 # api-centos-7-3002.7-py3: {extends: .test_instance}
229 # api-centos-7-3001.8-py3: {extends: .test_instance}
230
231 ###############################################################################
232 # `release` stage: `semantic-release`
233 ###############################################################################
234 semantic-release:
235   only: *only_branch_main_parent_repo
236   stage: *stage_release
237   image: *image_semanticrelease
238   variables:
239     MAINTAINER_TOKEN: '${GH_TOKEN}'
240   script:
241     # Update `AUTHORS.md`
242     - '${HOME}/go/bin/maintainer contributor'
243     # Run `semantic-release`
244     - 'semantic-release'