From 585538569f6704b2e383496ffe2fc5932953c3c6 Mon Sep 17 00:00:00 2001 From: Timo Furrer <tfurrer@gitlab.com> Date: Fri, 31 May 2024 09:08:16 +0200 Subject: [PATCH] Use apply setup for destroy integration test --- templates/apply.yml | 5 +++++ tests/integration-tests/Destroy.gitlab-ci.yml | 17 ++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/templates/apply.yml b/templates/apply.yml index 235c6e7..e2d3778 100644 --- a/templates/apply.yml +++ b/templates/apply.yml @@ -50,6 +50,10 @@ spec: state_name: default: default description: 'Remote OpenTofu state name.' + no_plan: + default: false + type: boolean + description: 'Whether a plan file should be used.' plan_name: default: 'plan' description: 'The name of the plan file to use. Will be used for TF_PLAN_CACHE and TF_PLAN_JSON.' @@ -79,6 +83,7 @@ spec: __CACHE_KEY_HACK: "$[[ inputs.root_dir ]]" TF_ROOT: $[[ inputs.root_dir ]] TF_STATE_NAME: $[[ inputs.state_name ]] + TF_APPLY_NO_PLAN: $[[ inputs.no_plan ]] TF_PLAN_NAME: $[[ inputs.plan_name ]] image: name: '$[[ inputs.image_registry_base ]]/$[[ inputs.image_name ]]:$[[ inputs.version ]]-opentofu$[[ inputs.opentofu_version ]]' diff --git a/tests/integration-tests/Destroy.gitlab-ci.yml b/tests/integration-tests/Destroy.gitlab-ci.yml index 2b8ac40..d0ec3c5 100644 --- a/tests/integration-tests/Destroy.gitlab-ci.yml +++ b/tests/integration-tests/Destroy.gitlab-ci.yml @@ -1,4 +1,16 @@ include: + - component: $CI_SERVER_FQDN/$CI_PROJECT_PATH/apply@$CI_COMMIT_SHA + inputs: + image_registry_base: $GITLAB_OPENTOFU_IMAGE_BASE + version: $CI_COMMIT_SHA + opentofu_version: $OPENTOFU_VERSION + as: 'setup:apply' + stage: setup + root_dir: $TEST_TF_ROOT + state_name: $TEST_TF_STATE_NAME + no_plan: true + auto_apply: true + - component: $CI_SERVER_FQDN/$CI_PROJECT_PATH/validate-plan-destroy@$CI_COMMIT_SHA inputs: image_registry_base: $GITLAB_OPENTOFU_IMAGE_BASE @@ -7,10 +19,13 @@ include: root_dir: $TEST_TF_ROOT state_name: $TEST_TF_STATE_NAME -stages: [validate, build, cleanup] +stages: [setup, validate, build, cleanup] # Required to run everything immediately, instead of manually. +'setup:apply': + rules: [{when: always}] + fmt: rules: [{when: always}] -- GitLab