chore: refactor pipelines #96
4 changed files with 74 additions and 65 deletions
85
.github/actions/acc_test/action.yaml
vendored
85
.github/actions/acc_test/action.yaml
vendored
|
|
@ -65,6 +65,11 @@ inputs:
|
||||||
description: "testfile to run"
|
description: "testfile to run"
|
||||||
default: ''
|
default: ''
|
||||||
|
|
||||||
|
outputs:
|
||||||
|
result:
|
||||||
|
value: ${{ steps.testrun.result }}
|
||||||
|
description: "the output of the tests"
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: "composite"
|
using: "composite"
|
||||||
steps:
|
steps:
|
||||||
|
|
@ -88,6 +93,10 @@ runs:
|
||||||
with:
|
with:
|
||||||
terraform_wrapper: false
|
terraform_wrapper: false
|
||||||
|
|
||||||
|
- uses: actions/setup-node@v6
|
||||||
|
with:
|
||||||
|
node-version: '24.x'
|
||||||
|
|
||||||
- name: Setup JAVA
|
- name: Setup JAVA
|
||||||
uses: actions/setup-java@v5
|
uses: actions/setup-java@v5
|
||||||
with:
|
with:
|
||||||
|
|
@ -190,8 +199,8 @@ runs:
|
||||||
ls -l stackit/"${{ inputs.service_account_json_file_path }}"
|
ls -l stackit/"${{ inputs.service_account_json_file_path }}"
|
||||||
echo "::endgroup::"
|
echo "::endgroup::"
|
||||||
|
|
||||||
- name: Run acceptance test file
|
- name: Run acceptance tests
|
||||||
if: ${{ inputs.test_file != '' }}
|
id: testrun
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
echo "::group::go test file"
|
echo "::group::go test file"
|
||||||
|
|
@ -203,7 +212,10 @@ runs:
|
||||||
export TF_LOG
|
export TF_LOG
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
testfile="${{ inputs.test_file }}"
|
||||||
|
|
||||||
echo "Running acceptance tests for the terraform provider"
|
echo "Running acceptance tests for the terraform provider"
|
||||||
|
set +e
|
||||||
cd stackit || exit 1
|
cd stackit || exit 1
|
||||||
TF_ACC=1 \
|
TF_ACC=1 \
|
||||||
TF_ACC_PROJECT_ID=${TF_ACC_PROJECT_ID} \
|
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_RING_ID=${TF_ACC_KEK_KEY_RING_ID} \
|
||||||
TF_ACC_KEK_KEY_VERSION=${TF_ACC_KEK_KEY_VERSION} \
|
TF_ACC_KEK_KEY_VERSION=${TF_ACC_KEK_KEY_VERSION} \
|
||||||
TF_ACC_KEK_SERVICE_ACCOUNT=${TF_ACC_KEK_SERVICE_ACCOUNT} \
|
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::"
|
echo "::endgroup::"
|
||||||
env:
|
env:
|
||||||
TF_ACC_PROJECT_ID: ${{ inputs.project_id }}
|
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_KEY_VERSION: ${{ inputs.tf_acc_kek_key_version }}
|
||||||
TF_ACC_KEK_SERVICE_ACCOUNT: ${{ inputs.tf_acc_kek_service_account }}
|
TF_ACC_KEK_SERVICE_ACCOUNT: ${{ inputs.tf_acc_kek_service_account }}
|
||||||
|
|
||||||
# does not work correctly
|
- name: Artifact upload start
|
||||||
# - 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 == '' }}
|
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
echo "::group::go test all"
|
echo "::group::artifact upload"
|
||||||
set -e
|
|
||||||
set -o pipefail
|
|
||||||
|
|
||||||
if [[ "${{ inputs.tf_debug }}" == "true" ]]; then
|
- name: Upload test log artifact
|
||||||
TF_LOG=INFO
|
if: always()
|
||||||
export TF_LOG
|
uses: actions/upload-artifact@v3
|
||||||
fi
|
with:
|
||||||
|
name: acc_test.log
|
||||||
|
path: "stackit/acc_test_run.log"
|
||||||
|
|
||||||
echo "Running acceptance tests for the terraform provider"
|
- name: Artifact upload finish
|
||||||
cd stackit || exit 1
|
shell: bash
|
||||||
TF_ACC=1 \
|
run: |
|
||||||
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 }}
|
|
||||||
echo "::endgroup::"
|
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 }}
|
|
||||||
|
|
|
||||||
10
.github/workflows/clean_up.yaml
vendored
10
.github/workflows/clean_up.yaml
vendored
|
|
@ -38,12 +38,12 @@ jobs:
|
||||||
uses: ./.github/actions/notify
|
uses: ./.github/actions/notify
|
||||||
with:
|
with:
|
||||||
webhook_url: ${{ secrets.GOOGLE_WEBHOOK_URL }}
|
webhook_url: ${{ secrets.GOOGLE_WEBHOOK_URL }}
|
||||||
title: CI pipeline started
|
title: CLEAN UP pipeline started
|
||||||
event_title: ${{ github.event.type }}
|
event_title: ${{ forgejo.event_name }}
|
||||||
event_author: ${{ github.event.actor.login }}
|
event_author: ${{ forgejo.actor }}
|
||||||
event_body: "Filter: ${{ inputs.res_prefix }}"
|
event_body: "Filter: ${{ inputs.res_prefix }}"
|
||||||
event_number: ${{ github.event.id }}
|
event_number: ${{ forgejo.run_number }}
|
||||||
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 }}"
|
||||||
|
|
||||||
- name: Clean
|
- name: Clean
|
||||||
uses: ./.github/actions/clean_up
|
uses: ./.github/actions/clean_up
|
||||||
|
|
|
||||||
31
.github/workflows/tf-acc-test.yaml
vendored
31
.github/workflows/tf-acc-test.yaml
vendored
|
|
@ -21,6 +21,16 @@ on:
|
||||||
type: string
|
type: string
|
||||||
default: '90m'
|
default: '90m'
|
||||||
required: true
|
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:
|
jobs:
|
||||||
acc_test:
|
acc_test:
|
||||||
|
|
@ -35,14 +45,15 @@ jobs:
|
||||||
with:
|
with:
|
||||||
webhook_url: ${{ secrets.GOOGLE_WEBHOOK_URL }}
|
webhook_url: ${{ secrets.GOOGLE_WEBHOOK_URL }}
|
||||||
title: Terraform Acceptance Tests started
|
title: Terraform Acceptance Tests started
|
||||||
event_title: ${{ github.event.type }}
|
event_title: ${{ github.event_name }}
|
||||||
event_author: ${{ github.event.actor.login }}
|
event_author: ${{ github.actor }}
|
||||||
event_body: 'No event body.'
|
event_body: ${{ inputs.test_file }}
|
||||||
event_number: ${{ github.event.id }}
|
event_number: ${{ github.run_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 }}"
|
||||||
|
|
||||||
- name: Run Test (workflow dispatch)
|
- name: Run Test (workflow dispatch)
|
||||||
if: ${{ github.event_name == 'workflow_dispatch' }}
|
if: ${{ github.event_name == 'workflow_dispatch' }}
|
||||||
|
id: manual_run
|
||||||
uses: ./.github/actions/acc_test
|
uses: ./.github/actions/acc_test
|
||||||
with:
|
with:
|
||||||
go-version: ${{ env.GO_VERSION }}
|
go-version: ${{ env.GO_VERSION }}
|
||||||
|
|
@ -56,9 +67,11 @@ jobs:
|
||||||
tf_acc_kek_service_account: ${{ vars.TF_ACC_KEK_SERVICE_ACCOUNT }}
|
tf_acc_kek_service_account: ${{ vars.TF_ACC_KEK_SERVICE_ACCOUNT }}
|
||||||
tf_debug: ${{ inputs.enable_debug }}
|
tf_debug: ${{ inputs.enable_debug }}
|
||||||
test_timeout_string: ${{ inputs.test_timeout_string }}
|
test_timeout_string: ${{ inputs.test_timeout_string }}
|
||||||
|
test_file: ${{ inputs.test_file }}
|
||||||
|
|
||||||
- name: Run Test (automatic)
|
- name: Run Test (automatic)
|
||||||
if: ${{ github.event_name != 'workflow_dispatch' }}
|
if: ${{ github.event_name != 'workflow_dispatch' }}
|
||||||
|
id: automatic_run
|
||||||
uses: ./.github/actions/acc_test
|
uses: ./.github/actions/acc_test
|
||||||
with:
|
with:
|
||||||
go-version: ${{ env.GO_VERSION }}
|
go-version: ${{ env.GO_VERSION }}
|
||||||
|
|
@ -76,8 +89,8 @@ jobs:
|
||||||
with:
|
with:
|
||||||
webhook_url: ${{ secrets.GOOGLE_WEBHOOK_URL }}
|
webhook_url: ${{ secrets.GOOGLE_WEBHOOK_URL }}
|
||||||
title: Terraform Acceptance Tests finished
|
title: Terraform Acceptance Tests finished
|
||||||
event_title: ${{ github.event.type }}
|
event_title: ${{ github.event_name }}
|
||||||
event_author: ${{ github.event.actor.login }}
|
event_author: ${{ github.actor }}
|
||||||
event_body: 'No event body.'
|
event_body: "${{ steps.automatic_run.outputs.result || steps.manual_run.outputs.result }}"
|
||||||
event_number: ${{ github.event.id }}
|
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 }}"
|
||||||
|
|
|
||||||
|
|
@ -182,7 +182,7 @@ func TestAccInstance(t *testing.T) {
|
||||||
PreConfig: func() {
|
PreConfig: func() {
|
||||||
t.Logf("testing: %s - %s", t.Name(), "update name and verify")
|
t.Logf("testing: %s - %s", t.Name(), "update name and verify")
|
||||||
},
|
},
|
||||||
ExpectNonEmptyPlan: true,
|
ExpectNonEmptyPlan: false,
|
||||||
Config: testutils.StringFromTemplateMust(
|
Config: testutils.StringFromTemplateMust(
|
||||||
"testdata/instance_template.gompl",
|
"testdata/instance_template.gompl",
|
||||||
updNameData,
|
updNameData,
|
||||||
|
|
@ -196,6 +196,17 @@ func TestAccInstance(t *testing.T) {
|
||||||
defaultNoEncInstanceTestChecks(testInstanceID, updNameData),
|
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
|
// Update size and verify
|
||||||
{
|
{
|
||||||
PreConfig: func() {
|
PreConfig: func() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue