From 23814c53b852b4c7cf9ff39f7d9d15cde6c76132 Mon Sep 17 00:00:00 2001 From: miampf Date: Wed, 27 Mar 2024 15:34:15 +0100 Subject: [PATCH] added new logic to other tests added manual logic to e2e-upgrade.yml --- .github/workflows/e2e-test-daily.yml | 27 +++++++++- .github/workflows/e2e-test-release.yml | 27 +++++++++- .github/workflows/e2e-test-weekly.yml | 27 +++++++++- .github/workflows/e2e-upgrade.yml | 69 ++++++++++++++++++++++++++ 4 files changed, 144 insertions(+), 6 deletions(-) diff --git a/.github/workflows/e2e-test-daily.yml b/.github/workflows/e2e-test-daily.yml index a5576cef9..2b4e52006 100644 --- a/.github/workflows/e2e-test-daily.yml +++ b/.github/workflows/e2e-test-daily.yml @@ -56,6 +56,7 @@ jobs: checks: write contents: read packages: write + actions: write needs: [find-latest-image] steps: - name: Check out repository @@ -122,20 +123,43 @@ jobs: azureCredentials: ${{ secrets.AZURE_E2E_IAM_CREDENTIALS }} gcpServiceAccount: "iam-e2e@constellation-e2e.iam.gserviceaccount.com" + - name: Check if tfstate should be deleted + if: always() + shell: bash + run: | + if [ ! -d constellation-terraform ] && [ ! -d constellation-iam-terraform ]; then + echo "DELETE_TF_STATE=true" >> "$GITHUB_ENV" + else + echo "DELETE_TF_STATE=false" >> "$GITHUB_ENV" + fi + + - name: Delete tfstate artifact if necessary + if: env.DELETE_TF_STATE == 'true' + env: + GH_TOKEN: ${{ github.token }} + uses: ./.github/actions/artifact_delete + with: + name: terraform-state-${{ steps.e2e_test.outputs.namePrefix }} + workflowID: ${{ github.run_id }} + - name: Prepare terraform state folders if: always() shell: bash run: | rm -rf to-zip/* + to_upload="" if [ -d constellation-terraform ]; then cp -r constellation-terraform to-zip rm to-zip/constellation-terraform/plan.zip rm -rf to-zip/constellation-terraform/.terraform + to_upload+="to-zip/constellation-terraform" fi if [ -d constellation-iam-terraform ]; then cp -r constellation-iam-terraform to-zip rm -rf to-zip/constellation-iam-terraform/.terraform + to_upload+=" to-zip/constellation-iam-terraform" fi + echo "TO_UPLOAD=$to_upload" >> "$GITHUB_ENV" - name: Update tfstate if: always() @@ -143,8 +167,7 @@ jobs: with: name: terraform-state-${{ steps.e2e_test.outputs.namePrefix }} path: > - to-zip/constellation-terraform - to-zip/constellation-iam-terraform + ${{ env.TO_UPLOAD }} encryptionSecret: ${{ secrets.ARTIFACT_ENCRYPT_PASSWD }} overwrite: true diff --git a/.github/workflows/e2e-test-release.yml b/.github/workflows/e2e-test-release.yml index 177854239..b2592e457 100644 --- a/.github/workflows/e2e-test-release.yml +++ b/.github/workflows/e2e-test-release.yml @@ -303,6 +303,7 @@ jobs: checks: write contents: read packages: write + actions: write steps: - name: Install the basics tools (macOS) if: runner.os == 'macOS' @@ -378,20 +379,43 @@ jobs: azureCredentials: ${{ secrets.AZURE_E2E_IAM_CREDENTIALS }} gcpServiceAccount: "iam-e2e@constellation-e2e.iam.gserviceaccount.com" + - name: Check if tfstate should be deleted + if: always() + shell: bash + run: | + if [ ! -d constellation-terraform ] && [ ! -d constellation-iam-terraform ]; then + echo "DELETE_TF_STATE=true" >> "$GITHUB_ENV" + else + echo "DELETE_TF_STATE=false" >> "$GITHUB_ENV" + fi + + - name: Delete tfstate artifact if necessary + if: env.DELETE_TF_STATE == 'true' + env: + GH_TOKEN: ${{ github.token }} + uses: ./.github/actions/artifact_delete + with: + name: terraform-state-${{ steps.e2e_test.outputs.namePrefix }} + workflowID: ${{ github.run_id }} + - name: Prepare terraform state folders if: always() shell: bash run: | rm -rf to-zip/* + to_upload="" if [ -d constellation-terraform ]; then cp -r constellation-terraform to-zip rm to-zip/constellation-terraform/plan.zip rm -rf to-zip/constellation-terraform/.terraform + to_upload+="to-zip/constellation-terraform" fi if [ -d constellation-iam-terraform ]; then cp -r constellation-iam-terraform to-zip rm -rf to-zip/constellation-iam-terraform/.terraform + to_upload+=" to-zip/constellation-iam-terraform" fi + echo "TO_UPLOAD=$to_upload" >> "$GITHUB_ENV" - name: Update tfstate if: always() @@ -399,8 +423,7 @@ jobs: with: name: terraform-state-${{ steps.e2e_test.outputs.namePrefix }} path: > - to-zip/constellation-terraform - to-zip/constellation-iam-terraform + ${{ env.TO_UPLOAD }} encryptionSecret: ${{ secrets.ARTIFACT_ENCRYPT_PASSWD }} overwrite: true diff --git a/.github/workflows/e2e-test-weekly.yml b/.github/workflows/e2e-test-weekly.yml index af5da0572..888b55272 100644 --- a/.github/workflows/e2e-test-weekly.yml +++ b/.github/workflows/e2e-test-weekly.yml @@ -309,6 +309,7 @@ jobs: checks: write contents: read packages: write + actions: write needs: [find-latest-image] steps: - name: Check out repository @@ -378,20 +379,43 @@ jobs: azureCredentials: ${{ secrets.AZURE_E2E_IAM_CREDENTIALS }} gcpServiceAccount: "iam-e2e@constellation-e2e.iam.gserviceaccount.com" + - name: Check if tfstate should be deleted + if: always() + shell: bash + run: | + if [ ! -d constellation-terraform ] && [ ! -d constellation-iam-terraform ]; then + echo "DELETE_TF_STATE=true" >> "$GITHUB_ENV" + else + echo "DELETE_TF_STATE=false" >> "$GITHUB_ENV" + fi + + - name: Delete tfstate artifact if necessary + if: env.DELETE_TF_STATE == 'true' + env: + GH_TOKEN: ${{ github.token }} + uses: ./.github/actions/artifact_delete + with: + name: terraform-state-${{ steps.e2e_test.outputs.namePrefix }} + workflowID: ${{ github.run_id }} + - name: Prepare terraform state folders if: always() shell: bash run: | rm -rf to-zip/* + to_upload="" if [ -d constellation-terraform ]; then cp -r constellation-terraform to-zip rm to-zip/constellation-terraform/plan.zip rm -rf to-zip/constellation-terraform/.terraform + to_upload+="to-zip/constellation-terraform" fi if [ -d constellation-iam-terraform ]; then cp -r constellation-iam-terraform to-zip rm -rf to-zip/constellation-iam-terraform/.terraform + to_upload+=" to-zip/constellation-iam-terraform" fi + echo "TO_UPLOAD=$to_upload" >> "$GITHUB_ENV" - name: Update tfstate if: always() @@ -399,8 +423,7 @@ jobs: with: name: terraform-state-${{ steps.e2e_test.outputs.namePrefix }} path: > - to-zip/constellation-terraform - to-zip/constellation-iam-terraform + ${{ env.TO_UPLOAD }} encryptionSecret: ${{ secrets.ARTIFACT_ENCRYPT_PASSWD }} overwrite: true diff --git a/.github/workflows/e2e-upgrade.yml b/.github/workflows/e2e-upgrade.yml index 34ff34a25..28ad786d9 100644 --- a/.github/workflows/e2e-upgrade.yml +++ b/.github/workflows/e2e-upgrade.yml @@ -505,6 +505,27 @@ jobs: constellation-version.yaml encryptionSecret: ${{ secrets.ARTIFACT_ENCRYPT_PASSWD }} + - name: Prepare terraform state + if: always() + shell: bash + run: | + mkdir -p to-zip + cp -r constellation-terraform to-zip + rm to-zip/constellation-terraform/plan.zip + rm -rf to-zip/constellation-terraform/.terraform + cp -r constellation-iam-terraform to-zip + rm -rf to-zip/constellation-iam-terraform/.terraform + + - name: Upload terraform state + if: always() + uses: ./.github/actions/artifact_upload + with: + name: terraform-state-${{ github.run_id }} + path: > + to-zip/constellation-terraform + to-zip/constellation-iam-terraform + encryptionSecret: ${{ secrets.ARTIFACT_ENCRYPT_PASSWD }} + - name: Always terminate cluster if: always() uses: ./.github/actions/constellation_destroy @@ -523,6 +544,54 @@ jobs: azureCredentials: ${{ secrets.AZURE_E2E_IAM_CREDENTIALS }} gcpServiceAccount: "iam-e2e@constellation-e2e.iam.gserviceaccount.com" + - name: Check if tfstate should be deleted + if: always() + shell: bash + run: | + if [ ! -d constellation-terraform ] && [ ! -d constellation-iam-terraform ]; then + echo "DELETE_TF_STATE=true" >> "$GITHUB_ENV" + else + echo "DELETE_TF_STATE=false" >> "$GITHUB_ENV" + fi + + - name: Delete tfstate artifact if necessary + if: env.DELETE_TF_STATE == 'true' + env: + GH_TOKEN: ${{ github.token }} + uses: ./.github/actions/artifact_delete + with: + name: terraform-state-${{ github.run_id }} + workflowID: ${{ github.run_id }} + + - name: Prepare terraform state folders + if: always() + shell: bash + run: | + rm -rf to-zip/* + to_upload="" + if [ -d constellation-terraform ]; then + cp -r constellation-terraform to-zip + rm to-zip/constellation-terraform/plan.zip + rm -rf to-zip/constellation-terraform/.terraform + to_upload+="to-zip/constellation-terraform" + fi + if [ -d constellation-iam-terraform ]; then + cp -r constellation-iam-terraform to-zip + rm -rf to-zip/constellation-iam-terraform/.terraform + to_upload+=" to-zip/constellation-iam-terraform" + fi + echo "TO_UPLOAD=$to_upload" >> "$GITHUB_ENV" + + - name: Update tfstate + if: always() + uses: ./.github/actions/artifact_upload + with: + name: terraform-state-${{ github.run_id }} + path: > + ${{ env.TO_UPLOAD }} + encryptionSecret: ${{ secrets.ARTIFACT_ENCRYPT_PASSWD }} + overwrite: true + - name: Notify about failure if: | always() &&