From 909b08ddd73f61686683ec3a4f11dc53b943e603 Mon Sep 17 00:00:00 2001
From: Timo Furrer <tfurrer@gitlab.com>
Date: Mon, 4 Nov 2024 14:35:08 +0100
Subject: [PATCH] Use `rules` inputs in integration tests

---
 .../integration-tests/Defaults.gitlab-ci.yml  | 32 +++++--------------
 tests/integration-tests/Destroy.gitlab-ci.yml | 29 +++++------------
 tests/integration-tests/TestJob.gitlab-ci.yml |  7 ++--
 tests/integration-tests/VarFile.gitlab-ci.yml | 32 +++++--------------
 4 files changed, 26 insertions(+), 74 deletions(-)

diff --git a/tests/integration-tests/Defaults.gitlab-ci.yml b/tests/integration-tests/Defaults.gitlab-ci.yml
index 09762e0..2c51ac1 100644
--- a/tests/integration-tests/Defaults.gitlab-ci.yml
+++ b/tests/integration-tests/Defaults.gitlab-ci.yml
@@ -7,29 +7,13 @@ include:
       opentofu_version: $OPENTOFU_VERSION
       root_dir: $TEST_TF_ROOT
       state_name: $TEST_TF_STATE_NAME
+      # Required to run everything immediately, instead of manually.
+      fmt_rules: [{when: always}]
+      validate_rules: [{when: always}]
+      test_rules: [{when: always}]
+      plan_rules: [{when: always}]
+      apply_rules: [{when: always}]
+      destroy_rules: [{when: always}]
+      delete_state_rules: [{when: always}]
 
 stages: [validate, test, build, deploy, cleanup]
-
-# Required to run everything immediately, instead of manually.
-
-fmt:
-  rules: [{when: always}]
-
-validate:
-  rules: [{when: always}]
-
-test:
-  rules: [{when: always}]
-
-plan:
-  rules: [{when: always}]
-
-apply:
-  rules: [{when: always}]
-
-destroy:
-  rules: [{when: always}]
-
-delete-state:
-  rules: [{when: always}]
-
diff --git a/tests/integration-tests/Destroy.gitlab-ci.yml b/tests/integration-tests/Destroy.gitlab-ci.yml
index d0ec3c5..874168e 100644
--- a/tests/integration-tests/Destroy.gitlab-ci.yml
+++ b/tests/integration-tests/Destroy.gitlab-ci.yml
@@ -10,6 +10,8 @@ include:
       state_name: $TEST_TF_STATE_NAME
       no_plan: true
       auto_apply: true
+      # Required to run everything immediately, instead of manually.
+      rules: [{when: always}]
 
   - component: $CI_SERVER_FQDN/$CI_PROJECT_PATH/validate-plan-destroy@$CI_COMMIT_SHA
     inputs:
@@ -18,26 +20,11 @@ include:
       opentofu_version: $OPENTOFU_VERSION
       root_dir: $TEST_TF_ROOT
       state_name: $TEST_TF_STATE_NAME
+      # Required to run everything immediately, instead of manually.
+      fmt_rules: [{when: always}]
+      validate_rules: [{when: always}]
+      plan_rules: [{when: always}]
+      destroy_rules: [{when: always}]
+      delete_state_rules: [{when: always}]
 
 stages: [setup, validate, build, cleanup]
-
-# Required to run everything immediately, instead of manually.
-
-'setup:apply':
-  rules: [{when: always}]
-
-fmt:
-  rules: [{when: always}]
-
-validate:
-  rules: [{when: always}]
-
-plan:
-  rules: [{when: always}]
-
-destroy:
-  rules: [{when: always}]
-
-delete-state:
-  rules: [{when: always}]
-
diff --git a/tests/integration-tests/TestJob.gitlab-ci.yml b/tests/integration-tests/TestJob.gitlab-ci.yml
index adf8da8..96e90ee 100644
--- a/tests/integration-tests/TestJob.gitlab-ci.yml
+++ b/tests/integration-tests/TestJob.gitlab-ci.yml
@@ -6,10 +6,7 @@ include:
       opentofu_version: $OPENTOFU_VERSION
       root_dir: $TEST_TF_ROOT
       state_name: $TEST_TF_STATE_NAME
+      # Required to run everything immediately, instead of manually.
+      rules: [{when: always}]
 
 stages: [test]
-
-# Required to run everything immediately, instead of manually.
-
-test:
-  rules: [{when: always}]
diff --git a/tests/integration-tests/VarFile.gitlab-ci.yml b/tests/integration-tests/VarFile.gitlab-ci.yml
index 0c035da..f1505f3 100644
--- a/tests/integration-tests/VarFile.gitlab-ci.yml
+++ b/tests/integration-tests/VarFile.gitlab-ci.yml
@@ -8,29 +8,13 @@ include:
       root_dir: $TEST_TF_ROOT
       state_name: $TEST_TF_STATE_NAME
       var_file: varfile.integration-test.tfvars
+      # Required to run everything immediately, instead of manually.
+      fmt_rules: [{when: always}]
+      validate_rules: [{when: always}]
+      test_rules: [{when: always}]
+      plan_rules: [{when: always}]
+      apply_rules: [{when: always}]
+      destroy_rules: [{when: always}]
+      delete_state_rules: [{when: always}]
 
 stages: [validate, test, build, deploy, cleanup]
-
-# Required to run everything immediately, instead of manually.
-
-fmt:
-  rules: [{when: always}]
-
-validate:
-  rules: [{when: always}]
-
-test:
-  rules: [{when: always}]
-
-plan:
-  rules: [{when: always}]
-
-apply:
-  rules: [{when: always}]
-
-destroy:
-  rules: [{when: always}]
-
-delete-state:
-  rules: [{when: always}]
-
-- 
GitLab