From af0ddb1d60b862e2fc98b8551c258863c1378f71 Mon Sep 17 00:00:00 2001 From: okramarenko Date: Fri, 29 Nov 2024 13:05:42 +0200 Subject: [PATCH 1/3] SCALRCORE-33080: Tech debt: Use preview-env action in go-scalr and provider workflows --- .github/workflows/default.yml | 99 ++++++----------------------------- .github/workflows/pr.yml | 90 ++++++------------------------- 2 files changed, 34 insertions(+), 155 deletions(-) diff --git a/.github/workflows/default.yml b/.github/workflows/default.yml index 79ad46e..9afa31e 100644 --- a/.github/workflows/default.yml +++ b/.github/workflows/default.yml @@ -78,86 +78,26 @@ jobs: ref: ${{ steps.check-branch.outputs.branch }} token: ${{steps.generate_token.outputs.token}} - - name: Set DB_BRANCH - if: ${{ contains(github.event.head_commit.message, '[DB_BRANCH]') }} - run: echo "DB_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV - - - id: auth - uses: google-github-actions/auth@v2 - with: - credentials_json: ${{ secrets.GCP_SA_KEY }} - - - name: Set up Cloud SDK - uses: google-github-actions/setup-gcloud@v2 - - - name: Copy Secrets - shell: bash - run: | - mkdir ~/.scalr-labs - gsutil cp gs://tacobell-secrets/.secrets.yaml fatmouse/tacobell/.secrets.yaml - gsutil cp gs://tacobell-secrets/github.json ~/.scalr-labs/github.json - - - name: Configure Docker - shell: bash - run: gcloud auth configure-docker us-central1-docker.pkg.dev - - - name: Pull Python Builder - shell: bash - run: | - echo "::group::Pull python builder image" - builder_path=us-central1-docker.pkg.dev/scalr-dev/main-docker/fatmouse/python-builder - exists=$(docker manifest inspect $builder_path:${{ github.ref_name }} > /dev/null ; echo $?) - if [[ $exists == "0" ]]; then - docker pull $builder_path:${{ github.ref_name }} - docker tag $builder_path:${{ github.ref_name }} fatmouse/python-builder:base - else - docker pull $builder_path:master - docker tag $builder_path:master fatmouse/python-builder:base - fi - echo "::endgroup::" - - - name: Get current job log URL - uses: Tiryoh/gha-jobid-action@v1 - id: get-job-id + - uses: ./fatmouse/.github/actions/preview-env + name: Create preview environment + id: create-preview-env with: - github_token: ${{ secrets.GITHUB_TOKEN }} - job_name: Tests - - - name: Generate Run Tag - shell: bash - run: | - if [ ${{ github.run_attempt }} = 1 ]; then - RERUN_SUFFIX="" - else - RERUN_SUFFIX=$(echo -${{ github.run_attempt }}) - fi - echo "RUN_TAG=e2e-${{ github.workflow }}-${{ github.job }}-${{ github.run_number }}${RERUN_SUFFIX}" >> $GITHUB_ENV - - - name: Create Container - id: create - shell: bash - run: | - docker run --rm \ - -e GITHUB_WORKSPACE=true \ - -e GITHUB_OUTPUT=/fatmouse/output \ - -e GITHUB_STEP_SUMMARY=/fatmouse/step_summary \ - -w /fatmouse \ - -v $PWD/fatmouse:/fatmouse \ - -v $GITHUB_OUTPUT:/fatmouse/output \ - -v $GITHUB_STEP_SUMMARY:/fatmouse/step_summary \ - -v ~/.scalr-labs:/etc/scalr-labs \ - fatmouse/python-builder:base python -u clickfile.py te up \ - --branch ${{ env.API_BRANCH }} \ - --run-url ${{ steps.get-job-id.outputs.html_url }} \ - --skip-ui-build \ - --ignore-missing-branches \ - --agent-pool-id="${{vars.TACO_APOOL_ID}}" \ - ${{ env.RUN_TAG }} + ref: ${{ env.API_BRANCH }} + github_token: ${{ steps.generate_token.outputs.token }} + google_cloud_credentials: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }} + run_prefix: e2e-go-scalr-default + deployment_type: saas + prepare_runner: true + wait_for_env: true + no_segment: true + agent_pool_id: ${{ vars.TACO_APOOL_ID }} + working_directory: fatmouse + secrets_bucket: tacobell-secrets - name: Get Scalr Hostname shell: bash run: | - SCALR_HOST=${{ steps.create.outputs.host }} + SCALR_HOST=${{ steps.create-preview-env.outputs.host }} echo "SCALR_ADDRESS=https://mainiacp.${SCALR_HOST/https:\/\//}" >> $GITHUB_ENV - name: Run Tests @@ -187,12 +127,7 @@ jobs: - name: Delete Container id: delete if: ${{ always() }} + working-directory: fatmouse shell: bash run: | - docker run --rm \ - -w /fatmouse \ - -v $PWD/fatmouse:/fatmouse \ - -v ~/.scalr-labs:/etc/scalr-labs \ - fatmouse/python-builder:base \ - python -u clickfile.py te rm \ - --no-wait ${{ env.RUN_TAG }} + python -u clickfile.py te rm --no-wait ${{ steps.create-preview-env.outputs.env_name }} diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 3058c37..43f5b14 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -84,77 +84,26 @@ jobs: repo: fatmouse pr_id: ${{ inputs.pr_id }} - - name: Set DB_BRANCH - if: ${{ contains(github.event.head_commit.message, '[DB_BRANCH]') }} - run: echo "DB_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV - - - id: auth - uses: google-github-actions/auth@v2 + - uses: ./fatmouse/.github/actions/preview-env + name: Create preview environment + id: create-preview-env with: - credentials_json: ${{ secrets.GCP_SA_KEY }} - - - name: Set up Cloud SDK - uses: google-github-actions/setup-gcloud@v2 - - name: Copy secrets - shell: bash - run: | - mkdir ~/.scalr-labs - gsutil cp gs://tacobell-secrets/.secrets.yaml fatmouse/tacobell/.secrets.yaml - gsutil cp gs://tacobell-secrets/github.json ~/.scalr-labs/github.json - - - name: Configure Docker - shell: bash - run: gcloud auth configure-docker us-central1-docker.pkg.dev - - - name: Pull Python Builder - shell: bash - run: | - echo "::group::Pull python builder image" - builder_path=us-central1-docker.pkg.dev/scalr-dev/main-docker/fatmouse/python-builder - exists=$(docker manifest inspect $builder_path:${{ inputs.pr_branch }} > /dev/null ; echo $?) - if [[ $exists == "0" ]]; then - docker pull $builder_path:${{ inputs.pr_branch }} - docker tag $builder_path:${{ inputs.pr_branch }} fatmouse/python-builder:base - else - docker pull $builder_path:master - docker tag $builder_path:master fatmouse/python-builder:base - fi - echo "::endgroup::" - - - name: Generate Run Tag - shell: bash - run: | - if [ ${{ github.run_attempt }} = 1 ]; then - RERUN_SUFFIX="" - else - RERUN_SUFFIX=$(echo -${{ github.run_attempt }}) - fi - echo "RUN_TAG=e2e-go-scalr-external-pr-${{ github.run_number }}${RERUN_SUFFIX}" >> $GITHUB_ENV - - - name: Create Container - id: create - shell: bash - run: | - docker run --rm \ - -e GITHUB_WORKSPACE=true \ - -e GITHUB_OUTPUT=/fatmouse/output \ - -e GITHUB_STEP_SUMMARY=/fatmouse/step_summary \ - -w /fatmouse \ - -v $PWD/fatmouse:/fatmouse \ - -v $GITHUB_OUTPUT:/fatmouse/output \ - -v $GITHUB_STEP_SUMMARY:/fatmouse/step_summary \ - -v ~/.scalr-labs:/etc/scalr-labs \ - fatmouse/python-builder:base python -u clickfile.py te up \ - --branch ${{ inputs.pr_branch }} \ - --run-url ${{ steps.get-job-id.outputs.html_url }} \ - --skip-ui-build \ - --agent-pool-id="${{ !contains(steps.pr-labels.outputs.labels, ' e2e:tev2_on_server ') && vars.TACO_APOOL_ID || '' }}" \ - ${{ env.RUN_TAG }} + ref: ${{ inputs.pr_branch }} + github_token: ${{ steps.generate_token.outputs.token }} + google_cloud_credentials: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }} + run_prefix: e2e-go-scalr-pr + deployment_type: saas + prepare_runner: true + wait_for_env: true + no_segment: true + agent_pool_id: ${{ !contains(steps.pr-labels.outputs.labels, ' e2e:tev2_on_server ') && vars.TACO_APOOL_ID || '' }} + working_directory: fatmouse + secrets_bucket: tacobell-secrets - name: Get Scalr Hostname shell: bash run: | - SCALR_HOST=${{ steps.create.outputs.host }} + SCALR_HOST=${{ steps.create-preview-env.outputs.host }} echo "SCALR_ADDRESS=https://mainiacp.${SCALR_HOST/https:\/\//}" >> $GITHUB_ENV - name: Run Tests @@ -219,12 +168,7 @@ jobs: - name: Delete Container id: delete if: ${{ always() }} + working-directory: fatmouse shell: bash run: | - docker run --rm \ - -w /fatmouse \ - -v $PWD/fatmouse:/fatmouse \ - -v ~/.scalr-labs:/etc/scalr-labs \ - fatmouse/python-builder:base \ - python -u clickfile.py te rm \ - --no-wait ${{ env.RUN_TAG }} + python -u clickfile.py te rm --no-wait ${{ steps.create-preview-env.outputs.env_name }} From d5d8c65b9276163984179fff2a9ed3f0f4d704a3 Mon Sep 17 00:00:00 2001 From: okramarenko Date: Fri, 29 Nov 2024 13:10:15 +0200 Subject: [PATCH 2/3] SCALRCORE-33080: Tech debt: Use preview-env action in go-scalr and provider workflows --- .github/workflows/default.yml | 2 +- .github/workflows/pr.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/default.yml b/.github/workflows/default.yml index 9afa31e..b510cd9 100644 --- a/.github/workflows/default.yml +++ b/.github/workflows/default.yml @@ -84,7 +84,7 @@ jobs: with: ref: ${{ env.API_BRANCH }} github_token: ${{ steps.generate_token.outputs.token }} - google_cloud_credentials: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }} + google_cloud_credentials: ${{ secrets.GCP_SA_KEY }} run_prefix: e2e-go-scalr-default deployment_type: saas prepare_runner: true diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 43f5b14..6631348 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -90,7 +90,7 @@ jobs: with: ref: ${{ inputs.pr_branch }} github_token: ${{ steps.generate_token.outputs.token }} - google_cloud_credentials: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }} + google_cloud_credentials: ${{ secrets.GCP_SA_KEY }} run_prefix: e2e-go-scalr-pr deployment_type: saas prepare_runner: true From aa56974e544bb3abfee6c10cfa5e9659f524ee2c Mon Sep 17 00:00:00 2001 From: okramarenko Date: Fri, 29 Nov 2024 13:13:32 +0200 Subject: [PATCH 3/3] SCALRCORE-33080: Tech debt: Use preview-env action in go-scalr and provider workflows --- .github/workflows/default.yml | 2 ++ .github/workflows/pr.yml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/.github/workflows/default.yml b/.github/workflows/default.yml index b510cd9..c6dbb8e 100644 --- a/.github/workflows/default.yml +++ b/.github/workflows/default.yml @@ -81,6 +81,8 @@ jobs: - uses: ./fatmouse/.github/actions/preview-env name: Create preview environment id: create-preview-env + env: + JOB_NAME: Tests with: ref: ${{ env.API_BRANCH }} github_token: ${{ steps.generate_token.outputs.token }} diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 6631348..e0eb6db 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -87,6 +87,8 @@ jobs: - uses: ./fatmouse/.github/actions/preview-env name: Create preview environment id: create-preview-env + env: + JOB_NAME: Tests with: ref: ${{ inputs.pr_branch }} github_token: ${{ steps.generate_token.outputs.token }}