Skip to content
Snippets Groups Projects
Select Git revision
  • master default
  • v0.52.5
  • v0.52.4
  • v0.52.3
  • v0.52.2
  • v0.52.1
  • v0.52.0
  • v0.51.0
  • v0.50.0
  • v0.49.0
10 results

.gitlab-ci.yml

Blame
  • .gitlab-ci.yml 10.54 KiB
    # -*- coding: utf-8 -*-
    # vim: ft=yaml
    ---
    ###############################################################################
    # Define all YAML node anchors
    ###############################################################################
    .node_anchors:
      # `only` (also used for `except` where applicable)
      only_branch_master_parent_repo: &only_branch_master_parent_repo
        - 'master@saltstack-formulas/mysql-formula'
      # `stage`
      stage_lint: &stage_lint 'lint'
      stage_release: &stage_release 'release'
      stage_test: &stage_test 'test'
      # `image`
      image_commitlint: &image_commitlint 'myii/ssf-commitlint:11'
      image_dindruby: &image_dindruby 'myii/ssf-dind-ruby:2.7.1-r3'
      image_precommit: &image_precommit
        name: 'myii/ssf-pre-commit:2.9.2'
        entrypoint: ['/bin/bash', '-c']
      image_rubocop: &image_rubocop 'pipelinecomponents/rubocop:latest'
      image_semantic-release: &image_semanticrelease 'myii/ssf-semantic-release:15.14'
      # `services`
      services_docker_dind: &services_docker_dind
        - 'docker:dind'
      # `variables`
      # https://forum.gitlab.com/t/gitlab-com-ci-caching-rubygems/5627/3
      # https://bundler.io/v1.16/bundle_config.html
      variables_bundler: &variables_bundler
        BUNDLE_CACHE_PATH: '${CI_PROJECT_DIR}/.cache/bundler'
        BUNDLE_WITHOUT: 'production'
      # `cache`
      cache_bundler: &cache_bundler
        key: '${CI_JOB_STAGE}'
        paths:
          - '${BUNDLE_CACHE_PATH}'
    
    ###############################################################################
    # Define stages and global variables
    ###############################################################################
    stages:
      - *stage_lint
      - *stage_test
      - *stage_release
    variables:
      DOCKER_DRIVER: 'overlay2'
    
    ###############################################################################
    # `lint` stage: `commitlint`, `pre-commit` & `rubocop` (latest, failure allowed)
    ###############################################################################
    commitlint:
      stage: *stage_lint
      image: *image_commitlint
      script:
        # Add `upstream` remote to get access to `upstream/master`
        - 'git remote add upstream
           https://gitlab.com/saltstack-formulas/mysql-formula.git'
        - 'git fetch --all'
        # Set default commit hashes for `--from` and `--to`
        - 'export COMMITLINT_FROM="$(git merge-base upstream/master HEAD)"'
        - 'export COMMITLINT_TO="${CI_COMMIT_SHA}"'
        # `coqbot` adds a merge commit to test PRs on top of the latest commit in
        # the repo; amend this merge commit message to avoid failure
        - |
          if [ "${GITLAB_USER_LOGIN}" = "coqbot" ] \
          && [ "${CI_COMMIT_BRANCH}" != "master" ]; then
            git commit --amend -m \
              'chore: reword coqbot merge commit message for commitlint'
            export COMMITLINT_TO=HEAD
          fi