From 1e2e8a97c00751b27099a53ad45f09d596917820 Mon Sep 17 00:00:00 2001
From: Timo Furrer <tfurrer@gitlab.com>
Date: Thu, 14 Nov 2024 15:05:34 +0100
Subject: [PATCH] Add some more integration tests

---
 .../ValidatePlanApply.gitlab-ci.yml           | 22 +++++++++++++++++++
 ...ApplyTriggerInChildPipeline.gitlab-ci.yml} |  0
 ....yml => ValidatePlanDestroy.gitlab-ci.yml} |  0
 tests/integration.gitlab-ci.yml               |  8 +++----
 4 files changed, 25 insertions(+), 5 deletions(-)
 create mode 100644 tests/integration-tests/ValidatePlanApply.gitlab-ci.yml
 rename tests/integration-tests/{TriggerInChildPipeline.gitlab-ci.yml => ValidatePlanApplyTriggerInChildPipeline.gitlab-ci.yml} (100%)
 rename tests/integration-tests/{Destroy.gitlab-ci.yml => ValidatePlanDestroy.gitlab-ci.yml} (100%)

diff --git a/tests/integration-tests/ValidatePlanApply.gitlab-ci.yml b/tests/integration-tests/ValidatePlanApply.gitlab-ci.yml
new file mode 100644
index 0000000..ce33dd7
--- /dev/null
+++ b/tests/integration-tests/ValidatePlanApply.gitlab-ci.yml
@@ -0,0 +1,22 @@
+include:
+  - component: $CI_SERVER_FQDN/$CI_PROJECT_PATH/validate-plan-apply@$CI_COMMIT_SHA
+    inputs:
+      image_registry_base: $GITLAB_OPENTOFU_IMAGE_BASE
+      version: $CI_COMMIT_SHA
+      base_os: $GITLAB_OPENTOFU_BASE_IMAGE_OS
+      opentofu_version: $OPENTOFU_VERSION
+      root_dir: $TEST_GITLAB_TOFU_ROOT_DIR
+      state_name: $TEST_GITLAB_TOFU_STATE_NAME
+      fmt_rules: [{when: on_success}]
+      validate_rules: [{when: on_success}]
+      plan_rules: [{when: on_success}]
+      apply_rules: [{when: on_success}]
+
+  # For CI Terraform state cleanup
+  - component: $CI_SERVER_FQDN/$CI_PROJECT_PATH/delete-state@$CI_COMMIT_SHA
+    inputs:
+      stage: cleanup
+      state_name: $TEST_GITLAB_TOFU_STATE_NAME
+      rules: [{when: always}]
+
+stages: [validate, build, deploy, cleanup]
diff --git a/tests/integration-tests/TriggerInChildPipeline.gitlab-ci.yml b/tests/integration-tests/ValidatePlanApplyTriggerInChildPipeline.gitlab-ci.yml
similarity index 100%
rename from tests/integration-tests/TriggerInChildPipeline.gitlab-ci.yml
rename to tests/integration-tests/ValidatePlanApplyTriggerInChildPipeline.gitlab-ci.yml
diff --git a/tests/integration-tests/Destroy.gitlab-ci.yml b/tests/integration-tests/ValidatePlanDestroy.gitlab-ci.yml
similarity index 100%
rename from tests/integration-tests/Destroy.gitlab-ci.yml
rename to tests/integration-tests/ValidatePlanDestroy.gitlab-ci.yml
diff --git a/tests/integration.gitlab-ci.yml b/tests/integration.gitlab-ci.yml
index b9e6199..5d4c185 100644
--- a/tests/integration.gitlab-ci.yml
+++ b/tests/integration.gitlab-ci.yml
@@ -13,9 +13,6 @@ full-pipeline:
           - Defaults
           - FullPipelineTriggerInChildPipeline
           - VarFile
-          # - TestJob
-          # - ModuleRelease
-          # - WarningOnNonEmptyPlan
         GITLAB_OPENTOFU_BASE_IMAGE_OS:
           - alpine
           - debian
@@ -32,7 +29,8 @@ validate-plan-apply:
   parallel:
     matrix:
       - PIPELINE_NAME:
-          - TriggerInChildPipeline
+          - ValidatePlanApply
+          - ValidatePlanApplyTriggerInChildPipeline
         GITLAB_OPENTOFU_BASE_IMAGE_OS:
           - alpine
           - debian
@@ -49,7 +47,7 @@ validate-plan-destroy:
   parallel:
     matrix:
       - PIPELINE_NAME:
-          - Destroy
+          - ValidatePlanDestroy
           - ValidatePlanDestroyTriggerInChildPipeline
         GITLAB_OPENTOFU_BASE_IMAGE_OS:
           - alpine
-- 
GitLab