From 413dbd6f506724b28470629c90d3082dfaf26d7f Mon Sep 17 00:00:00 2001 From: "Marcel S. Henselin" Date: Wed, 25 Mar 2026 13:52:47 +0100 Subject: [PATCH 01/10] chore: add notifications [skip ci] --- .github/workflows/ci_new.yaml | 17 +++++++++++++++++ .github/workflows/clean_up.yaml | 9 +++++++++ 2 files changed, 26 insertions(+) diff --git a/.github/workflows/ci_new.yaml b/.github/workflows/ci_new.yaml index d79f806a..8679e134 100644 --- a/.github/workflows/ci_new.yaml +++ b/.github/workflows/ci_new.yaml @@ -33,6 +33,23 @@ jobs: - name: Checkout uses: actions/checkout@v6 + - name: Notify Google Chat + if: ${{ always() }} # Use always to ensure that the notification is also send on failure of former steps + uses: SimonScholz/google-chat-action@main + with: + webhookUrl: '${{ secrets.GOOGLE_WEBHOOK_URL }}' + jobStatus: '${{ job.status }}' + title: CI pipeline + subtitle: "on: ${{ github.event_name }}" + #imageUrl: https://raw.githubusercontent.com/SimonScholz/simonscholz.github.io/gatsby-homepage/src/assets/img/avatar.webp + #imageType: SQUARE + #imageAltText: Alternative image text + #createDefaultSection: false + #collapsibleDefaultSection: false + #uncollapsibleWidgetsCount: 3 + #additionalSections: '[{"header": "Additional Section", "collapsible": true, "widgets": [{"decoratedText": {"startIcon": {"knownIcon": "STAR"},"text": "Additional Section"}}] }]' + #threadKey: ${{ github.event.number }} + - name: Notify uses: ./.github/actions/notify with: diff --git a/.github/workflows/clean_up.yaml b/.github/workflows/clean_up.yaml index 318c5054..369e973e 100644 --- a/.github/workflows/clean_up.yaml +++ b/.github/workflows/clean_up.yaml @@ -34,6 +34,15 @@ jobs: - name: Checkout uses: actions/checkout@v6 + - name: Notify Google Chat + if: ${{ always() }} # Use always to ensure that the notification is also send on failure of former steps + uses: SimonScholz/google-chat-action@main + with: + webhookUrl: '${{ secrets.GOOGLE_WEBHOOK_URL }}' + jobStatus: '${{ job.status }}' + title: CI pipeline + subtitle: "on: ${{ github.event_name }} \n
with filter prefix: ${{ inputs.res_prefix }}" + - name: Notify uses: ./.github/actions/notify with: From ff144042ba106553b598b8f4ac7953db286ed611 Mon Sep 17 00:00:00 2001 From: "Marcel S. Henselin" Date: Wed, 25 Mar 2026 13:56:44 +0100 Subject: [PATCH 02/10] chore: add notifications [skip ci] --- .github/actions/acc_test/action.yaml | 4 ++-- .github/workflows/clean_up.yaml | 24 ++++++++++++------------ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/actions/acc_test/action.yaml b/.github/actions/acc_test/action.yaml index 23bcd84e..99a1ffeb 100644 --- a/.github/actions/acc_test/action.yaml +++ b/.github/actions/acc_test/action.yaml @@ -214,7 +214,7 @@ runs: TF_ACC_KEK_KEY_RING_ID=${TF_ACC_KEK_KEY_RING_ID} \ TF_ACC_KEK_KEY_VERSION=${TF_ACC_KEK_KEY_VERSION} \ TF_ACC_KEK_SERVICE_ACCOUNT=${TF_ACC_KEK_SERVICE_ACCOUNT} \ - go test -v ${{ inputs.test_file }} -timeout=${{ inputs.test_timeout_string }} + go test -v ${{ inputs.test_file }} -timeout=${{ inputs.test_timeout_string }} | tee -a acc_test_run.log echo "::endgroup::" env: TF_ACC_PROJECT_ID: ${{ inputs.project_id }} @@ -243,7 +243,7 @@ runs: # testArguments: "./... -timeout ${{ inputs.test_timeout_string }}" # moduleDirectory: "stackit" - - name: Run acceptance tests + - name: Run all acceptance tests if: ${{ inputs.test_file == '' }} shell: bash run: | diff --git a/.github/workflows/clean_up.yaml b/.github/workflows/clean_up.yaml index 369e973e..edb14bb4 100644 --- a/.github/workflows/clean_up.yaml +++ b/.github/workflows/clean_up.yaml @@ -40,19 +40,19 @@ jobs: with: webhookUrl: '${{ secrets.GOOGLE_WEBHOOK_URL }}' jobStatus: '${{ job.status }}' - title: CI pipeline - subtitle: "on: ${{ github.event_name }} \n
with filter prefix: ${{ inputs.res_prefix }}" + title: CLEAN-UP pipeline + subtitle: "${{ github.event_name }} with filter prefix ${{ inputs.res_prefix }}" - - name: Notify - uses: ./.github/actions/notify - with: - webhook_url: ${{ secrets.GOOGLE_WEBHOOK_URL }} - title: CI pipeline started - event_title: ${{ github.event.type }} - event_author: ${{ github.event.actor.login }} - event_body: "Filter: ${{ inputs.res_prefix }}" - event_number: ${{ github.event.id }} - event_url: "https://tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/actions/runs/${{ github.run_id }}" +# - name: Notify +# uses: ./.github/actions/notify +# with: +# webhook_url: ${{ secrets.GOOGLE_WEBHOOK_URL }} +# title: CI pipeline started +# event_title: ${{ github.event.type }} +# event_author: ${{ github.event.actor.login }} +# event_body: "Filter: ${{ inputs.res_prefix }}" +# event_number: ${{ github.event.id }} +# event_url: "https://tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/actions/runs/${{ github.run_id }}" - name: Clean uses: ./.github/actions/clean_up From b06e7ffd4030f4c04b2e9426e982d3e4e8cffc07 Mon Sep 17 00:00:00 2001 From: "Marcel S. Henselin" Date: Wed, 25 Mar 2026 16:53:23 +0100 Subject: [PATCH 03/10] chore: add tests [skip ci] --- .github/workflows/clean_up.yaml | 4 ++-- .github/workflows/tf-acc-test.yaml | 17 ++++++++++++++++ .../postgresflex_acc_test.go | 20 +++++++++++++++++++ .../sqlserverflex_acc_test.go | 17 ++++++++++++++++ 4 files changed, 56 insertions(+), 2 deletions(-) diff --git a/.github/workflows/clean_up.yaml b/.github/workflows/clean_up.yaml index edb14bb4..b5a84fed 100644 --- a/.github/workflows/clean_up.yaml +++ b/.github/workflows/clean_up.yaml @@ -41,13 +41,13 @@ jobs: webhookUrl: '${{ secrets.GOOGLE_WEBHOOK_URL }}' jobStatus: '${{ job.status }}' title: CLEAN-UP pipeline - subtitle: "${{ github.event_name }} with filter prefix ${{ inputs.res_prefix }}" + subtitle: "${{ github.event_name }} with filter prefix \"${{ inputs.res_prefix }}\"" # - name: Notify # uses: ./.github/actions/notify # with: # webhook_url: ${{ secrets.GOOGLE_WEBHOOK_URL }} -# title: CI pipeline started +# title: CLEAN-UP pipeline # event_title: ${{ github.event.type }} # event_author: ${{ github.event.actor.login }} # event_body: "Filter: ${{ inputs.res_prefix }}" diff --git a/.github/workflows/tf-acc-test.yaml b/.github/workflows/tf-acc-test.yaml index 85c78437..cc76fd61 100644 --- a/.github/workflows/tf-acc-test.yaml +++ b/.github/workflows/tf-acc-test.yaml @@ -30,6 +30,14 @@ jobs: - name: Checkout uses: actions/checkout@v6 + - name: Notify Google Chat + if: ${{ always() }} # Use always to ensure that the notification is also send on failure of former steps + uses: SimonScholz/google-chat-action@main + with: + webhookUrl: '${{ secrets.GOOGLE_WEBHOOK_URL }}' + title: Acceptance Tests started + subtitle: "${{ github.event_name }}" + - name: Notify uses: ./.github/actions/notify with: @@ -71,6 +79,15 @@ jobs: tf_acc_kek_key_version: ${{ vars.TF_ACC_KEK_KEY_VERSION }} tf_acc_kek_service_account: ${{ vars.TF_ACC_KEK_SERVICE_ACCOUNT }} + - name: Notify Google Chat + if: ${{ always() }} # Use always to ensure that the notification is also send on failure of former steps + uses: SimonScholz/google-chat-action@main + with: + webhookUrl: '${{ secrets.GOOGLE_WEBHOOK_URL }}' + jobStatus: '${{ job.status }}' + title: Acceptance Tests started + subtitle: "${{ github.event_name }} finished" + - name: Notify uses: ./.github/actions/notify with: diff --git a/stackit/internal/services/postgresflexalpha/postgresflex_acc_test.go b/stackit/internal/services/postgresflexalpha/postgresflex_acc_test.go index 6c057cfb..4dd1e6ea 100644 --- a/stackit/internal/services/postgresflexalpha/postgresflex_acc_test.go +++ b/stackit/internal/services/postgresflexalpha/postgresflex_acc_test.go @@ -157,6 +157,9 @@ func TestAccInstance(t *testing.T) { updVersion := updNetACL updVersion.Version = "17" + updRetention := updVersion + updRetention.RetentionDays = 40 + testItemID := testutils.ResStr(pfx, "instance", exData.TfName) compareValuesSame := statecheck.CompareValue(compare.ValuesSame()) resource.ParallelTest( @@ -337,6 +340,23 @@ func TestAccInstance(t *testing.T) { ), ), }, + // Update retention_days + { + PreConfig: func() { + t.Logf(" ... %s - %s", t.Name(), "update version") + }, + Config: testutils.StringFromTemplateMust( + "testdata/instance_template.gompl", + updVersion, + ), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr( + testItemID, + "retention_days", + strconv.Itoa(int(updVersion.RetentionDays)), + ), + ), + }, // Import test // test instance imports { diff --git a/stackit/internal/services/sqlserverflexbeta/sqlserverflex_acc_test.go b/stackit/internal/services/sqlserverflexbeta/sqlserverflex_acc_test.go index 77955dd5..399eed3f 100644 --- a/stackit/internal/services/sqlserverflexbeta/sqlserverflex_acc_test.go +++ b/stackit/internal/services/sqlserverflexbeta/sqlserverflex_acc_test.go @@ -142,6 +142,9 @@ func TestAccInstance(t *testing.T) { updSizeData := exData updSizeData.Size = 25 + updRetentionDays := updSizeData + updRetentionDays.RetentionDays = 30 + testInstanceID := testutils.ResStr(pfx, "instance", exData.TfName) compareValuesSame := statecheck.CompareValue(compare.ValuesSame()) @@ -210,6 +213,20 @@ func TestAccInstance(t *testing.T) { defaultNoEncInstanceTestChecks(testInstanceID, updSizeData), ), }, + // Update retention_days + { + PreConfig: func() { + t.Logf("testing: %s - %s", t.Name(), "update storage.retention_days and verify") + }, + ExpectNonEmptyPlan: true, + Config: testutils.StringFromTemplateMust( + "testdata/instance_template.gompl", + updRetentionDays, + ), + Check: resource.ComposeTestCheckFunc( + defaultNoEncInstanceTestChecks(testInstanceID, updRetentionDays), + ), + }, // Import test // test instance imports { From 2893a11c0a4b146a55f40b370d963c400a20eb1c Mon Sep 17 00:00:00 2001 From: Marcel_Henselin Date: Thu, 26 Mar 2026 16:18:00 +0000 Subject: [PATCH 04/10] chore: refactor pipelines (#96) ## Description relates to #1234 ## Checklist - [ ] Issue was linked above - [ ] Code format was applied: `make fmt` - [ ] Examples were added / adjusted (see `examples/` directory) - [x] Docs are up-to-date: `make generate-docs` (will be checked by CI) - [ ] Unit tests got implemented or updated - [ ] Acceptance tests got implemented or updated (see e.g. [here](https://github.com/stackitcloud/terraform-provider-stackit/blob/f5f99d170996b208672ae684b6da53420e369563/stackit/internal/services/dns/dns_acc_test.go)) - [x] Unit tests are passing: `make test` (will be checked by CI) - [x] No linter issues: `make lint` (will be checked by CI) Co-authored-by: Marcel S. Henselin Reviewed-on: https://tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pulls/96 --- .github/actions/acc_test/action.yaml | 85 ++++++++----------- .github/workflows/clean_up.yaml | 10 +-- .github/workflows/tf-acc-test.yaml | 31 +++++-- .../sqlserverflex_acc_test.go | 13 ++- 4 files changed, 74 insertions(+), 65 deletions(-) diff --git a/.github/actions/acc_test/action.yaml b/.github/actions/acc_test/action.yaml index 23bcd84e..13674a9a 100644 --- a/.github/actions/acc_test/action.yaml +++ b/.github/actions/acc_test/action.yaml @@ -65,6 +65,11 @@ inputs: description: "testfile to run" default: '' +outputs: + result: + value: ${{ steps.testrun.result }} + description: "the output of the tests" + runs: using: "composite" steps: @@ -88,6 +93,10 @@ runs: with: terraform_wrapper: false + - uses: actions/setup-node@v6 + with: + node-version: '24.x' + - name: Setup JAVA uses: actions/setup-java@v5 with: @@ -190,8 +199,8 @@ runs: ls -l stackit/"${{ inputs.service_account_json_file_path }}" echo "::endgroup::" - - name: Run acceptance test file - if: ${{ inputs.test_file != '' }} + - name: Run acceptance tests + id: testrun shell: bash run: | echo "::group::go test file" @@ -203,7 +212,10 @@ runs: export TF_LOG fi + testfile="${{ inputs.test_file }}" + echo "Running acceptance tests for the terraform provider" + set +e cd stackit || exit 1 TF_ACC=1 \ TF_ACC_PROJECT_ID=${TF_ACC_PROJECT_ID} \ @@ -214,7 +226,16 @@ runs: TF_ACC_KEK_KEY_RING_ID=${TF_ACC_KEK_KEY_RING_ID} \ TF_ACC_KEK_KEY_VERSION=${TF_ACC_KEK_KEY_VERSION} \ TF_ACC_KEK_SERVICE_ACCOUNT=${TF_ACC_KEK_SERVICE_ACCOUNT} \ - go test -v ${{ inputs.test_file }} -timeout=${{ inputs.test_timeout_string }} + go test -v ${testfile} -timeout=${{ inputs.test_timeout_string }} | tee -a acc_test_run.log + echo "::endgroup::" + set -e + echo "::group::go test result" + if [ $? -ne 0 ]; then + echo "Test failed, see acc_test_run.log for details" + res=$(cat acc_test_run.log | grep -v "=== RUN" | grep -v "\-\-\- PASS" | grep -v "=== CONT" | grep -v "=== PAUSE") + echo "result=${res}" >> "$GITHUB_OUTPUT" + exit 1 + fi echo "::endgroup::" env: TF_ACC_PROJECT_ID: ${{ inputs.project_id }} @@ -225,55 +246,19 @@ runs: TF_ACC_KEK_KEY_VERSION: ${{ inputs.tf_acc_kek_key_version }} TF_ACC_KEK_SERVICE_ACCOUNT: ${{ inputs.tf_acc_kek_service_account }} -# does not work correctly -# - name: Run test action -# if: ${{ inputs.test_file == '' }} -# env: -# TF_ACC: 1 -# TF_ACC_PROJECT_ID: ${{ inputs.project_id }} -# TF_ACC_REGION: ${{ inputs.region }} -# TF_ACC_TEST_PROJECT_USER_EMAIL: ${{ inputs.project_user_email }} -# TF_ACC_KEK_KEY_ID: ${{ inputs.tf_acc_kek_key_id }} -# TF_ACC_KEK_KEY_RING_ID: ${{ inputs.tf_acc_kek_key_ring_id }} -# TF_ACC_KEK_KEY_VERSION: ${{ inputs.tf_acc_kek_key_version }} -# TF_ACC_KEK_SERVICE_ACCOUNT: ${{ inputs.tf_acc_kek_service_account }} -# TF_ACC_SERVICE_ACCOUNT_FILE: ${{ steps.service_account.outputs.safile }} -# uses: robherley/go-test-action@v0 -# with: -# testArguments: "./... -timeout ${{ inputs.test_timeout_string }}" -# moduleDirectory: "stackit" - - - name: Run acceptance tests - if: ${{ inputs.test_file == '' }} + - name: Artifact upload start shell: bash run: | - echo "::group::go test all" - set -e - set -o pipefail + echo "::group::artifact upload" - if [[ "${{ inputs.tf_debug }}" == "true" ]]; then - TF_LOG=INFO - export TF_LOG - fi + - name: Upload test log artifact + if: always() + uses: actions/upload-artifact@v3 + with: + name: acc_test.log + path: "stackit/acc_test_run.log" - echo "Running acceptance tests for the terraform provider" - cd stackit || exit 1 - TF_ACC=1 \ - TF_ACC_PROJECT_ID=${TF_ACC_PROJECT_ID} \ - TF_ACC_REGION=${TF_ACC_REGION} \ - TF_ACC_TEST_PROJECT_USER_EMAIL=${TF_ACC_TEST_PROJECT_USER_EMAIL} \ - TF_ACC_SERVICE_ACCOUNT_FILE="${PWD}/${{ inputs.service_account_json_file_path }}" \ - TF_ACC_KEK_KEY_ID=${TF_ACC_KEK_KEY_ID} \ - TF_ACC_KEK_KEY_RING_ID=${TF_ACC_KEK_KEY_RING_ID} \ - TF_ACC_KEK_KEY_VERSION=${TF_ACC_KEK_KEY_VERSION} \ - TF_ACC_KEK_SERVICE_ACCOUNT=${TF_ACC_KEK_SERVICE_ACCOUNT} \ - go test -v ./... -timeout=${{ inputs.test_timeout_string }} + - name: Artifact upload finish + shell: bash + run: | echo "::endgroup::" - env: - TF_ACC_PROJECT_ID: ${{ inputs.project_id }} - TF_ACC_REGION: ${{ inputs.region }} - TF_ACC_TEST_PROJECT_USER_EMAIL: ${{ inputs.project_user_email }} - TF_ACC_KEK_KEY_ID: ${{ inputs.tf_acc_kek_key_id }} - TF_ACC_KEK_KEY_RING_ID: ${{ inputs.tf_acc_kek_key_ring_id }} - TF_ACC_KEK_KEY_VERSION: ${{ inputs.tf_acc_kek_key_version }} - TF_ACC_KEK_SERVICE_ACCOUNT: ${{ inputs.tf_acc_kek_service_account }} diff --git a/.github/workflows/clean_up.yaml b/.github/workflows/clean_up.yaml index 318c5054..b366488f 100644 --- a/.github/workflows/clean_up.yaml +++ b/.github/workflows/clean_up.yaml @@ -38,12 +38,12 @@ jobs: uses: ./.github/actions/notify with: webhook_url: ${{ secrets.GOOGLE_WEBHOOK_URL }} - title: CI pipeline started - event_title: ${{ github.event.type }} - event_author: ${{ github.event.actor.login }} + title: CLEAN UP pipeline started + event_title: ${{ forgejo.event_name }} + event_author: ${{ forgejo.actor }} event_body: "Filter: ${{ inputs.res_prefix }}" - event_number: ${{ github.event.id }} - event_url: "https://tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/actions/runs/${{ github.run_id }}" + event_number: ${{ forgejo.run_number }} + event_url: "https://tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/actions/runs/${{ forgejo.run_number }}" - name: Clean uses: ./.github/actions/clean_up diff --git a/.github/workflows/tf-acc-test.yaml b/.github/workflows/tf-acc-test.yaml index 85c78437..642fe63b 100644 --- a/.github/workflows/tf-acc-test.yaml +++ b/.github/workflows/tf-acc-test.yaml @@ -21,6 +21,16 @@ on: type: string default: '90m' required: true + test_file: + description: "string that determines the test file to run (default all tests)" + type: choice + options: + - tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/wait/postgresflexalpha + - tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha + - tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/wait/sqlserverflexbeta + - tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexbeta + default: '' + required: true jobs: acc_test: @@ -35,14 +45,15 @@ jobs: with: webhook_url: ${{ secrets.GOOGLE_WEBHOOK_URL }} title: Terraform Acceptance Tests started - event_title: ${{ github.event.type }} - event_author: ${{ github.event.actor.login }} - event_body: 'No event body.' - event_number: ${{ github.event.id }} - event_url: "https://tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/actions/runs/${{ github.run_id }}" + event_title: ${{ github.event_name }} + event_author: ${{ github.actor }} + event_body: ${{ inputs.test_file }} + event_number: ${{ github.run_id }} + event_url: "https://tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/actions/runs/${{ forgejo.run_number }}" - name: Run Test (workflow dispatch) if: ${{ github.event_name == 'workflow_dispatch' }} + id: manual_run uses: ./.github/actions/acc_test with: go-version: ${{ env.GO_VERSION }} @@ -56,9 +67,11 @@ jobs: tf_acc_kek_service_account: ${{ vars.TF_ACC_KEK_SERVICE_ACCOUNT }} tf_debug: ${{ inputs.enable_debug }} test_timeout_string: ${{ inputs.test_timeout_string }} + test_file: ${{ inputs.test_file }} - name: Run Test (automatic) if: ${{ github.event_name != 'workflow_dispatch' }} + id: automatic_run uses: ./.github/actions/acc_test with: go-version: ${{ env.GO_VERSION }} @@ -76,8 +89,8 @@ jobs: with: webhook_url: ${{ secrets.GOOGLE_WEBHOOK_URL }} title: Terraform Acceptance Tests finished - event_title: ${{ github.event.type }} - event_author: ${{ github.event.actor.login }} - event_body: 'No event body.' + event_title: ${{ github.event_name }} + event_author: ${{ github.actor }} + event_body: "${{ steps.automatic_run.outputs.result || steps.manual_run.outputs.result }}" event_number: ${{ github.event.id }} - event_url: "https://tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/actions/runs/${{ github.run_id }}" + event_url: "https://tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/actions/runs/${{ forgejo.run_number }}" diff --git a/stackit/internal/services/sqlserverflexbeta/sqlserverflex_acc_test.go b/stackit/internal/services/sqlserverflexbeta/sqlserverflex_acc_test.go index 77955dd5..656b93df 100644 --- a/stackit/internal/services/sqlserverflexbeta/sqlserverflex_acc_test.go +++ b/stackit/internal/services/sqlserverflexbeta/sqlserverflex_acc_test.go @@ -182,7 +182,7 @@ func TestAccInstance(t *testing.T) { PreConfig: func() { t.Logf("testing: %s - %s", t.Name(), "update name and verify") }, - ExpectNonEmptyPlan: true, + ExpectNonEmptyPlan: false, Config: testutils.StringFromTemplateMust( "testdata/instance_template.gompl", updNameData, @@ -196,6 +196,17 @@ func TestAccInstance(t *testing.T) { defaultNoEncInstanceTestChecks(testInstanceID, updNameData), ), }, + // Expect empty plan after update + { + PreConfig: func() { + t.Logf("testing: %s - %s", t.Name(), "expect empty plan") + }, + ExpectNonEmptyPlan: false, + Config: testutils.StringFromTemplateMust( + "testdata/instance_template.gompl", + updNameData, + ), + }, // Update size and verify { PreConfig: func() { From 7b2dfaea44a2b341511574609fce014d042a10f8 Mon Sep 17 00:00:00 2001 From: Marcel_Henselin Date: Fri, 27 Mar 2026 15:23:30 +0000 Subject: [PATCH 05/10] chore: refactor pipelines (#97) ## Description relates to #1234 ## Checklist - [ ] Issue was linked above - [ ] Code format was applied: `make fmt` - [ ] Examples were added / adjusted (see `examples/` directory) - [x] Docs are up-to-date: `make generate-docs` (will be checked by CI) - [ ] Unit tests got implemented or updated - [ ] Acceptance tests got implemented or updated (see e.g. [here](https://github.com/stackitcloud/terraform-provider-stackit/blob/f5f99d170996b208672ae684b6da53420e369563/stackit/internal/services/dns/dns_acc_test.go)) - [x] Unit tests are passing: `make test` (will be checked by CI) - [x] No linter issues: `make lint` (will be checked by CI) Co-authored-by: Marcel S. Henselin Reviewed-on: https://tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pulls/97 --- .github/actions/acc_test/action.yaml | 26 +++++++----- .github/actions/clean_up/action.yaml | 44 +++++++++++++++++-- .github/actions/notify/action.yaml | 63 ++++++++++++++++++---------- .github/workflows/clean_up.yaml | 20 ++++++++- .github/workflows/tf-acc-test.yaml | 42 ++++++++++++++----- 5 files changed, 145 insertions(+), 50 deletions(-) diff --git a/.github/actions/acc_test/action.yaml b/.github/actions/acc_test/action.yaml index 13674a9a..46565e96 100644 --- a/.github/actions/acc_test/action.yaml +++ b/.github/actions/acc_test/action.yaml @@ -67,9 +67,13 @@ inputs: outputs: result: - value: ${{ steps.testrun.result }} + value: "${{ steps.testrun.result }}" description: "the output of the tests" + status: + value: "${{ steps.status.status }}" + description: "the status of the tests" + runs: using: "composite" steps: @@ -213,6 +217,8 @@ runs: fi testfile="${{ inputs.test_file }}" + + echo "result=no result before run" >> "$GITHUB_OUTPUT" echo "Running acceptance tests for the terraform provider" set +e @@ -230,11 +236,14 @@ runs: echo "::endgroup::" set -e echo "::group::go test result" - if [ $? -ne 0 ]; then + + if [[ $(cat acc_test_run.log | grep "FAIL") ]]; then echo "Test failed, see acc_test_run.log for details" res=$(cat acc_test_run.log | grep -v "=== RUN" | grep -v "\-\-\- PASS" | grep -v "=== CONT" | grep -v "=== PAUSE") - echo "result=${res}" >> "$GITHUB_OUTPUT" + echo "result=FAIL: ${res}" >> "$GITHUB_OUTPUT" exit 1 + else + echo "result=no FAIL detected" >> "$GITHUB_OUTPUT" fi echo "::endgroup::" env: @@ -246,10 +255,12 @@ runs: TF_ACC_KEK_KEY_VERSION: ${{ inputs.tf_acc_kek_key_version }} TF_ACC_KEK_SERVICE_ACCOUNT: ${{ inputs.tf_acc_kek_service_account }} - - name: Artifact upload start + - name: Set status output variable + if: always() + id: status shell: bash run: | - echo "::group::artifact upload" + echo "status=${{ steps.testrun.outcome == 'success' && 'SUCCESS' || 'FAILURE' }}" >> "$GITHUB_OUTPUT" - name: Upload test log artifact if: always() @@ -257,8 +268,3 @@ runs: with: name: acc_test.log path: "stackit/acc_test_run.log" - - - name: Artifact upload finish - shell: bash - run: | - echo "::endgroup::" diff --git a/.github/actions/clean_up/action.yaml b/.github/actions/clean_up/action.yaml index 1cea3615..72ee1dad 100644 --- a/.github/actions/clean_up/action.yaml +++ b/.github/actions/clean_up/action.yaml @@ -41,6 +41,14 @@ outputs: description: "stackit cli version" value: ${{ steps.stackit_version.outputs.version }} + pre_count: + description: "number of resources found" + value: ${{ steps.retrieve_pre.outputs.count }} + + post_count: + description: "number of resources found" + value: ${{ steps.retrieve_post.outputs.count }} + runs: using: "composite" steps: @@ -115,7 +123,8 @@ runs: exit 1 fi - - name: Retrieve resources + - name: Retrieve resources before + id: retrieve_pre run: | echo "::group::retrieve resources" set -e @@ -125,11 +134,15 @@ runs: stackit auth activate-service-account --service-account-key-path .svc_acc.json echo "SQL Server Flex resources:" - stackit --verbosity ${{ inputs.log_level }} --project-id "${{ inputs.project_id }}" beta sqlserverflex instance list --output-format json | jq -r '.[] | select(.name | startswith("${{ inputs.tf_resource_prefix }}"))' + sql_res=$(stackit --verbosity ${{ inputs.log_level }} --project-id "${{ inputs.project_id }}" beta sqlserverflex instance list --output-format json | jq -r '.[] | select(.name | startswith("${{ inputs.tf_resource_prefix }}"))') + sql_count=$(echo "$sql_res" | jq -r '.id' | wc -l) echo "PostgreSQL Flex resources:" - stackit --verbosity ${{ inputs.log_level }} --project-id "${{ inputs.project_id }}" postgresflex instance list --output-format json | jq -r '.[] | select(.name | startswith("${{ inputs.tf_resource_prefix }}"))' + pg_res=$(stackit --verbosity ${{ inputs.log_level }} --project-id "${{ inputs.project_id }}" postgresflex instance list --output-format json | jq -r '.[] | select(.name | startswith("${{ inputs.tf_resource_prefix }}"))') + pg_count=$(echo "$pg_res" | jq -r '.id' | wc -l) + echo "Number of resources found: ${sql_count} SQL Server Flex, ${pg_count} PostgreSQL Flex" + echo "count=$(( ${pg_count} + ${sql_count} ))" >> $GITHUB_OUTPUT echo "::endgroup::" shell: bash @@ -156,7 +169,7 @@ runs: echo "::group::delete PostgreSQL Flex resources" set -e stackit auth activate-service-account --service-account-key-path .svc_acc.json - for s in $(stackit --verbosity ${{ inputs.log_level }} --project-id ${{ inputs.project_id }} postgresflex instance list --output-format json | jq -r '.[] | select(.name | startswith("${{ inputs.tf_resource_prefix }}")) | .id'); do stackit --verbosity ${{ inputs.log_level }} -y --project-id ${{ inputs.project_id }} postgresflex instance delete $s; done + for s in $(stackit --verbosity ${{ inputs.log_level }} --project-id ${{ inputs.project_id }} postgresflex instance list --output-format json | jq -r '.[] | select(.name | startswith("${{ inputs.tf_resource_prefix }}")) | .id'); do stackit --verbosity ${{ inputs.log_level }} -y --project-id ${{ inputs.project_id }} postgresflex instance delete "$s" --force; done echo "::endgroup::" shell: bash @@ -166,3 +179,26 @@ runs: set -e echo "Skip deleting: list only mode" shell: bash + + - name: Retrieve resources after + id: retrieve_post + run: | + echo "::group::retrieve resources" + set -e + echo "authenticating api" + STACKIT_SERVICE_ACCOUNT_KEY_PATH="${PWD}/.svc_acc.json" + export STACKIT_SERVICE_ACCOUNT_KEY_PATH + stackit auth activate-service-account --service-account-key-path .svc_acc.json + + echo "SQL Server Flex resources:" + sql_res=$(stackit --verbosity ${{ inputs.log_level }} --project-id "${{ inputs.project_id }}" beta sqlserverflex instance list --output-format json | jq -r '.[] | select(.name | startswith("${{ inputs.tf_resource_prefix }}"))') + sql_count=$(echo "$sql_res" | jq -r '.id' | wc -l) + + echo "PostgreSQL Flex resources:" + pg_res=$(stackit --verbosity ${{ inputs.log_level }} --project-id "${{ inputs.project_id }}" postgresflex instance list --output-format json | jq -r '.[] | select(.name | startswith("${{ inputs.tf_resource_prefix }}"))') + pg_count=$(echo "$pg_res" | jq -r '.id' | wc -l) + + echo "Number of resources found: ${sql_count} SQL Server Flex, ${pg_count} PostgreSQL Flex" + echo "count=$(( ${pg_count} + ${sql_count} ))" >> $GITHUB_OUTPUT + echo "::endgroup::" + shell: bash diff --git a/.github/actions/notify/action.yaml b/.github/actions/notify/action.yaml index f260d087..2e72732e 100644 --- a/.github/actions/notify/action.yaml +++ b/.github/actions/notify/action.yaml @@ -9,11 +9,17 @@ inputs: title: description: "The title of the notification." required: true - default: 'no title provided' + + subtitle: + description: "The subtitle of the notification." + default: 'no subtitle provided' + + image_slug: + description: "The slug of the image to be included in the notification." + default: 'git' event_author: description: "The author of the event." - required: true default: 'unknown' event_title: @@ -22,35 +28,23 @@ inputs: event_body: description: "The body of the event." - required: true default: 'no body provided' event_number: description: "The number of the event." - required: true default: 'no number provided' event_url: description: "The url of the event." - required: true default: 'none' + status: + description: "The status of the event." + default: 'UNKNOWN' + runs: using: "composite" steps: -# - name: event list -# shell: bash -# run: | -# cat <<'EOF' -# ${{ toJSON(github) }} -# EOF -# -# - name: print env -# shell: bash -# run: | -# env -# exit 1 - - name: Install prerequisites shell: bash run: | @@ -60,6 +54,27 @@ runs: apt install -y curl jq echo "::endgroup::" + - name: Determine status color + id: status + shell: bash + run: | + case "${{ inputs.status }}" in + SUCCESS) + STATUS_COLOR="006400/228b22" + ADD='{"decoratedText": {"startIcon": {"materialIcon": {"name": "check_circle"}},"text": "SUCCESS"}},' + ;; + FAILURE) + STATUS_COLOR="8b0000/dc143c" + ADD='{"decoratedText": {"startIcon": {"materialIcon": {"name": "stop_circle"}},"text": "FAILURE"}},' + ;; + *) + STATUS_COLOR="483d8b/6495ed" + ADD='' + ;; + esac + echo "color=${STATUS_COLOR}" >> "$GITHUB_OUTPUT" + echo "status_add=${ADD}" >> "$GITHUB_OUTPUT" + - name: Notify via Google Chat Webhook shell: bash env: @@ -69,7 +84,8 @@ runs: PAYLOAD=$(jq -n -r \ --arg header "${{ inputs.title }}" \ - --arg repo "${{ github.repository || '' }}" \ + --arg subtitle "${{ inputs.subtitle }}" \ + --arg imgurl "https://cdn.simpleicons.org/${{ inputs.image_slug }}/${{ steps.status.outputs.color }}" \ --arg title "${{ inputs.event_title || 'no event title given' }}" \ --arg body "${{ inputs.event_body || 'no event body given' }}" \ --arg author "${{ inputs.event_author || 'no event author given' }}" \ @@ -77,8 +93,8 @@ runs: '{ "cardsV2": [ { "cardId": "notify-${{ github.run_id }}", "card": { "header": { "title": "\($header)", - "subtitle": "Repo: \($repo)", - "imageUrl": "https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/png/git.png", + "subtitle": "\($subtitle)", + "imageUrl": "\($imgurl)", "imageType": "SQUARE" }, "sections": [ @@ -86,12 +102,13 @@ runs: "header": "\($title)", "collapsible": false, "widgets": [ + ${{ steps.status.outputs.status_add }} { "decoratedText": { - "icon": { + "startIcon": { "knownIcon": "PERSON" }, - "text": "Opened by: \($author)" + "text": "\($author)" } }, { diff --git a/.github/workflows/clean_up.yaml b/.github/workflows/clean_up.yaml index b366488f..d9e61d2c 100644 --- a/.github/workflows/clean_up.yaml +++ b/.github/workflows/clean_up.yaml @@ -38,14 +38,16 @@ jobs: uses: ./.github/actions/notify with: webhook_url: ${{ secrets.GOOGLE_WEBHOOK_URL }} - title: CLEAN UP pipeline started + title: "[START] CLEAN UP pipeline" + subtitle: "${{ forgejo.repository }}" event_title: ${{ forgejo.event_name }} event_author: ${{ forgejo.actor }} - event_body: "Filter: ${{ inputs.res_prefix }}" + event_body: "try to remove all resources with prefix ${{ inputs.res_prefix }}" event_number: ${{ forgejo.run_number }} event_url: "https://tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/actions/runs/${{ forgejo.run_number }}" - name: Clean + id: clean uses: ./.github/actions/clean_up with: project_id: ${{ vars.TF_ACC_PROJECT_ID }} @@ -54,3 +56,17 @@ jobs: service_account_json_content_b64: "${{ secrets.TF_ACC_SERVICE_ACCOUNT_JSON_B64 }}" list_only: ${{ inputs.list_only }} log_level: ${{ inputs.log_level }} + + - name: Notify + if: always() + uses: ./.github/actions/notify + with: + webhook_url: ${{ secrets.GOOGLE_WEBHOOK_URL }} + title: "[END] CLEAN UP pipeline" + subtitle: "${{ forgejo.repository }}" + event_title: ${{ forgejo.event_name }} + event_author: ${{ forgejo.actor }} + event_body: "count before cleaning: ${{ steps.clean.outputs.pre_count }}
count after cleaning: ${{ steps.clean.outputs.post_count }}" + event_number: ${{ forgejo.run_number }} + event_url: "https://tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/actions/runs/${{ forgejo.run_number }}" + status: ${{ steps.clean.outcome == 'success' && 'SUCCESS' || 'FAILURE' }} diff --git a/.github/workflows/tf-acc-test.yaml b/.github/workflows/tf-acc-test.yaml index 642fe63b..504324ba 100644 --- a/.github/workflows/tf-acc-test.yaml +++ b/.github/workflows/tf-acc-test.yaml @@ -40,19 +40,26 @@ jobs: - name: Checkout uses: actions/checkout@v6 + - name: set start time + id: start_time + run: | + echo "time=$(date --rfc-3339=ns)" >> ${GITHUB_ENV} + echo "start=$(date +%s%N)" >> ${GITHUB_ENV} + - name: Notify uses: ./.github/actions/notify with: webhook_url: ${{ secrets.GOOGLE_WEBHOOK_URL }} - title: Terraform Acceptance Tests started - event_title: ${{ github.event_name }} - event_author: ${{ github.actor }} + title: "[START] Terraform Acceptance Tests" + subtitle: "${{ forgejo.event_name }} on branch ${{ forgejo.ref }}" + event_title: "started: ${{ steps.start_time.outputs.time }}" + event_author: ${{ forgejo.actor }} event_body: ${{ inputs.test_file }} - event_number: ${{ github.run_id }} + event_number: ${{ forgejo.run_number }} event_url: "https://tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/actions/runs/${{ forgejo.run_number }}" - name: Run Test (workflow dispatch) - if: ${{ github.event_name == 'workflow_dispatch' }} + if: ${{ forgejo.event_name == 'workflow_dispatch' }} id: manual_run uses: ./.github/actions/acc_test with: @@ -70,7 +77,7 @@ jobs: test_file: ${{ inputs.test_file }} - name: Run Test (automatic) - if: ${{ github.event_name != 'workflow_dispatch' }} + if: ${{ forgejo.event_name != 'workflow_dispatch' }} id: automatic_run uses: ./.github/actions/acc_test with: @@ -84,13 +91,26 @@ jobs: tf_acc_kek_key_version: ${{ vars.TF_ACC_KEK_KEY_VERSION }} tf_acc_kek_service_account: ${{ vars.TF_ACC_KEK_SERVICE_ACCOUNT }} + - name: set end time + id: end_time + run: | + echo "time=$(date --rfc-3339=ns)" >> ${GITHUB_ENV} + end=$(date +%s%N) + echo "end=${end}" >> ${GITHUB_ENV} + start=${{ steps.start_time.outputs.start }} + diff=$((end-start)) + duration=$(printf "%s.%s" "${diff:0: -9}" "${diff: -9:3}") + echo "duration=${duration}" >> ${GITHUB_ENV} + - name: Notify uses: ./.github/actions/notify with: webhook_url: ${{ secrets.GOOGLE_WEBHOOK_URL }} - title: Terraform Acceptance Tests finished - event_title: ${{ github.event_name }} - event_author: ${{ github.actor }} - event_body: "${{ steps.automatic_run.outputs.result || steps.manual_run.outputs.result }}" - event_number: ${{ github.event.id }} + title: "[END] Terraform Acceptance Tests" + subtitle: "${{ forgejo.event_name }} on branch ${{ forgejo.ref }} with status: ${{ forgejo.event_name == 'workflow_dispatch' && steps.manual_run.outputs.status || steps.automatic_run.outputs.status }}" + event_title: "run ended: ${{ steps.end_time.outputs.time }}, duration: ${{ steps.end_time.outputs.duration }} seconds" + event_author: ${{ forgejo.actor }} + event_body: "${{ forgejo.event_name == 'workflow_dispatch' && steps.manual_run.outputs.result || steps.automatic_run.outputs.result }}" + event_number: ${{ forgejo.event.id }} event_url: "https://tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/actions/runs/${{ forgejo.run_number }}" + status: "${{ forgejo.event_name == 'workflow_dispatch' && steps.manual_run.outputs.status || steps.automatic_run.outputs.status }}" From edc5e869ce8a5cc59794c60835c39b46f3e804b0 Mon Sep 17 00:00:00 2001 From: "Marcel S. Henselin" Date: Fri, 27 Mar 2026 16:25:56 +0100 Subject: [PATCH 06/10] fix: empty string on required input [skip ci] --- .github/workflows/tf-acc-test.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/tf-acc-test.yaml b/.github/workflows/tf-acc-test.yaml index 504324ba..be9c4c58 100644 --- a/.github/workflows/tf-acc-test.yaml +++ b/.github/workflows/tf-acc-test.yaml @@ -30,7 +30,6 @@ on: - tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/wait/sqlserverflexbeta - tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexbeta default: '' - required: true jobs: acc_test: From aac1a2ba1723baa140dcf8276a9d980609bdb2b8 Mon Sep 17 00:00:00 2001 From: Marcel_Henselin Date: Fri, 27 Mar 2026 17:07:50 +0000 Subject: [PATCH 07/10] fix: pipeline_fix (#99) ## Description relates to #1234 ## Checklist - [ ] Issue was linked above - [ ] Code format was applied: `make fmt` - [ ] Examples were added / adjusted (see `examples/` directory) - [x] Docs are up-to-date: `make generate-docs` (will be checked by CI) - [ ] Unit tests got implemented or updated - [ ] Acceptance tests got implemented or updated (see e.g. [here](https://github.com/stackitcloud/terraform-provider-stackit/blob/f5f99d170996b208672ae684b6da53420e369563/stackit/internal/services/dns/dns_acc_test.go)) - [x] Unit tests are passing: `make test` (will be checked by CI) - [x] No linter issues: `make lint` (will be checked by CI) Co-authored-by: Marcel S. Henselin Reviewed-on: https://tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pulls/99 --- .github/actions/acc_test/action.yaml | 15 +++++++------- .github/actions/clean_up/action.yaml | 31 ++++++++++++++++++++++++---- .github/workflows/ci_new.yaml | 14 +++++++------ .github/workflows/clean_up.yaml | 4 ++-- .github/workflows/publish.yaml | 28 +++++++++++++++++++------ .github/workflows/tf-acc-test.yaml | 28 +++++++++++++++++-------- 6 files changed, 86 insertions(+), 34 deletions(-) diff --git a/.github/actions/acc_test/action.yaml b/.github/actions/acc_test/action.yaml index 46565e96..79f82298 100644 --- a/.github/actions/acc_test/action.yaml +++ b/.github/actions/acc_test/action.yaml @@ -67,11 +67,11 @@ inputs: outputs: result: - value: "${{ steps.testrun.result }}" + value: ${{ steps.testrun.outputs.result }} description: "the output of the tests" status: - value: "${{ steps.status.status }}" + value: ${{ steps.status.outputs.status }} description: "the status of the tests" runs: @@ -207,7 +207,7 @@ runs: id: testrun shell: bash run: | - echo "::group::go test file" + echo "::group::go test" set -e set -o pipefail @@ -233,18 +233,19 @@ runs: TF_ACC_KEK_KEY_VERSION=${TF_ACC_KEK_KEY_VERSION} \ TF_ACC_KEK_SERVICE_ACCOUNT=${TF_ACC_KEK_SERVICE_ACCOUNT} \ go test -v ${testfile} -timeout=${{ inputs.test_timeout_string }} | tee -a acc_test_run.log - echo "::endgroup::" set -e - echo "::group::go test result" if [[ $(cat acc_test_run.log | grep "FAIL") ]]; then + echo "::endgroup::" + echo "::group::go test result" echo "Test failed, see acc_test_run.log for details" res=$(cat acc_test_run.log | grep -v "=== RUN" | grep -v "\-\-\- PASS" | grep -v "=== CONT" | grep -v "=== PAUSE") echo "result=FAIL: ${res}" >> "$GITHUB_OUTPUT" + echo "::endgroup::" exit 1 - else - echo "result=no FAIL detected" >> "$GITHUB_OUTPUT" fi + + echo "result=no FAIL detected" >> "$GITHUB_OUTPUT" echo "::endgroup::" env: TF_ACC_PROJECT_ID: ${{ inputs.project_id }} diff --git a/.github/actions/clean_up/action.yaml b/.github/actions/clean_up/action.yaml index 72ee1dad..c8e142fa 100644 --- a/.github/actions/clean_up/action.yaml +++ b/.github/actions/clean_up/action.yaml @@ -49,6 +49,10 @@ outputs: description: "number of resources found" value: ${{ steps.retrieve_post.outputs.count }} + status: + description: "status of the test" + value: ${{ steps.status.outputs.status }} + runs: using: "composite" steps: @@ -148,11 +152,14 @@ runs: - name: Delete SQL Server Flex resources if: ${{ inputs.list_only != 'true' }} + id: del_sql run: | echo "::group::delete SQL Server Flex resources" - set -e stackit --verbosity ${{ inputs.log_level }} auth activate-service-account --service-account-key-path .svc_acc.json - for s in $(stackit --verbosity ${{ inputs.log_level }} --project-id ${{ inputs.project_id }} beta sqlserverflex instance list --output-format json | jq -r '.[] | select(.name | startswith("${{ inputs.tf_resource_prefix }}")) | .id'); do stackit --verbosity ${{ inputs.log_level }} -y --project-id ${{ inputs.project_id }} beta sqlserverflex instance delete $s; done + for s in $(stackit --verbosity ${{ inputs.log_level }} --project-id ${{ inputs.project_id }} beta sqlserverflex instance list --output-format json | jq -r '.[] | select(.name | startswith("${{ inputs.tf_resource_prefix }}")) | .id'); + do + stackit --verbosity ${{ inputs.log_level }} -y --project-id ${{ inputs.project_id }} beta sqlserverflex instance delete $s || echo "status=FAILURE" >> ${GITHUB_OUTPUT}; + done echo "::endgroup::" shell: bash @@ -165,11 +172,14 @@ runs: - name: Delete PostgreSQL Flex resources if: ${{ inputs.list_only != 'true' }} + id: del_pg run: | echo "::group::delete PostgreSQL Flex resources" - set -e stackit auth activate-service-account --service-account-key-path .svc_acc.json - for s in $(stackit --verbosity ${{ inputs.log_level }} --project-id ${{ inputs.project_id }} postgresflex instance list --output-format json | jq -r '.[] | select(.name | startswith("${{ inputs.tf_resource_prefix }}")) | .id'); do stackit --verbosity ${{ inputs.log_level }} -y --project-id ${{ inputs.project_id }} postgresflex instance delete "$s" --force; done + for s in $(stackit --verbosity ${{ inputs.log_level }} --project-id ${{ inputs.project_id }} postgresflex instance list --output-format json | jq -r '.[] | select(.name | startswith("${{ inputs.tf_resource_prefix }}")) | .id'); + do + stackit --verbosity ${{ inputs.log_level }} -y --project-id ${{ inputs.project_id }} postgresflex instance delete "$s" --force || echo "status=FAILURE" >> ${GITHUB_OUTPUT}; + done echo "::endgroup::" shell: bash @@ -202,3 +212,16 @@ runs: echo "count=$(( ${pg_count} + ${sql_count} ))" >> $GITHUB_OUTPUT echo "::endgroup::" shell: bash + + - name: Set status + if: always() + id: status + run: | + status="SUCCESS" + if [[ "${{ steps.del_pg.outputs.status }}" == "FAILURE" ]]; then + status=FAILURE" + elif [[ "${{ steps.del_sql.outputs.status }}" == "FAILURE" ]]; then + status=FAILURE" + fi + echo "status=$status" >> $GITHUB_OUTPUT + shell: bash diff --git a/.github/workflows/ci_new.yaml b/.github/workflows/ci_new.yaml index d79f806a..61288df4 100644 --- a/.github/workflows/ci_new.yaml +++ b/.github/workflows/ci_new.yaml @@ -34,15 +34,17 @@ jobs: uses: actions/checkout@v6 - name: Notify + if: always() uses: ./.github/actions/notify with: webhook_url: ${{ secrets.GOOGLE_WEBHOOK_URL }} - title: CI pipeline started - event_title: ${{ github.event.type }} - event_author: ${{ github.event.actor.login }} - event_body: 'No event body.' - event_number: ${{ github.event.id }} - event_url: "https://tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/actions/runs/${{ github.run_id }}" + title: "[START] CI pipeline (#${{ forgejo.run_number }})" + subtitle: "${{ forgejo.event_name }} on ${{ forgejo.ref_name }}" + event_title: "${{ forgejo.event_name }} for ${{ forgejo.repository }}" + event_author: ${{ forgejo.actor }} + event_body: "${{ forgejo.event_name }} on ${{ forgejo.ref }} for ${{ forgejo.repository }}" + event_number: ${{ forgejo.run_number }} + event_url: "https://tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/actions/runs/${{ forgejo.run_number }}" - name: Check GoReleaser uses: goreleaser/goreleaser-action@v7 diff --git a/.github/workflows/clean_up.yaml b/.github/workflows/clean_up.yaml index d9e61d2c..e1cc291b 100644 --- a/.github/workflows/clean_up.yaml +++ b/.github/workflows/clean_up.yaml @@ -38,7 +38,7 @@ jobs: uses: ./.github/actions/notify with: webhook_url: ${{ secrets.GOOGLE_WEBHOOK_URL }} - title: "[START] CLEAN UP pipeline" + title: "[START] CLEAN UP pipeline (#${{ forgejo.run_number }})" subtitle: "${{ forgejo.repository }}" event_title: ${{ forgejo.event_name }} event_author: ${{ forgejo.actor }} @@ -62,7 +62,7 @@ jobs: uses: ./.github/actions/notify with: webhook_url: ${{ secrets.GOOGLE_WEBHOOK_URL }} - title: "[END] CLEAN UP pipeline" + title: "[END] CLEAN UP pipeline (#${{ forgejo.run_number }})" subtitle: "${{ forgejo.repository }}" event_title: ${{ forgejo.event_name }} event_author: ${{ forgejo.actor }} diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 2810d5c4..dbfbc247 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -51,12 +51,13 @@ jobs: uses: ./.github/actions/notify with: webhook_url: ${{ secrets.GOOGLE_WEBHOOK_URL }} - title: Publish started - event_title: ${{ github.event.type }} - event_author: ${{ github.event.actor.login }} - event_body: "Trigger: ${{ github.event_name }}" - event_number: ${{ github.event.id }} - event_url: "https://tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/actions/runs/${{ github.run_id }}" + title: "[START] Publish (#${{ forgejo.run_number }})" + subtitle: "${{ forgejo.event_name }} on branch ${{ forgejo.ref }}" + event_title: "run started" + event_author: ${{ forgejo.actor }} + event_body: "" + event_number: ${{ forgejo.event.id }} + event_url: "https://tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/actions/runs/${{ forgejo.run_number }}" - name: Setup Go uses: actions/setup-go@v6 @@ -145,6 +146,7 @@ jobs: --outFile nav.md - name: Publish provider to S3 + id: publish_to_s3 run: | set -e cd release/ @@ -165,3 +167,17 @@ jobs: # echo "${{ github.ref_name }}" >docs/_version.txt scp -o StrictHostKeyChecking=no -r docs ubuntu@${{ vars.DOCS_SERVER_IP }}:/srv/www/ scp -o StrictHostKeyChecking=no nav.md ubuntu@${{ vars.DOCS_SERVER_IP }}:/srv/www/ + + - name: Notify + if: always() + uses: ./.github/actions/notify + with: + webhook_url: ${{ secrets.GOOGLE_WEBHOOK_URL }} + title: "[END] Publish (#${{ forgejo.run_number }})" + subtitle: "${{ forgejo.event_name }} on branch ${{ forgejo.ref }}" + event_title: "released: ${{ steps.get_version.outputs.version }}" + event_author: ${{ forgejo.actor }} + event_body: "" + event_number: ${{ forgejo.event.id }} + event_url: "https://tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/actions/runs/${{ forgejo.run_number }}" + status: "${{ steps.publish_to_s3.outcome == 'success' && 'SUCCESS' || 'FAILURE' }}" diff --git a/.github/workflows/tf-acc-test.yaml b/.github/workflows/tf-acc-test.yaml index be9c4c58..730fb0ca 100644 --- a/.github/workflows/tf-acc-test.yaml +++ b/.github/workflows/tf-acc-test.yaml @@ -41,17 +41,20 @@ jobs: - name: set start time id: start_time + continue-on-error: true run: | - echo "time=$(date --rfc-3339=ns)" >> ${GITHUB_ENV} - echo "start=$(date +%s%N)" >> ${GITHUB_ENV} + time=$(date --rfc-3339=ns) + echo "start_time=$time" >> ${GITHUB_OUTPUT} + start=$(date +%s%N) + echo "start=$start" >> ${GITHUB_OUTPUT} - name: Notify uses: ./.github/actions/notify with: webhook_url: ${{ secrets.GOOGLE_WEBHOOK_URL }} - title: "[START] Terraform Acceptance Tests" + title: "[START] Terraform Acceptance Tests (#${{ forgejo.run_number }})" subtitle: "${{ forgejo.event_name }} on branch ${{ forgejo.ref }}" - event_title: "started: ${{ steps.start_time.outputs.time }}" + event_title: "started: ${{ steps.start_time.outputs.start_time }}" event_author: ${{ forgejo.actor }} event_body: ${{ inputs.test_file }} event_number: ${{ forgejo.run_number }} @@ -60,6 +63,7 @@ jobs: - name: Run Test (workflow dispatch) if: ${{ forgejo.event_name == 'workflow_dispatch' }} id: manual_run + continue-on-error: true uses: ./.github/actions/acc_test with: go-version: ${{ env.GO_VERSION }} @@ -78,6 +82,7 @@ jobs: - name: Run Test (automatic) if: ${{ forgejo.event_name != 'workflow_dispatch' }} id: automatic_run + continue-on-error: true uses: ./.github/actions/acc_test with: go-version: ${{ env.GO_VERSION }} @@ -92,22 +97,27 @@ jobs: - name: set end time id: end_time + continue-on-error: true run: | - echo "time=$(date --rfc-3339=ns)" >> ${GITHUB_ENV} + set -e + echo "auto status: ${{ steps.automatic_run.outputs.status }}" + echo "manual status: ${{ steps.manual_run.outputs.status }}" + echo "status: ${{ forgejo.event_name == 'workflow_dispatch' && steps.manual_run.outputs.status || steps.automatic_run.outputs.status }}" + echo "end_time=$(date --rfc-3339=ns)" >> ${GITHUB_OUTPUT} end=$(date +%s%N) - echo "end=${end}" >> ${GITHUB_ENV} + echo "end=${end}" >> ${GITHUB_OUTPUT} start=${{ steps.start_time.outputs.start }} diff=$((end-start)) duration=$(printf "%s.%s" "${diff:0: -9}" "${diff: -9:3}") - echo "duration=${duration}" >> ${GITHUB_ENV} + echo "duration=${duration}" >> ${GITHUB_OUTPUT} - name: Notify uses: ./.github/actions/notify with: webhook_url: ${{ secrets.GOOGLE_WEBHOOK_URL }} - title: "[END] Terraform Acceptance Tests" + title: "[END] Terraform Acceptance Tests (#${{ forgejo.run_number }})" subtitle: "${{ forgejo.event_name }} on branch ${{ forgejo.ref }} with status: ${{ forgejo.event_name == 'workflow_dispatch' && steps.manual_run.outputs.status || steps.automatic_run.outputs.status }}" - event_title: "run ended: ${{ steps.end_time.outputs.time }}, duration: ${{ steps.end_time.outputs.duration }} seconds" + event_title: "run ended: ${{ steps.end_time.outputs.end_time }}, duration: ${{ steps.end_time.outputs.duration }} seconds" event_author: ${{ forgejo.actor }} event_body: "${{ forgejo.event_name == 'workflow_dispatch' && steps.manual_run.outputs.result || steps.automatic_run.outputs.result }}" event_number: ${{ forgejo.event.id }} From 9ef7ce90295b3f83af55fb82c2da896c1b3a1d29 Mon Sep 17 00:00:00 2001 From: "Marcel S. Henselin" Date: Fri, 27 Mar 2026 18:33:12 +0100 Subject: [PATCH 08/10] fix: try fix empty outputs [skip ci] --- .github/actions/acc_test/action.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/actions/acc_test/action.yaml b/.github/actions/acc_test/action.yaml index 46565e96..cb492499 100644 --- a/.github/actions/acc_test/action.yaml +++ b/.github/actions/acc_test/action.yaml @@ -221,6 +221,16 @@ runs: echo "result=no result before run" >> "$GITHUB_OUTPUT" echo "Running acceptance tests for the terraform provider" + + if [[ -z "$testfile" ]]; then + test_file="./..." + fi + + if [[ -z "$testfile" ]]; then + echo "ERROR: No test file provided" + exit 1 + fi + set +e cd stackit || exit 1 TF_ACC=1 \ From 6e3d2b51fada196822061679bf0128cf3366d627 Mon Sep 17 00:00:00 2001 From: "Marcel S. Henselin" Date: Fri, 27 Mar 2026 18:34:22 +0100 Subject: [PATCH 09/10] fix: try fix empty outputs [skip ci] --- .github/actions/acc_test/action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/acc_test/action.yaml b/.github/actions/acc_test/action.yaml index cb492499..17c776de 100644 --- a/.github/actions/acc_test/action.yaml +++ b/.github/actions/acc_test/action.yaml @@ -223,7 +223,7 @@ runs: echo "Running acceptance tests for the terraform provider" if [[ -z "$testfile" ]]; then - test_file="./..." + testfile="./..." fi if [[ -z "$testfile" ]]; then From dab47d4690c44f492f6cda0996214b362b5ce91c Mon Sep 17 00:00:00 2001 From: "Marcel S. Henselin" Date: Fri, 27 Mar 2026 21:19:53 +0100 Subject: [PATCH 10/10] fix: try fix test runs [skip ci] --- .github/actions/acc_test/action.yaml | 7 ++++--- .github/workflows/tf-acc-test.yaml | 6 ++++-- .../services/sqlserverflexbeta/sqlserverflex_acc_test.go | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/actions/acc_test/action.yaml b/.github/actions/acc_test/action.yaml index d7c78d1f..e43ceeff 100644 --- a/.github/actions/acc_test/action.yaml +++ b/.github/actions/acc_test/action.yaml @@ -245,12 +245,13 @@ runs: go test -v ${testfile} -timeout=${{ inputs.test_timeout_string }} | tee -a acc_test_run.log set -e - if [[ $(cat acc_test_run.log | grep "FAIL") ]]; then + have_fail=$(cat acc_test_run.log | grep FAIL) + if [[ -n $have_fail ]]; then echo "::endgroup::" echo "::group::go test result" echo "Test failed, see acc_test_run.log for details" - res=$(cat acc_test_run.log | grep -v "=== RUN" | grep -v "\-\-\- PASS" | grep -v "=== CONT" | grep -v "=== PAUSE") - echo "result=FAIL: ${res}" >> "$GITHUB_OUTPUT" + echo "${have_fail}" + echo "result=FAIL:
${have_fail}" >> "$GITHUB_OUTPUT" echo "::endgroup::" exit 1 fi diff --git a/.github/workflows/tf-acc-test.yaml b/.github/workflows/tf-acc-test.yaml index 730fb0ca..91619dde 100644 --- a/.github/workflows/tf-acc-test.yaml +++ b/.github/workflows/tf-acc-test.yaml @@ -16,11 +16,13 @@ on: type: boolean default: false required: true + test_timeout_string: - description: "string that determines the timeout (default: 45m)" + description: "string that determines the timeout (default: '120m')" type: string - default: '90m' + default: '120m' required: true + test_file: description: "string that determines the test file to run (default all tests)" type: choice diff --git a/stackit/internal/services/sqlserverflexbeta/sqlserverflex_acc_test.go b/stackit/internal/services/sqlserverflexbeta/sqlserverflex_acc_test.go index 656b93df..fae56505 100644 --- a/stackit/internal/services/sqlserverflexbeta/sqlserverflex_acc_test.go +++ b/stackit/internal/services/sqlserverflexbeta/sqlserverflex_acc_test.go @@ -212,7 +212,7 @@ func TestAccInstance(t *testing.T) { PreConfig: func() { t.Logf("testing: %s - %s", t.Name(), "update storage.size and verify") }, - ExpectNonEmptyPlan: true, + ExpectNonEmptyPlan: false, Config: testutils.StringFromTemplateMust( "testdata/instance_template.gompl", updSizeData,