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

Add backport integration tests

parent 496bd4ae
No related branches found
No related tags found
No related merge requests found
......@@ -14,25 +14,30 @@ docs:
rm -f readme0 readme1 readme_inputs.md
BACKPORTS_DIR := backports
BACKPORTS_BASE_FILE := $(BACKPORTS_DIR)/Base.gitlab-ci.yml
BACKPORTS_BASE_DIR := $(BACKPORTS_DIR)/OpenTofu
BACKPORTS_BASE_FILE := $(BACKPORTS_BASE_DIR)/Base.gitlab-ci.yml
.PHONY: backports
backports:
@mkdir -p $(BACKPORTS_DIR)
@mkdir -p $(BACKPORTS_BASE_DIR)
@echo 'variables:' > $(BACKPORTS_BASE_FILE)
@echo ' # OpenTofu CI/CD component version, see https://gitlab.com/components/opentofu/-/releases' >> $(BACKPORTS_BASE_FILE)
@echo ' VERSION: "0.1.0-alpha4"' >> $(BACKPORTS_BASE_FILE)
@echo ' # Compatible OpenTofu version, see https://gitlab.com/components/opentofu/-/releases' >> $(BACKPORTS_BASE_FILE)
@echo ' OPENTOFU_VERSION: "1.6.0"' >> $(BACKPORTS_BASE_FILE)
@echo ' TF_ROOT: $${CI_PROJECT_DIR} # The relative path to the root directory of the OpenTofu project' >> $(BACKPORTS_BASE_FILE)
@echo ' TF_STATE_NAME: default # The name of the state file used by the GitLab Managed Terraform state backend'>> $(BACKPORTS_BASE_FILE)
@echo ' # Job Image with `gitlab-tofu`' >> $(BACKPORTS_BASE_FILE)
@echo ' GITLAB_OPENTOFU_IMAGE: registry.gitlab.com/components/opentofu/gitlab-opentofu:$$VERSION-opentofu$$OPENTOFU_VERSION' >> $(BACKPORTS_BASE_FILE)
@echo ' # The relative path to the root directory of the OpenTofu project' >> $(BACKPORTS_BASE_FILE)
@echo ' TF_ROOT: $${CI_PROJECT_DIR}' >> $(BACKPORTS_BASE_FILE)
@echo ' # The name of the state file used by the GitLab Managed Terraform state backend' >> $(BACKPORTS_BASE_FILE)
@echo ' TF_STATE_NAME: default' >> $(BACKPORTS_BASE_FILE)
@sed '1,/^---$$/d' templates/full-pipeline.yml >> $(BACKPORTS_BASE_FILE)
@sed -i $(BACKPORTS_BASE_FILE) -e 's/$$\[\[ inputs.stage_validate \]\]/validate/'
@sed -i $(BACKPORTS_BASE_FILE) -e 's/$$\[\[ inputs.stage_build \]\]/build/'
@sed -i $(BACKPORTS_BASE_FILE) -e 's/$$\[\[ inputs.stage_deploy \]\]/deploy/'
@sed -i $(BACKPORTS_BASE_FILE) -e 's/$$\[\[ inputs.stage_cleanup \]\]/cleanup/'
@sed -i $(BACKPORTS_BASE_FILE) -e 's#$$\[\[ inputs.gitlab_opentofu_image \]\]#registry.gitlab.com/components/opentofu/gitlab-opentofu:$$VERSION-opentofu$$OPENTOFU_VERSION#'
@sed -i $(BACKPORTS_BASE_FILE) -e 's/$$\[\[ inputs.gitlab_opentofu_image \]\]/$$GITLAB_OPENTOFU_IMAGE/'
@sed -i $(BACKPORTS_BASE_FILE) -e 's/$$\[\[ inputs.root_dir \]\]/$$TF_ROOT/'
@sed -i $(BACKPORTS_BASE_FILE) -e 's/$$\[\[ inputs.state_name \]\]/$$TF_STATE_NAME/'
@sed -i $(BACKPORTS_BASE_FILE) -e 's/$$\[\[ inputs.auto_apply \]\]/$$TF_AUTO_APPLY/'
......
......@@ -3,12 +3,16 @@ variables:
VERSION: "0.1.0-alpha4"
# Compatible OpenTofu version, see https://gitlab.com/components/opentofu/-/releases
OPENTOFU_VERSION: "1.6.0"
TF_ROOT: ${CI_PROJECT_DIR} # The relative path to the root directory of the OpenTofu project
TF_STATE_NAME: default # The name of the state file used by the GitLab Managed Terraform state backend
# Job Image with `gitlab-tofu`
GITLAB_OPENTOFU_IMAGE: registry.gitlab.com/components/opentofu/gitlab-opentofu:$VERSION-opentofu$OPENTOFU_VERSION
# The relative path to the root directory of the OpenTofu project
TF_ROOT: ${CI_PROJECT_DIR}
# The name of the state file used by the GitLab Managed Terraform state backend
TF_STATE_NAME: default
.opentofu:default:
image:
name: registry.gitlab.com/components/opentofu/gitlab-opentofu:$VERSION-opentofu$OPENTOFU_VERSION
name: $GITLAB_OPENTOFU_IMAGE
cache:
key: "$TF_ROOT"
......
include:
- template: /backports/OpenTofu.gitlab-ci.yml
stages: [validate, test, build, deploy, cleanup]
# Required to run everything immediately, instead of manually.
fmt:
rules: [{when: always}]
validate:
rules: [{when: always}]
plan:
rules: [{when: always}]
apply:
rules: [{when: always}]
destroy:
rules: [{when: always}]
delete-state:
rules: [{when: always}]
......@@ -13,3 +13,20 @@ component:
parallel:
matrix:
- PIPELINE: [Defaults.gitlab-ci.yml]
backport-templates:
stage: test-integration
variables:
OPENTOFU_VERSION: $LATEST_OPENTOFU_VERSION
GITLAB_OPENTOFU_IMAGE: $GITLAB_OPENTOFU_IMAGE_NAME
TF_STATE_NAME: ci-integration-backports-$CI_PIPELINE_IID-$CI_NODE_INDEX
TF_ROOT: tests/terraform
trigger:
include: tests/integration-tests/$PIPELINE
strategy: depend
rules:
- if: '$CI_PROJECT_PATH == "components/opentofu"'
#- if: '$CI_MERGE_REQUEST_EVENT_TYPE == "merge_train"'
parallel:
matrix:
- PIPELINE: [BackportTemplates.gitlab-ci.yml]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment