fix: pipeline_fix #99

Merged
marcel.henselin merged 13 commits from fix/pipeline_fix into main 2026-03-27 17:07:51 +00:00
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
@ -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 }}

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

View file

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

View file

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

View file

@ -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' }}"

View file

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