|
| 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/php-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/php-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: &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 | +# Define `test` template (`allow_failure: true`) |
| 122 | +############################################################################### |
| 123 | +.test_instance_failure_permitted: |
| 124 | + <<: *test_instance |
| 125 | + allow_failure: true |
| 126 | + |
| 127 | +############################################################################### |
| 128 | +# `test` stage: each instance below uses the `test` template above |
| 129 | +############################################################################### |
| 130 | +## Define the rest of the matrix based on Kitchen testing |
| 131 | +# Make sure the instances listed below match up with |
| 132 | +# the `platforms` defined in `kitchen.yml` |
| 133 | +# yamllint disable rule:line-length |
| 134 | +# debian-debian-11-tiamat-py3: {extends: '.test_instance'} |
| 135 | +# debian-debian-10-tiamat-py3: {extends: '.test_instance'} |
| 136 | +# debian-debian-9-tiamat-py3: {extends: '.test_instance'} |
| 137 | +# ubuntu-ubuntu-2204-tiamat-py3: {extends: '.test_instance_failure_permitted'} |
| 138 | +# ubuntu-ubuntu-2004-tiamat-py3: {extends: '.test_instance'} |
| 139 | +# ubuntu-ubuntu-1804-tiamat-py3: {extends: '.test_instance'} |
| 140 | +# redhat-centos-stream8-tiamat-py3: {extends: '.test_instance_failure_permitted'} |
| 141 | +# redhat-centos-7-tiamat-py3: {extends: '.test_instance'} |
| 142 | +# redhat-amazonlinux-2-tiamat-py3: {extends: '.test_instance'} |
| 143 | +# redhat-oraclelinux-8-tiamat-py3: {extends: '.test_instance'} |
| 144 | +# redhat-oraclelinux-7-tiamat-py3: {extends: '.test_instance'} |
| 145 | +# redhat-almalinux-8-tiamat-py3: {extends: '.test_instance'} |
| 146 | +# redhat-rockylinux-8-tiamat-py3: {extends: '.test_instance'} |
| 147 | +debian-debian-11-master-py3: {extends: '.test_instance'} |
| 148 | +debian-debian-10-master-py3: {extends: '.test_instance'} |
| 149 | +debian-debian-9-master-py3: {extends: '.test_instance'} |
| 150 | +ubuntu-ubuntu-2204-master-py3: {extends: '.test_instance_failure_permitted'} |
| 151 | +ubuntu-ubuntu-2004-master-py3: {extends: '.test_instance'} |
| 152 | +ubuntu-ubuntu-1804-master-py3: {extends: '.test_instance'} |
| 153 | +redhat-centos-stream8-master-py3: {extends: '.test_instance_failure_permitted'} |
| 154 | +redhat-centos-7-master-py3: {extends: '.test_instance'} |
| 155 | +redhat-fedora-36-master-py3: {extends: '.test_instance_failure_permitted'} |
| 156 | +redhat-fedora-35-master-py3: {extends: '.test_instance'} |
| 157 | +suse-opensuse-leap-153-master-py3: {extends: '.test_instance'} |
| 158 | +suse-opensuse-tmbl-latest-master-py3: {extends: '.test_instance_failure_permitted'} |
| 159 | +redhat-amazonlinux-2-master-py3: {extends: '.test_instance'} |
| 160 | +redhat-oraclelinux-8-master-py3: {extends: '.test_instance'} |
| 161 | +redhat-oraclelinux-7-master-py3: {extends: '.test_instance'} |
| 162 | +redhat-almalinux-8-master-py3: {extends: '.test_instance'} |
| 163 | +redhat-rockylinux-8-master-py3: {extends: '.test_instance'} |
| 164 | +# debian-debian-11-3004-1-py3: {extends: '.test_instance'} |
| 165 | +# debian-debian-10-3004-1-py3: {extends: '.test_instance'} |
| 166 | +# debian-debian-9-3004-1-py3: {extends: '.test_instance'} |
| 167 | +# ubuntu-ubuntu-2204-3004-1-py3: {extends: '.test_instance_failure_permitted'} |
| 168 | +# ubuntu-ubuntu-2004-3004-1-py3: {extends: '.test_instance'} |
| 169 | +# ubuntu-ubuntu-1804-3004-1-py3: {extends: '.test_instance'} |
| 170 | +# redhat-centos-stream8-3004-1-py3: {extends: '.test_instance_failure_permitted'} |
| 171 | +# redhat-centos-7-3004-1-py3: {extends: '.test_instance'} |
| 172 | +# redhat-fedora-36-3004-1-py3: {extends: '.test_instance_failure_permitted'} |
| 173 | +# redhat-fedora-35-3004-1-py3: {extends: '.test_instance'} |
| 174 | +# redhat-amazonlinux-2-3004-1-py3: {extends: '.test_instance'} |
| 175 | +# redhat-oraclelinux-8-3004-1-py3: {extends: '.test_instance'} |
| 176 | +# redhat-oraclelinux-7-3004-1-py3: {extends: '.test_instance'} |
| 177 | +# redhat-almalinux-8-3004-1-py3: {extends: '.test_instance'} |
| 178 | +# redhat-rockylinux-8-3004-1-py3: {extends: '.test_instance'} |
| 179 | +# suse-opensuse-leap-153-3004-0-py3: {extends: '.test_instance'} |
| 180 | +# suse-opensuse-tmbl-latest-3004-0-py3: {extends: '.test_instance_failure_permitted'} |
| 181 | +# debian-debian-10-3003-4-py3: {extends: '.test_instance'} |
| 182 | +# debian-debian-9-3003-4-py3: {extends: '.test_instance'} |
| 183 | +# ubuntu-ubuntu-2004-3003-4-py3: {extends: '.test_instance'} |
| 184 | +# ubuntu-ubuntu-1804-3003-4-py3: {extends: '.test_instance'} |
| 185 | +# redhat-centos-stream8-3003-4-py3: {extends: '.test_instance_failure_permitted'} |
| 186 | +# redhat-centos-7-3003-4-py3: {extends: '.test_instance'} |
| 187 | +# redhat-amazonlinux-2-3003-4-py3: {extends: '.test_instance'} |
| 188 | +# redhat-oraclelinux-8-3003-4-py3: {extends: '.test_instance'} |
| 189 | +# redhat-oraclelinux-7-3003-4-py3: {extends: '.test_instance'} |
| 190 | +# redhat-almalinux-8-3003-4-py3: {extends: '.test_instance'} |
| 191 | +# yamllint enable rule:line-length |
| 192 | + |
| 193 | +############################################################################### |
| 194 | +# `release` stage: `semantic-release` |
| 195 | +############################################################################### |
| 196 | +semantic-release: |
| 197 | + only: *only_branch_master_parent_repo |
| 198 | + stage: *stage_release |
| 199 | + image: *image_semanticrelease |
| 200 | + variables: |
| 201 | + MAINTAINER_TOKEN: '${GH_TOKEN}' |
| 202 | + script: |
| 203 | + # Update `AUTHORS.md` |
| 204 | + - '${HOME}/go/bin/maintainer contributor' |
| 205 | + # Run `semantic-release` |
| 206 | + - 'semantic-release' |
0 commit comments