From 4fd0af548cf8048845948f1f6bd6b94901783ff5 Mon Sep 17 00:00:00 2001 From: Andrew Pearce Date: Tue, 3 Oct 2023 16:44:13 +0100 Subject: [PATCH] MLPAB-1419 - Use a single persistent environment for weblate changes optimise workflow (#741) * exclude this test weblate pr branch * run a weblate workflow only for a webalte branch * reconfigure conditions * use a webalte environment and skip long tests * remove account level changes as they won't be part of changes from weblate * remove ui tests on image * fix issue with end of line * add weblate-pr branch: * don't run on push from a webalte branch * only run ui tests when it's not the weblate branch * use the correct branch for now * force a build * full ref * print head_ref * fix expression * use contains * no need for if * wrap * force a build and run smoke for webalte pr * if weblate pr then workspace is weblate * weblate is a protected environmetn * cleanup --- .github/workflows/tags_job.yml | 3 +++ .github/workflows/terraform_environment_job.yml | 2 +- .github/workflows/workflow_pr.yml | 1 + scripts/workspace_cleanup.sh | 2 +- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tags_job.yml b/.github/workflows/tags_job.yml index d6e3c50b12..babbfc159c 100644 --- a/.github/workflows/tags_job.yml +++ b/.github/workflows/tags_job.yml @@ -62,6 +62,9 @@ jobs: workspace=${workspace//\/} workspace=${workspace:0:11} workspace=$(echo ${workspace} | tr '[:upper:]' '[:lower:]') + if ${{ contains(fromJSON('["MLPAB-1419-use-a-single-persistent-environment-for-weblate-changes-optimise-workflow", "weblate-pr"]'), github.head_ref) }}; then + workspace="weblate" + fi echo "name=${workspace}" >> $GITHUB_OUTPUT echo ${workspace} outputs: diff --git a/.github/workflows/terraform_environment_job.yml b/.github/workflows/terraform_environment_job.yml index a63b28567a..4dbf196225 100644 --- a/.github/workflows/terraform_environment_job.yml +++ b/.github/workflows/terraform_environment_job.yml @@ -157,7 +157,7 @@ jobs: } - name: Protect environment workspace - if: github.workflow == '[Workflow] PR' + if: github.event_name == 'pull_request' && inputs.workspace_name != 'weblate' env: TF_WORKSPACE: ${{ inputs.workspace_name }} TF_VAR_container_version: ${{ inputs.version_tag }} diff --git a/.github/workflows/workflow_pr.yml b/.github/workflows/workflow_pr.yml index efb9be6929..60a70fd158 100644 --- a/.github/workflows/workflow_pr.yml +++ b/.github/workflows/workflow_pr.yml @@ -96,6 +96,7 @@ jobs: with: run_against_image: true tag: ${{ needs.create_tags.outputs.version_tag }} + smoke: ${{ contains(fromJSON('["MLPAB-1419-use-a-single-persistent-environment-for-weblate-changes-optimise-workflow", "weblate-pr"]'), github.head_ref) }} secrets: aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID_ACTIONS }} aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY_ACTIONS }} diff --git a/scripts/workspace_cleanup.sh b/scripts/workspace_cleanup.sh index 1a175fb462..2b7a74c658 100755 --- a/scripts/workspace_cleanup.sh +++ b/scripts/workspace_cleanup.sh @@ -13,7 +13,7 @@ fi export TF_EXIT_CODE="0" in_use_workspaces=( "$@" ) -reserved_workspaces=( "default" "production" "preproduction" "ur" "demo") +reserved_workspaces=( "default" "production" "preproduction" "ur" "demo" "weblate" ) protected_workspaces=( "${in_use_workspaces[@]} ${reserved_workspaces[@]}" ) all_workspaces=$(terraform workspace list|sed 's/*//g')