Skip to content

Commit ab48dcd

Browse files
committed
ci(gitlab-ci): use GitLab CI as Travis CI replacement
* Automated using myii/ssf-formula#275
1 parent 943ca5e commit ab48dcd

File tree

13 files changed

+333
-279
lines changed

13 files changed

+333
-279
lines changed

.gitlab-ci.yml

Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
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/docker-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_semantic-release: &image_semanticrelease 'myii/ssf-semantic-release:15.14'
22+
# `services`
23+
services_docker_dind: &services_docker_dind
24+
- 'docker:dind'
25+
# `variables`
26+
# https://forum.gitlab.com/t/gitlab-com-ci-caching-rubygems/5627/3
27+
# https://bundler.io/v1.16/bundle_config.html
28+
variables_bundler: &variables_bundler
29+
BUNDLE_CACHE_PATH: '${CI_PROJECT_DIR}/.cache/bundler'
30+
BUNDLE_WITHOUT: 'production'
31+
# `cache`
32+
cache_bundler: &cache_bundler
33+
key: '${CI_JOB_STAGE}'
34+
paths:
35+
- '${BUNDLE_CACHE_PATH}'
36+
37+
###############################################################################
38+
# Define stages and global variables
39+
###############################################################################
40+
stages:
41+
- *stage_lint
42+
- *stage_test
43+
- *stage_release
44+
variables:
45+
DOCKER_DRIVER: 'overlay2'
46+
47+
###############################################################################
48+
# `lint` stage: `commitlint` & `pre-commit`
49+
###############################################################################
50+
commitlint:
51+
stage: *stage_lint
52+
image: *image_commitlint
53+
script:
54+
# Add `upstream` remote to get access to `upstream/master`
55+
- 'git remote add upstream ${CI_PROJECT_URL}.git'
56+
- 'git fetch --all'
57+
# Set default commit hashes for `--from` and `--to`
58+
- 'export COMMITLINT_FROM="$(git merge-base upstream/master HEAD)"'
59+
- 'export COMMITLINT_TO="${CI_COMMIT_SHA}"'
60+
# `coqbot` adds a merge commit to test PRs on top of the latest commit in
61+
# the repo; amend this merge commit message to avoid failure
62+
- |
63+
if [ "${GITLAB_USER_LOGIN}" = "coqbot" ] \
64+
&& [ "${CI_COMMIT_BRANCH}" != "master" ]; then
65+
git commit --amend -m \
66+
'chore: reword coqbot merge commit message for commitlint'
67+
export COMMITLINT_TO=HEAD
68+
fi
69+
# Run `commitlint`
70+
- 'commitlint --from "${COMMITLINT_FROM}"
71+
--to "${COMMITLINT_TO}"
72+
--verbose'
73+
74+
pre-commit:
75+
stage: *stage_lint
76+
image: *image_precommit
77+
# https://pre-commit.com/#gitlab-ci-example
78+
variables:
79+
PRE_COMMIT_HOME: '${CI_PROJECT_DIR}/.cache/pre-commit'
80+
cache:
81+
key: '${CI_JOB_NAME}'
82+
paths:
83+
- '${PRE_COMMIT_HOME}'
84+
script:
85+
- 'pre-commit run --all-files --color always --verbose'
86+
87+
###############################################################################
88+
# Define `test` template
89+
###############################################################################
90+
.test_instance:
91+
stage: *stage_test
92+
image: *image_dindruby
93+
services: *services_docker_dind
94+
variables: *variables_bundler
95+
cache: *cache_bundler
96+
before_script:
97+
# TODO: This should work from the env vars above automatically
98+
- 'bundle config set path "${BUNDLE_CACHE_PATH}"'
99+
- 'bundle config set without "${BUNDLE_WITHOUT}"'
100+
- 'bundle install'
101+
script:
102+
# Alternative value to consider: `${CI_JOB_NAME}`
103+
- 'bin/kitchen verify "${DOCKER_ENV_CI_JOB_NAME}"'
104+
105+
###############################################################################
106+
# `test` stage: each instance below uses the `test` template above
107+
###############################################################################
108+
## Define the rest of the matrix based on Kitchen testing
109+
# Make sure the instances listed below match up with
110+
# the `platforms` defined in `kitchen.yml`
111+
# archive-debian-10-master-py3: {extends: '.test_instance'}
112+
# package-debian-10-master-py3: {extends: '.test_instance'}
113+
# clean-debian-10-master-py3: {extends: '.test_instance'}
114+
# archive-ubuntu-1804-master-py3: {extends: '.test_instance'}
115+
# package-ubuntu-1804-master-py3: {extends: '.test_instance'}
116+
# clean-ubuntu-1804-master-py3: {extends: '.test_instance'}
117+
# archive-centos-8-master-py3: {extends: '.test_instance'}
118+
# package-centos-8-master-py3: {extends: '.test_instance'}
119+
# clean-centos-8-master-py3: {extends: '.test_instance'}
120+
# archive-fedora-31-master-py3: {extends: '.test_instance'}
121+
# package-fedora-31-master-py3: {extends: '.test_instance'}
122+
# clean-fedora-31-master-py3: {extends: '.test_instance'}
123+
# archive-opensuse-leap-151-master-py3: {extends: '.test_instance'}
124+
# package-opensuse-leap-151-master-py3: {extends: '.test_instance'}
125+
# clean-opensuse-leap-151-master-py3: {extends: '.test_instance'}
126+
# archive-amazonlinux-2-master-py3: {extends: '.test_instance'}
127+
# package-amazonlinux-2-master-py3: {extends: '.test_instance'}
128+
# clean-amazonlinux-2-master-py3: {extends: '.test_instance'}
129+
# archive-debian-10-2019-2-py3: {extends: '.test_instance'}
130+
# package-debian-10-2019-2-py3: {extends: '.test_instance'}
131+
# clean-debian-10-2019-2-py3: {extends: '.test_instance'}
132+
# archive-debian-9-2019-2-py3: {extends: '.test_instance'}
133+
# package-debian-9-2019-2-py3: {extends: '.test_instance'}
134+
# clean-debian-9-2019-2-py3: {extends: '.test_instance'}
135+
# archive-ubuntu-1804-2019-2-py3: {extends: '.test_instance'}
136+
# package-ubuntu-1804-2019-2-py3: {extends: '.test_instance'}
137+
# clean-ubuntu-1804-2019-2-py3: {extends: '.test_instance'}
138+
# archive-centos-8-2019-2-py3: {extends: '.test_instance'}
139+
# package-centos-8-2019-2-py3: {extends: '.test_instance'}
140+
# clean-centos-8-2019-2-py3: {extends: '.test_instance'}
141+
# archive-fedora-31-2019-2-py3: {extends: '.test_instance'}
142+
# package-fedora-31-2019-2-py3: {extends: '.test_instance'}
143+
# clean-fedora-31-2019-2-py3: {extends: '.test_instance'}
144+
# archive-opensuse-leap-151-2019-2-py3: {extends: '.test_instance'}
145+
# package-opensuse-leap-151-2019-2-py3: {extends: '.test_instance'}
146+
# clean-opensuse-leap-151-2019-2-py3: {extends: '.test_instance'}
147+
# archive-centos-7-2019-2-py2: {extends: '.test_instance'}
148+
# package-centos-7-2019-2-py2: {extends: '.test_instance'}
149+
# clean-centos-7-2019-2-py2: {extends: '.test_instance'}
150+
# archive-amazonlinux-2-2019-2-py3: {extends: '.test_instance'}
151+
# package-amazonlinux-2-2019-2-py3: {extends: '.test_instance'}
152+
# clean-amazonlinux-2-2019-2-py3: {extends: '.test_instance'}
153+
# archive-arch-base-latest-2019-2-py2: {extends: '.test_instance'}
154+
# package-arch-base-latest-2019-2-py2: {extends: '.test_instance'}
155+
# clean-arch-base-latest-2019-2-py2: {extends: '.test_instance'}
156+
# archive-fedora-30-2018-3-py3: {extends: '.test_instance'}
157+
# package-fedora-30-2018-3-py3: {extends: '.test_instance'}
158+
# clean-fedora-30-2018-3-py3: {extends: '.test_instance'}
159+
# archive-debian-9-2018-3-py2: {extends: '.test_instance'}
160+
# package-debian-9-2018-3-py2: {extends: '.test_instance'}
161+
# clean-debian-9-2018-3-py2: {extends: '.test_instance'}
162+
# archive-ubuntu-1604-2018-3-py2: {extends: '.test_instance'}
163+
# package-ubuntu-1604-2018-3-py2: {extends: '.test_instance'}
164+
# clean-ubuntu-1604-2018-3-py2: {extends: '.test_instance'}
165+
# archive-centos-7-2018-3-py2: {extends: '.test_instance'}
166+
# package-centos-7-2018-3-py2: {extends: '.test_instance'}
167+
# clean-centos-7-2018-3-py2: {extends: '.test_instance'}
168+
# archive-opensuse-leap-151-2018-3-py2: {extends: '.test_instance'}
169+
# package-opensuse-leap-151-2018-3-py2: {extends: '.test_instance'}
170+
# clean-opensuse-leap-151-2018-3-py2: {extends: '.test_instance'}
171+
# archive-amazonlinux-1-2018-3-py2: {extends: '.test_instance'}
172+
# package-amazonlinux-1-2018-3-py2: {extends: '.test_instance'}
173+
# clean-amazonlinux-1-2018-3-py2: {extends: '.test_instance'}
174+
# archive-arch-base-latest-2018-3-py2: {extends: '.test_instance'}
175+
# package-arch-base-latest-2018-3-py2: {extends: '.test_instance'}
176+
# clean-arch-base-latest-2018-3-py2: {extends: '.test_instance'}
177+
# archive-debian-8-2017-7-py2: {extends: '.test_instance'}
178+
# package-debian-8-2017-7-py2: {extends: '.test_instance'}
179+
# clean-debian-8-2017-7-py2: {extends: '.test_instance'}
180+
# archive-ubuntu-1604-2017-7-py2: {extends: '.test_instance'}
181+
# package-ubuntu-1604-2017-7-py2: {extends: '.test_instance'}
182+
# clean-ubuntu-1604-2017-7-py2: {extends: '.test_instance'}
183+
# archive-centos-6-2017-7-py2: {extends: '.test_instance'}
184+
# package-centos-6-2017-7-py2: {extends: '.test_instance'}
185+
# clean-centos-6-2017-7-py2: {extends: '.test_instance'}
186+
# archive-fedora-30-2017-7-py2: {extends: '.test_instance'}
187+
# package-fedora-30-2017-7-py2: {extends: '.test_instance'}
188+
# clean-fedora-30-2017-7-py2: {extends: '.test_instance'}
189+
# archive-opensuse-leap-151-2017-7-py2: {extends: '.test_instance'}
190+
# package-opensuse-leap-151-2017-7-py2: {extends: '.test_instance'}
191+
# clean-opensuse-leap-151-2017-7-py2: {extends: '.test_instance'}
192+
# archive-amazonlinux-1-2017-7-py2: {extends: '.test_instance'}
193+
# package-amazonlinux-1-2017-7-py2: {extends: '.test_instance'}
194+
# clean-amazonlinux-1-2017-7-py2: {extends: '.test_instance'}
195+
# archive-arch-base-latest-2017-7-py2: {extends: '.test_instance'}
196+
# package-arch-base-latest-2017-7-py2: {extends: '.test_instance'}
197+
# clean-arch-base-latest-2017-7-py2: {extends: '.test_instance'}
198+
199+
###############################################################################
200+
# `release` stage: `semantic-release`
201+
###############################################################################
202+
semantic-release:
203+
only: *only_branch_master_parent_repo
204+
stage: *stage_release
205+
image: *image_semanticrelease
206+
variables:
207+
MAINTAINER_TOKEN: '${GH_TOKEN}'
208+
script:
209+
# Update `AUTHORS.md`
210+
- '${HOME}/go/bin/maintainer contributor'
211+
# Run `semantic-release`
212+
- 'semantic-release'

.travis.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
# -*- coding: utf-8 -*-
22
# vim: ft=yaml
33
---
4+
################################################################################
5+
# NOTE: This file is UNMAINTAINED; it is provided for references purposes only.
6+
# No guarantees are tendered that this structure will work after 2020.
7+
################################################################################
8+
# * https://en.wikipedia.org/wiki/Travis_CI:
9+
# - "... free open-source plans were removed in [sic] the end of 2020"
10+
# - https://blog.travis-ci.com/2020-11-02-travis-ci-new-billing
11+
# - https://ropensci.org/technotes/2020/11/19/moving-away-travis/
12+
################################################################################
413
## Machine config
514
os: 'linux'
615
arch: 'amd64'
@@ -32,8 +41,10 @@ script:
3241
## Stages and jobs matrix
3342
stages:
3443
- test
35-
- name: 'release'
36-
if: 'branch = master AND type != pull_request'
44+
# # As part of the switch away from Travis CI, ensure that the `release` stage
45+
# # is not run inadvertently
46+
# - name: 'release'
47+
# if: 'branch = master AND type != pull_request'
3748
jobs:
3849
include:
3950
## Define the test stage that runs the linters (and testing matrix, if applicable)

.yamllint

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ extends: default
99
# 2. Any SLS files under directory `test/`, which are actually state files
1010
# 3. Any YAML files under directory `.kitchen/`, introduced during local testing
1111
ignore: |
12+
.cache/
1213
node_modules/
1314
test/**/states/**/*.sls
1415
.kitchen/

CODEOWNERS

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@
1919
/docs/AUTHORS.rst @saltstack-formulas/ssf
2020
/docs/CHANGELOG.rst @saltstack-formulas/ssf
2121
/docs/TOFS_pattern.rst @saltstack-formulas/ssf
22-
/docker/libsaltcli.jinja @saltstack-formulas/ssf
23-
/docker/libtofs.jinja @saltstack-formulas/ssf
22+
/*/libsaltcli.jinja @saltstack-formulas/ssf
23+
/*/libtofs.jinja @saltstack-formulas/ssf
2424
/test/integration/**/inspec.yml @saltstack-formulas/ssf
2525
/test/integration/**/README.md @saltstack-formulas/ssf
2626
/.gitignore @saltstack-formulas/ssf
2727
/.cirrus.yml @saltstack-formulas/ssf
28+
/.gitlab-ci.yml @saltstack-formulas/ssf
2829
/.pre-commit-config.yaml @saltstack-formulas/ssf
2930
/.rstcheck.cfg @saltstack-formulas/ssf
3031
/.rubocop.yml @saltstack-formulas/ssf

0 commit comments

Comments
 (0)