Skip to content

Commit

Permalink
ci: correctly clean up failed windows e2e tests (#3059)
Browse files Browse the repository at this point in the history
  • Loading branch information
miampf authored May 3, 2024
1 parent f699908 commit bd26cb5
Showing 1 changed file with 12 additions and 22 deletions.
34 changes: 12 additions & 22 deletions .github/workflows/e2e-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,12 @@ jobs:
azure_credentials: ${{ secrets.AZURE_E2E_IAM_CREDENTIALS }}

- name: Create IAM configuration
id: iam-create
shell: pwsh
run: |
$uid = Get-Random -Minimum 1000 -Maximum 9999
$rgName = "e2e-win-${{ github.run_id }}-${{ github.run_attempt }}-$uid"
"rgName=$($rgName)" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
.\constellation.exe config generate azure -t "workflow=${{ github.run_id }}"
.\constellation.exe iam create azure --region=westus --resourceGroup=$rgName-rg --servicePrincipal=$rgName-sp --update-config --debug -y
Expand Down Expand Up @@ -150,6 +152,7 @@ jobs:
}
- name: Terminate cluster
id: terminate-cluster
if: always()
shell: pwsh
run: |
Expand All @@ -162,11 +165,20 @@ jobs:
azure_credentials: ${{ secrets.AZURE_E2E_IAM_CREDENTIALS }}

- name: Delete IAM configuration
id: delete-iam
if: always()
shell: pwsh
run: |
.\constellation.exe iam destroy --debug -y
- name: Clean up after failure
# run on a cleanup failure or if cancelled
if: (failure() && (steps.terminate-cluster.conclusion == 'failure' || steps.delete-iam.conclusion == 'failure')) || cancelled()
shell: pwsh
run: |
az group delete --name ${{ steps.iam-create.outputs.rgName }}-rg --yes
az group delete --name ${{ steps.iam-create.outputs.rgName }}-rg-identity --yes
notify-failure:
name: Notify about failure
runs-on: ubuntu-22.04
Expand Down Expand Up @@ -196,25 +208,3 @@ jobs:
provider: Azure
attestationVariant: "azure-sev-snp"

upload-tfstate:
name: Upload terraform state if it exists
runs-on: ubuntu-22.04
needs: e2e-test
if: always()
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
ref: ${{ !github.event.pull_request.head.repo.fork && github.head_ref || '' }}

- name: Upload tfstate
if: always()
env:
GH_TOKEN: ${{ github.token }}
uses: ./.github/actions/update_tfstate
with:
name: terraform-state-${{ github.run_id }}
runID: ${{ github.run_id }}
encryptionSecret: ${{ secrets.ARTIFACT_ENCRYPT_PASSWD }}
skipDeletion: "true"

0 comments on commit bd26cb5

Please sign in to comment.