Commit 1a8e296f authored by Hordur Freyr Yngvason's avatar Hordur Freyr Yngvason
Browse files

ci: skip most jobs on 'docs:' commits

Since adding the test matrix, our CI has gotten heavy and more prone to
random failures due to network flakiness. This adds unnecessary friction
to docs-only contributions. Since we are using conventional commits,
these should be exactly the commits where the subject line starts with
'docs:'.
parent a79cdc11
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -25,3 +25,14 @@ include:
  - local: .gitlab/ci/test.gitlab-ci.yml
  - local: .gitlab/ci/release.gitlab-ci.yml
  - local: .gitlab/ci/chart.gitlab-ci.yml

# This complements the skip-if-docs-only rule to ensure that
# we are not skipping tests when code is *actually* changed.
assert-docs-only:
  image: alpine
  rules:
    - if: '$CI_COMMIT_MESSAGE =~ /\Adocs:/'
  before_script:
    - apk add git
  script:
    - git diff --name-only HEAD~1 | grep -v '.md$' && exit 1 || exit 0
+8 −0
Original line number Diff line number Diff line
.shared-rules:
  skip-if-docs-only: &skip-if-docs-only
    if: '$CI_COMMIT_MESSAGE =~ /\Adocs:/'
    when: never

build:
  stage: build
  image: docker:19.03.5
@@ -5,6 +10,9 @@ build:
    - docker:19.03.5-dind
  before_script:
    - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
  rules:
    - <<: *skip-if-docs-only
    - when: on_success
  script:
    - >-
       docker build
+9 −0
Original line number Diff line number Diff line
.shared-rules:
  skip-if-docs-only: &skip-if-docs-only
    if: '$CI_COMMIT_MESSAGE =~ /\Adocs:/'
    when: never

variables:
  SAST_DISABLE_DIND: "true"
  SCAN_KUBERNETES_MANIFESTS: "true"
@@ -11,6 +16,9 @@ stages:

.chart-job:
  image: "$BUILD_IMAGE_NAME"
  rules:
    - <<: *skip-if-docs-only
    - when: on_success
  before_script:
    - cd assets/auto-deploy-app

@@ -30,6 +38,7 @@ kubesec-sast:
    - helm dependency build .
  # we are using merge request pipelines, so we need to override the rules
  rules:
    - <<: *skip-if-docs-only
    - if: $SCAN_KUBERNETES_MANIFESTS == 'true'

chart:test:
+0 −1
Original line number Diff line number Diff line
@@ -4,7 +4,6 @@
#     See README.md for more information
#   * If there is a new release it will tag the repository with the new release as the `ops-gitlab-net`
#     user

.semantic-release:
  image: node:12
  stage: release
+11 −0
Original line number Diff line number Diff line
.shared-rules:
  skip-if-docs-only: &skip-if-docs-only
    if: '$CI_COMMIT_MESSAGE =~ /\Adocs:/'
    when: never

test-shellcheck:
  stage: test
  image: koalaman/shellcheck-alpine:stable
  needs: []
  rules:
    - <<: *skip-if-docs-only
    - when: on_success
  script:
    - shellcheck src/bin/auto-deploy test/verify-application-secret test/verify-deployment-database

@@ -10,5 +18,8 @@ test-shfmt:
  image:
    name: mvdan/shfmt:v3.2.1-alpine
  needs: []
  rules:
    - <<: *skip-if-docs-only
    - when: on_success
  script:
    - shfmt -i 2 -ci -l -d src/bin/auto-deploy test/verify-application-secret test/verify-deployment-database
Loading