17750: Ensure the arvados-cli gem is available in controller when creating resources
[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_master_parent_repo: &only_branch_master_parent_repo
10     - 'master@saltstack-formulas/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 commitlint:
52   stage: *stage_lint
53   image: *image_commitlint
54   script:
55     # Add `upstream` remote to get access to `upstream/master`
56     - 'git remote add upstream
57        https://gitlab.com/saltstack-formulas/arvados-formula.git'
58     - 'git fetch --all'
59     # Set default commit hashes for `--from` and `--to`
60     - 'export COMMITLINT_FROM="$(git merge-base upstream/master HEAD)"'
61     - 'export COMMITLINT_TO="${CI_COMMIT_SHA}"'
62     # `coqbot` adds a merge commit to test PRs on top of the latest commit in
63     # the repo; amend this merge commit message to avoid failure
64     - |
65       if [ "${GITLAB_USER_LOGIN}" = "coqbot" ] \
66       && [ "${CI_COMMIT_BRANCH}" != "master" ]; then
67         git commit --amend -m \
68           'chore: reword coqbot merge commit message for commitlint'
69         export COMMITLINT_TO=HEAD
70       fi
71     # Run `commitlint`
72     - 'commitlint --from "${COMMITLINT_FROM}"
73                   --to   "${COMMITLINT_TO}"
74                   --verbose'
75
76 pre-commit:
77   stage: *stage_lint
78   image: *image_precommit
79   # https://pre-commit.com/#gitlab-ci-example
80   variables:
81     PRE_COMMIT_HOME: '${CI_PROJECT_DIR}/.cache/pre-commit'
82   cache:
83     key: '${CI_JOB_NAME}'
84     paths:
85       - '${PRE_COMMIT_HOME}'
86   script:
87     - 'pre-commit run --all-files --color always --verbose'
88
89 # Use a separate job for `rubocop` other than the one potentially run by `pre-commit`
90 # - The `pre-commit` check will only be available for formulas that pass the default
91 #   `rubocop` check -- and must continue to do so
92 # - This job is allowed to fail, so can be used for all formulas
93 # - Furthermore, this job uses all of the latest `rubocop` features & cops,
94 #   which will help when upgrading the `rubocop` linter used in `pre-commit`
95 rubocop:
96   allow_failure: true
97   stage: *stage_lint
98   image: *image_rubocop
99   script:
100     - 'rubocop -d -P -S --enable-pending-cops'
101
102 ###############################################################################
103 # Define `test` template
104 ###############################################################################
105 .test_instance:
106   stage: *stage_test
107   image: *image_dindruby
108   services: *services_docker_dind
109   variables: *variables_bundler
110   cache: *cache_bundler
111   before_script:
112     # TODO: This should work from the env vars above automatically
113     - 'bundle config set path "${BUNDLE_CACHE_PATH}"'
114     - 'bundle config set without "${BUNDLE_WITHOUT}"'
115     - 'bundle install'
116   script:
117     # Alternative value to consider: `${CI_JOB_NAME}`
118     - 'bin/kitchen verify "${DOCKER_ENV_CI_JOB_NAME}"'
119
120 ###############################################################################
121 # `test` stage: each instance below uses the `test` template above
122 ###############################################################################
123 ## Define the rest of the matrix based on Kitchen testing
124 # Make sure the instances listed below match up with
125 # the `platforms` defined in `kitchen.yml`
126 # api-debian-10-tiamat-py3: {extends: '.test_instance'}
127 # api-debian-9-tiamat-py3: {extends: '.test_instance'}
128 # api-ubuntu-2004-tiamat-py3: {extends: '.test_instance'}
129 # api-ubuntu-1804-tiamat-py3: {extends: '.test_instance'}
130 # api-ubuntu-1604-tiamat-py3: {extends: '.test_instance'}
131 # api-centos-8-tiamat-py3: {extends: '.test_instance'}
132 # api-centos-7-tiamat-py3: {extends: '.test_instance'}
133 # api-amazonlinux-2-tiamat-py3: {extends: '.test_instance'}
134 # api-oraclelinux-8-tiamat-py3: {extends: '.test_instance'}
135 # api-oraclelinux-7-tiamat-py3: {extends: '.test_instance'}
136 api-debian-10-master-py3: {extends: '.test_instance'}
137 workbench-debian-10-master-py3: {extends: '.test_instance'}
138 # shell-debian-10-master-py3: {extends: '.test_instance'}
139 keepstore-debian-10-master-py3: {extends: '.test_instance'}
140 # api-debian-9-master-py3: {extends: '.test_instance'}
141 # workbench-debian-9-master-py3: {extends: '.test_instance'}
142 # shell-debian-9-master-py3: {extends: '.test_instance'}
143 # keepstore-debian-9-master-py3: {extends: '.test_instance'}
144 # api-ubuntu-2004-master-py3: {extends: '.test_instance'}
145 # workbench-ubuntu-2004-master-py3: {extends: '.test_instance'}
146 # shell-ubuntu-2004-master-py3: {extends: '.test_instance'}
147 # keepstore-ubuntu-2004-master-py3: {extends: '.test_instance'}
148 api-ubuntu-1804-master-py3: {extends: '.test_instance'}
149 workbench-ubuntu-1804-master-py3: {extends: '.test_instance'}
150 # shell-ubuntu-1804-master-py3: {extends: '.test_instance'}
151 # keepstore-ubuntu-1804-master-py3: {extends: '.test_instance'}
152 # api-ubuntu-1604-master-py3: {extends: '.test_instance'}
153 # workbench-ubuntu-1604-master-py3: {extends: '.test_instance'}
154 # shell-ubuntu-1604-master-py3: {extends: '.test_instance'}
155 # keepstore-ubuntu-1604-master-py3: {extends: '.test_instance'}
156 # api-centos-8-master-py3: {extends: '.test_instance'}
157 # workbench-centos-8-master-py3: {extends: '.test_instance'}
158 # shell-centos-8-master-py3: {extends: '.test_instance'}
159 # keepstore-centos-8-master-py3: {extends: '.test_instance'}
160 # api-centos-7-master-py3: {extends: '.test_instance'}
161 # workbench-centos-7-master-py3: {extends: '.test_instance'}
162 shell-centos-7-master-py3: {extends: '.test_instance'}
163 keepstore-centos-7-master-py3: {extends: '.test_instance'}
164 # api-amazonlinux-2-master-py3: {extends: '.test_instance'}
165 # workbench-amazonlinux-2-master-py3: {extends: '.test_instance'}
166 # shell-amazonlinux-2-master-py3: {extends: '.test_instance'}
167 # keepstore-amazonlinux-2-master-py3: {extends: '.test_instance'}
168 # api-oraclelinux-8-master-py3: {extends: '.test_instance'}
169 # workbench-oraclelinux-8-master-py3: {extends: '.test_instance'}
170 # shell-oraclelinux-8-master-py3: {extends: '.test_instance'}
171 # keepstore-oraclelinux-8-master-py3: {extends: '.test_instance'}
172 # api-oraclelinux-7-master-py3: {extends: '.test_instance'}
173 # workbench-oraclelinux-7-master-py3: {extends: '.test_instance'}
174 # shell-oraclelinux-7-master-py3: {extends: '.test_instance'}
175 # keepstore-oraclelinux-7-master-py3: {extends: '.test_instance'}
176 # api-debian-10-3003-0-py3: {extends: '.test_instance'}
177 # api-debian-9-3003-0-py3: {extends: '.test_instance'}
178 # api-ubuntu-2004-3003-0-py3: {extends: '.test_instance'}
179 # api-ubuntu-1804-3003-0-py3: {extends: '.test_instance'}
180 # api-centos-8-3003-0-py3: {extends: '.test_instance'}
181 # api-centos-7-3003-0-py3: {extends: '.test_instance'}
182 # api-amazonlinux-2-3003-0-py3: {extends: '.test_instance'}
183 # api-oraclelinux-8-3003-0-py3: {extends: '.test_instance'}
184 # api-oraclelinux-7-3003-0-py3: {extends: '.test_instance'}
185 # api-debian-10-3002-6-py3: {extends: '.test_instance'}
186 # api-debian-9-3002-6-py3: {extends: '.test_instance'}
187 # api-ubuntu-2004-3002-6-py3: {extends: '.test_instance'}
188 # api-ubuntu-1804-3002-6-py3: {extends: '.test_instance'}
189 # api-ubuntu-1604-3002-6-py3: {extends: '.test_instance'}
190 # api-centos-8-3002-6-py3: {extends: '.test_instance'}
191 # api-centos-7-3002-6-py3: {extends: '.test_instance'}
192 # api-amazonlinux-2-3002-6-py3: {extends: '.test_instance'}
193 # api-oraclelinux-8-3002-6-py3: {extends: '.test_instance'}
194 # api-oraclelinux-7-3002-6-py3: {extends: '.test_instance'}
195 # api-debian-10-3001-7-py3: {extends: '.test_instance'}
196 # api-debian-9-3001-7-py3: {extends: '.test_instance'}
197 # api-ubuntu-2004-3001-7-py3: {extends: '.test_instance'}
198 # api-ubuntu-1804-3001-7-py3: {extends: '.test_instance'}
199 # api-ubuntu-1604-3001-7-py3: {extends: '.test_instance'}
200 # api-centos-8-3001-7-py3: {extends: '.test_instance'}
201 # api-centos-7-3001-7-py3: {extends: '.test_instance'}
202 # api-amazonlinux-2-3001-7-py3: {extends: '.test_instance'}
203 # api-oraclelinux-8-3001-7-py3: {extends: '.test_instance'}
204 # api-oraclelinux-7-3001-7-py3: {extends: '.test_instance'}
205 # api-debian-10-3000-9-py3: {extends: '.test_instance'}
206 # api-debian-9-3000-9-py3: {extends: '.test_instance'}
207 # api-ubuntu-1804-3000-9-py3: {extends: '.test_instance'}
208 # api-ubuntu-1604-3000-9-py3: {extends: '.test_instance'}
209 # api-centos-8-3000-9-py3: {extends: '.test_instance'}
210 # api-centos-7-3000-9-py3: {extends: '.test_instance'}
211 # api-amazonlinux-2-3000-9-py3: {extends: '.test_instance'}
212 # api-oraclelinux-8-3000-9-py3: {extends: '.test_instance'}
213 # api-oraclelinux-7-3000-9-py3: {extends: '.test_instance'}
214 # api-ubuntu-1804-3000-9-py2: {extends: '.test_instance'}
215 # api-ubuntu-1604-3000-9-py2: {extends: '.test_instance'}
216
217 ###############################################################################
218 # `release` stage: `semantic-release`
219 ###############################################################################
220 semantic-release:
221   only: *only_branch_master_parent_repo
222   stage: *stage_release
223   image: *image_semanticrelease
224   variables:
225     MAINTAINER_TOKEN: '${GH_TOKEN}'
226   script:
227     # Update `AUTHORS.md`
228     - '${HOME}/go/bin/maintainer contributor'
229     # Run `semantic-release`
230     - 'semantic-release'