ci: clean up failed miniconstellation e2e tests (#3109)

This commit is contained in:
miampf 2024-05-31 13:51:55 +02:00 committed by GitHub
parent 79d3781f3e
commit fbdc8f6e85
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 32 additions and 0 deletions

View File

@ -11,6 +11,9 @@ inputs:
azureTenantID:
description: "Azure tenant to use for login with OIDC"
required: true
azureIAMCredentials:
description: "Azure IAM credentials used for cleaning up resources"
required: true
registry:
description: "Container registry to use"
required: true
@ -38,9 +41,26 @@ runs:
- name: MiniConstellation E2E
shell: bash
id: e2e-test
env:
ARM_CLIENT_ID: ${{ inputs.azureClientID }}
ARM_SUBSCRIPTION_ID: ${{ inputs.azureSubscriptionID }}
ARM_TENANT_ID: ${{ inputs.azureTenantID }}
run: |
bazel run --test_timeout=14400 //e2e/miniconstellation:push_remote_test
- name: Log in to azure
# only log in if e2e test failed or if the run was cancelled
if: (failure() && steps.e2e-test.conclusion == 'failure') || cancelled()
uses: ./.github/actions/login_azure
with:
azure_credentials: ${{ inputs.azureIAMCredentials }}
- name: Clean up after failure
shell: bash
# clean up if e2e test failed or if the run was cancelled
if: (failure() && steps.e2e-test.conclusion == 'failure') || cancelled()
run: |
rg_name=${{ steps.e2e-test.outputs.rgname }}
echo "[*] Deleting resource group $rg_name"
az group delete -y --resource-group "$rg_name"

View File

@ -46,5 +46,6 @@ jobs:
azureClientID: ${{ secrets.AZURE_E2E_MINI_CLIENT_ID }}
azureSubscriptionID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
azureTenantID: ${{ secrets.AZURE_TENANT_ID }}
azureIAMCredentials: ${{ secrets.AZURE_E2E_IAM_CREDENTIALS }}
registry: ghcr.io
githubToken: ${{ secrets.GITHUB_TOKEN }}

View File

@ -181,6 +181,7 @@ jobs:
azureClientID: ${{ secrets.AZURE_E2E_MINI_CLIENT_ID }}
azureSubscriptionID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
azureTenantID: ${{ secrets.AZURE_TENANT_ID }}
azureIAMCredentials: ${{ secrets.AZURE_E2E_IAM_CREDENTIALS }}
registry: ghcr.io
githubToken: ${{ secrets.GITHUB_TOKEN }}

View File

@ -455,6 +455,7 @@ jobs:
azureClientID: ${{ secrets.AZURE_E2E_MINI_CLIENT_ID }}
azureSubscriptionID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
azureTenantID: ${{ secrets.AZURE_TENANT_ID }}
azureIAMCredentials: ${{ secrets.AZURE_E2E_IAM_CREDENTIALS }}
registry: ghcr.io
githubToken: ${{ secrets.GITHUB_TOKEN }}

View File

@ -28,6 +28,9 @@ terraform apply -auto-approve
terraform output -raw ssh_private_key > id_rsa
chmod 600 id_rsa
rg_name=$(terraform output -raw rg_name)
echo "rgname=$rg_name" >> "${GITHUB_OUTPUT:-/dev/null}"
azure_vm_ip=$(terraform output -raw public_ip)
echo "::endgroup::"

View File

@ -9,3 +9,9 @@ output "ssh_private_key" {
sensitive = true
depends_on = [tls_private_key.ssh_key]
}
output "rg_name" {
value = "e2e-mini-${random_string.suffix.result}"
sensitive = false
depends_on = [random_string.suffix]
}