Merge branch 'main' into fix/acc_test
Some checks failed
CI Workflow / Check GoReleaser config (pull_request) Failing after 1m16s
CI Workflow / Prepare GO cache (pull_request) Successful in 6m2s
CI Workflow / Test readiness for publishing provider (pull_request) Has been skipped
CI Workflow / CI run tests (pull_request) Has been skipped
CI Workflow / CI run build and linting (pull_request) Has been skipped
CI Workflow / Code coverage report (pull_request) Has been skipped
TF Acceptance Tests Workflow / Acceptance Tests (pull_request) Successful in 1h40m49s

This commit is contained in:
Marcel_Henselin 2026-03-27 17:34:38 +00:00
commit f7b022ec6c
Signed by: tf-provider.git.onstackit.cloud
GPG key ID: 6D7E8A1ED8955A9C
6 changed files with 86 additions and 34 deletions

View file

@ -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
@ -243,18 +243,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 }}

View file

@ -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