## Description
<!-- **Please link some issue here describing what you are trying to achieve.**
In case there is no issue present for your PR, please consider creating one.
At least please give us some description what you are trying to achieve and why your change is needed. -->
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](f5f99d1709/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 <marcel.henselin@stackit.cloud>
Reviewed-on: #99
125 lines
5.8 KiB
YAML
125 lines
5.8 KiB
YAML
name: TF Acceptance Tests Workflow
|
|
|
|
on:
|
|
pull_request:
|
|
types: [opened, synchronize, reopened]
|
|
branches:
|
|
- alpha
|
|
- main
|
|
push:
|
|
branches:
|
|
- master
|
|
workflow_dispatch:
|
|
inputs:
|
|
enable_debug:
|
|
description: "enable terraform debug logs"
|
|
type: boolean
|
|
default: false
|
|
required: true
|
|
test_timeout_string:
|
|
description: "string that determines the timeout (default: 45m)"
|
|
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: ''
|
|
|
|
jobs:
|
|
acc_test:
|
|
name: Acceptance Tests
|
|
runs-on: stackit-docker
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v6
|
|
|
|
- name: set start time
|
|
id: start_time
|
|
continue-on-error: true
|
|
run: |
|
|
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 (#${{ forgejo.run_number }})"
|
|
subtitle: "${{ forgejo.event_name }} on branch ${{ forgejo.ref }}"
|
|
event_title: "started: ${{ steps.start_time.outputs.start_time }}"
|
|
event_author: ${{ forgejo.actor }}
|
|
event_body: ${{ inputs.test_file }}
|
|
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: ${{ forgejo.event_name == 'workflow_dispatch' }}
|
|
id: manual_run
|
|
continue-on-error: true
|
|
uses: ./.github/actions/acc_test
|
|
with:
|
|
go-version: ${{ env.GO_VERSION }}
|
|
project_id: ${{ vars.TF_ACC_PROJECT_ID }}
|
|
region: 'eu01'
|
|
service_account_json_content_b64: "${{ secrets.TF_ACC_SERVICE_ACCOUNT_JSON_B64 }}"
|
|
project_user_email: ${{ vars.TEST_PROJECT_USER_EMAIL }}
|
|
tf_acc_kek_key_id: ${{ vars.TF_ACC_KEK_KEY_ID }}
|
|
tf_acc_kek_key_ring_id: ${{ vars.TF_ACC_KEK_KEY_RING_ID }}
|
|
tf_acc_kek_key_version: ${{ vars.TF_ACC_KEK_KEY_VERSION }}
|
|
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: ${{ forgejo.event_name != 'workflow_dispatch' }}
|
|
id: automatic_run
|
|
continue-on-error: true
|
|
uses: ./.github/actions/acc_test
|
|
with:
|
|
go-version: ${{ env.GO_VERSION }}
|
|
project_id: ${{ vars.TF_ACC_PROJECT_ID }}
|
|
region: 'eu01'
|
|
service_account_json_content_b64: "${{ secrets.TF_ACC_SERVICE_ACCOUNT_JSON_B64 }}"
|
|
project_user_email: ${{ vars.TEST_PROJECT_USER_EMAIL }}
|
|
tf_acc_kek_key_id: ${{ vars.TF_ACC_KEK_KEY_ID }}
|
|
tf_acc_kek_key_ring_id: ${{ vars.TF_ACC_KEK_KEY_RING_ID }}
|
|
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
|
|
continue-on-error: true
|
|
run: |
|
|
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_OUTPUT}
|
|
start=${{ steps.start_time.outputs.start }}
|
|
diff=$((end-start))
|
|
duration=$(printf "%s.%s" "${diff:0: -9}" "${diff: -9:3}")
|
|
echo "duration=${duration}" >> ${GITHUB_OUTPUT}
|
|
|
|
- name: Notify
|
|
uses: ./.github/actions/notify
|
|
with:
|
|
webhook_url: ${{ secrets.GOOGLE_WEBHOOK_URL }}
|
|
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.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 }}
|
|
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 }}"
|