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
Branches
Tags
No related merge requests found
......@@ -5,12 +5,17 @@ workflow:
- if: $CI_COMMIT_TAG
- 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:
- local: opentofu_versions.yaml
- local: tests/unit.gitlab-ci.yml
rules:
- if: $SKIP_TESTS == "true"
when: never
- *rule_skip_when_state_cleaner
- changes:
- src/gitlab-tofu.sh
- opentofu_versions.yaml
......@@ -24,6 +29,7 @@ include:
rules:
- if: $SKIP_TESTS == "true"
when: never
- *rule_skip_when_state_cleaner
- changes:
- src/gitlab-tofu.sh
- opentofu_versions.yaml
......@@ -110,6 +116,7 @@ variables:
check-semantic-version:
stage: .pre
rules:
- *rule_skip_when_state_cleaner
- if: $CI_COMMIT_TAG
image: alpine:3.21.2
before_script:
......@@ -118,6 +125,7 @@ check-semantic-version:
- echo -n "$CI_COMMIT_TAG" | ./.gitlab/scripts/check-semantic-version.sh
.gitlab-opentofu-image:build:base:rules: &gitlab-opentofu-image-build-base-rules
- *rule_skip_when_state_cleaner
- if: $CI_COMMIT_TAG
- changes:
- Dockerfile.*
......@@ -182,6 +190,9 @@ check-versions:
stage: test
needs: []
image: alpine:3.21.2
rules:
- *rule_skip_when_state_cleaner
- when: on_success
before_script:
- apk add coreutils yq patch git
script:
......@@ -198,6 +209,7 @@ check-readme:
- make docs
- git diff --exit-code
rules:
- *rule_skip_when_state_cleaner
- if: $CI_COMMIT_TAG
- changes:
- Makefile
......@@ -215,6 +227,7 @@ shellcheck:
- shellcheck ./src/gitlab-tofu.sh
- shellcheck ./.gitlab/scripts/*.sh
rules:
- *rule_skip_when_state_cleaner
- changes:
- .gitlab-ci.yml
- src/gitlab-tofu.sh
......@@ -251,6 +264,7 @@ gitlab-opentofu-image:deploy:
script:
- crane copy "$GITLAB_OPENTOFU_IMAGE_NAME" "$RELEASE_IMAGE"
rules:
- *rule_skip_when_state_cleaner
- if: $CI_COMMIT_TAG
gitlab-opentofu-image:deploy:dry-run:
......@@ -263,6 +277,7 @@ gitlab-opentofu-image:deploy:dry-run:
script:
- echo "dry run"
rules:
- *rule_skip_when_state_cleaner
- if: $CI_COMMIT_TAG
when: never
- changes:
......@@ -318,6 +333,7 @@ gitlab-opentofu-image:sign:
paths:
- 'image*.md'
rules:
- *rule_skip_when_state_cleaner
- if: '$CI_SERVER_FQDN == "gitlab.com" && $CI_COMMIT_TAG'
gitlab-opentofu-image:verify-signature:
......@@ -336,6 +352,7 @@ gitlab-opentofu-image:verify-signature:
"$RELEASE_IMAGE"
"$(crane digest --full-ref "$RELEASE_IMAGE")"
rules:
- *rule_skip_when_state_cleaner
- if: '$CI_SERVER_FQDN == "gitlab.com" && $CI_COMMIT_TAG'
.release:base:
......@@ -354,6 +371,7 @@ gitlab-opentofu-image:verify-signature:
release:
extends: ['.release:base']
rules:
- *rule_skip_when_state_cleaner
- if: $CI_COMMIT_TAG
variables:
RELEASE_TAG_NAME: $CI_COMMIT_TAG
......@@ -364,6 +382,7 @@ release:
release:dry-run:
extends: ['.release:base']
rules:
- *rule_skip_when_state_cleaner
- if: $CI_COMMIT_TAG
when: never
- changes:
......@@ -388,4 +407,4 @@ old-states:
- 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
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