Skip to content
Snippets Groups Projects
Unverified Commit febf1dc8 authored by Timo Furrer's avatar Timo Furrer
Browse files

Introduce pipeline rules for state cleaner optimization

parent 839a6cf8
No related branches found
No related tags found
No related merge requests found
...@@ -5,12 +5,17 @@ workflow: ...@@ -5,12 +5,17 @@ workflow:
- if: $CI_COMMIT_TAG - if: $CI_COMMIT_TAG
- if: $CI_COMMIT_REF_PROTECTED == "true" - if: $CI_COMMIT_REF_PROTECTED == "true"
.rule:skip-when-state-cleaner: &rule_skip_when_state_cleaner
- if: '$CI_PIPELINE_SOURCE == "schedule" && $CI_PIPELINE_SCHEDULE_DESCRIPTION == "state cleaner"'
when: never
include: include:
- local: opentofu_versions.yaml - local: opentofu_versions.yaml
- local: tests/unit.gitlab-ci.yml - local: tests/unit.gitlab-ci.yml
rules: rules:
- if: $SKIP_TESTS == "true" - if: $SKIP_TESTS == "true"
when: never when: never
- *rule_skip_when_state_cleaner
- changes: - changes:
- src/gitlab-tofu.sh - src/gitlab-tofu.sh
- opentofu_versions.yaml - opentofu_versions.yaml
...@@ -24,6 +29,7 @@ include: ...@@ -24,6 +29,7 @@ include:
rules: rules:
- if: $SKIP_TESTS == "true" - if: $SKIP_TESTS == "true"
when: never when: never
- *rule_skip_when_state_cleaner
- changes: - changes:
- src/gitlab-tofu.sh - src/gitlab-tofu.sh
- opentofu_versions.yaml - opentofu_versions.yaml
...@@ -110,6 +116,7 @@ variables: ...@@ -110,6 +116,7 @@ variables:
check-semantic-version: check-semantic-version:
stage: .pre stage: .pre
rules: rules:
- *rule_skip_when_state_cleaner
- if: $CI_COMMIT_TAG - if: $CI_COMMIT_TAG
image: alpine:3.21.2 image: alpine:3.21.2
before_script: before_script:
...@@ -118,6 +125,7 @@ check-semantic-version: ...@@ -118,6 +125,7 @@ check-semantic-version:
- echo -n "$CI_COMMIT_TAG" | ./.gitlab/scripts/check-semantic-version.sh - echo -n "$CI_COMMIT_TAG" | ./.gitlab/scripts/check-semantic-version.sh
.gitlab-opentofu-image:build:base:rules: &gitlab-opentofu-image-build-base-rules .gitlab-opentofu-image:build:base:rules: &gitlab-opentofu-image-build-base-rules
- *rule_skip_when_state_cleaner
- if: $CI_COMMIT_TAG - if: $CI_COMMIT_TAG
- changes: - changes:
- Dockerfile.* - Dockerfile.*
...@@ -182,6 +190,9 @@ check-versions: ...@@ -182,6 +190,9 @@ check-versions:
stage: test stage: test
needs: [] needs: []
image: alpine:3.21.2 image: alpine:3.21.2
rules:
- *rule_skip_when_state_cleaner
- when: on_success
before_script: before_script:
- apk add coreutils yq patch git - apk add coreutils yq patch git
script: script:
...@@ -198,6 +209,7 @@ check-readme: ...@@ -198,6 +209,7 @@ check-readme:
- make docs - make docs
- git diff --exit-code - git diff --exit-code
rules: rules:
- *rule_skip_when_state_cleaner
- if: $CI_COMMIT_TAG - if: $CI_COMMIT_TAG
- changes: - changes:
- Makefile - Makefile
...@@ -215,6 +227,7 @@ shellcheck: ...@@ -215,6 +227,7 @@ shellcheck:
- shellcheck ./src/gitlab-tofu.sh - shellcheck ./src/gitlab-tofu.sh
- shellcheck ./.gitlab/scripts/*.sh - shellcheck ./.gitlab/scripts/*.sh
rules: rules:
- *rule_skip_when_state_cleaner
- changes: - changes:
- .gitlab-ci.yml - .gitlab-ci.yml
- src/gitlab-tofu.sh - src/gitlab-tofu.sh
...@@ -251,6 +264,7 @@ gitlab-opentofu-image:deploy: ...@@ -251,6 +264,7 @@ gitlab-opentofu-image:deploy:
script: script:
- crane copy "$GITLAB_OPENTOFU_IMAGE_NAME" "$RELEASE_IMAGE" - crane copy "$GITLAB_OPENTOFU_IMAGE_NAME" "$RELEASE_IMAGE"
rules: rules:
- *rule_skip_when_state_cleaner
- if: $CI_COMMIT_TAG - if: $CI_COMMIT_TAG
gitlab-opentofu-image:deploy:dry-run: gitlab-opentofu-image:deploy:dry-run:
...@@ -263,6 +277,7 @@ gitlab-opentofu-image:deploy:dry-run: ...@@ -263,6 +277,7 @@ gitlab-opentofu-image:deploy:dry-run:
script: script:
- echo "dry run" - echo "dry run"
rules: rules:
- *rule_skip_when_state_cleaner
- if: $CI_COMMIT_TAG - if: $CI_COMMIT_TAG
when: never when: never
- changes: - changes:
...@@ -318,6 +333,7 @@ gitlab-opentofu-image:sign: ...@@ -318,6 +333,7 @@ gitlab-opentofu-image:sign:
paths: paths:
- 'image*.md' - 'image*.md'
rules: rules:
- *rule_skip_when_state_cleaner
- if: '$CI_SERVER_FQDN == "gitlab.com" && $CI_COMMIT_TAG' - if: '$CI_SERVER_FQDN == "gitlab.com" && $CI_COMMIT_TAG'
gitlab-opentofu-image:verify-signature: gitlab-opentofu-image:verify-signature:
...@@ -336,6 +352,7 @@ gitlab-opentofu-image:verify-signature: ...@@ -336,6 +352,7 @@ gitlab-opentofu-image:verify-signature:
"$RELEASE_IMAGE" "$RELEASE_IMAGE"
"$(crane digest --full-ref "$RELEASE_IMAGE")" "$(crane digest --full-ref "$RELEASE_IMAGE")"
rules: rules:
- *rule_skip_when_state_cleaner
- if: '$CI_SERVER_FQDN == "gitlab.com" && $CI_COMMIT_TAG' - if: '$CI_SERVER_FQDN == "gitlab.com" && $CI_COMMIT_TAG'
.release:base: .release:base:
...@@ -354,6 +371,7 @@ gitlab-opentofu-image:verify-signature: ...@@ -354,6 +371,7 @@ gitlab-opentofu-image:verify-signature:
release: release:
extends: ['.release:base'] extends: ['.release:base']
rules: rules:
- *rule_skip_when_state_cleaner
- if: $CI_COMMIT_TAG - if: $CI_COMMIT_TAG
variables: variables:
RELEASE_TAG_NAME: $CI_COMMIT_TAG RELEASE_TAG_NAME: $CI_COMMIT_TAG
...@@ -364,6 +382,7 @@ release: ...@@ -364,6 +382,7 @@ release:
release:dry-run: release:dry-run:
extends: ['.release:base'] extends: ['.release:base']
rules: rules:
- *rule_skip_when_state_cleaner
- if: $CI_COMMIT_TAG - if: $CI_COMMIT_TAG
when: never when: never
- changes: - changes:
...@@ -388,4 +407,4 @@ old-states: ...@@ -388,4 +407,4 @@ old-states:
- echo "Going to remove Terraform States older than '$FETCH_OLDER_THAN'" - echo "Going to remove Terraform States older than '$FETCH_OLDER_THAN'"
- ./.gitlab/scripts/fetch-states.sh | sed -n '1d;p' | ./.gitlab/scripts/remove-states.sh - ./.gitlab/scripts/fetch-states.sh | sed -n '1d;p' | ./.gitlab/scripts/remove-states.sh
rules: rules:
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "schedule" && $STATE_CLEANER == "true"' - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "schedule" && $CI_PIPELINE_SCHEDULE_DESCRIPTION == "state cleaner"'
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment