From 852d2974c8be5f6ce8c8cf81a6f00871900e89d6 Mon Sep 17 00:00:00 2001 From: Volodymyr Yahello Date: Wed, 1 Feb 2023 16:03:57 +0200 Subject: [PATCH 1/2] SCALRCORE-25157: Migrate go-scalr tests to tev2 --- .github/workflows/default.yml | 102 +++++++++++++++++++++------------- 1 file changed, 64 insertions(+), 38 deletions(-) diff --git a/.github/workflows/default.yml b/.github/workflows/default.yml index b49f43b..0225b82 100644 --- a/.github/workflows/default.yml +++ b/.github/workflows/default.yml @@ -7,8 +7,8 @@ jobs: name: lint runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-go@v2 + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 with: go-version: "1.18" - name: golangci-lint @@ -19,51 +19,77 @@ jobs: runs-on: ubuntu-latest name: tests env: - REVIZOR_URL: ${{ secrets.REVIZOR_URL }} - REVIZOR_TOKEN: ${{ secrets.REVIZOR_TOKEN }} SCALR_TOKEN: ${{ secrets.SCALR_TOKEN }} UPSTREAM_ID: ${{ github.run_number }} + GCP: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }} + GH_PAT: ${{ secrets.GH_PAT }} steps: - - uses: actions/checkout@v2 - - uses: actions/setup-go@v2 + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 with: go-version: "1.18" + - name: Clone fatmouse repo + uses: actions/checkout@v3 + with: + repository: Scalr/fatmouse + path: fatmouse + token: ${{ secrets.GH_PAT }} - name: Set API_BRANCH if: ${{ contains(github.event.head_commit.message, '[API_BRANCH]') }} run: echo "API_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV - name: Set DB_BRANCH if: ${{ contains(github.event.head_commit.message, '[DB_BRANCH]') }} run: echo "DB_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV - - name: Create container - id: create - uses: Scalr/gh-action-revizor@master - with: - command: create - - name: Run tests - env: - SCALR_ADDRESS: https://${{ steps.create.outputs.hostname }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - TEST_AWS_ACCESS_KEY: ${{ secrets.TEST_AWS_ACCESS_KEY }} - TEST_AWS_SECRET_KEY: ${{ secrets.TEST_AWS_SECRET_KEY }} - TEST_AWS_ROLE_ARN: ${{ secrets.TEST_AWS_ROLE_ARN }} - TEST_AWS_EXTERNAL_ID: ${{ secrets.TEST_AWS_EXTERNAL_ID }} - TEST_ARM_CLIENT_ID: ${{ secrets.TEST_ARM_CLIENT_ID }} - TEST_ARM_CLIENT_SECRET: ${{ secrets.TEST_ARM_CLIENT_SECRET }} - TEST_ARM_TENANT_ID: ${{ secrets.TEST_ARM_TENANT_ID }} - TEST_ARM_SUBSCRIPTION_ID: ${{ secrets.TEST_ARM_SUBSCRIPTION_ID }} - run: make test - - name: Install goveralls - env: - GO111MODULE: off - run: go get github.com/mattn/goveralls - - name: Send coverage - env: - COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: goveralls -coverprofile=covprofile -service=github - - name: Delete container - id: delete - if: ${{ always() && steps.create.outputs.container_id }} - uses: Scalr/gh-action-revizor@master + - id: auth + uses: google-github-actions/auth@v0 with: - command: delete - container_id: ${{ steps.create.outputs.container_id }} + credentials_json: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }} + - name: Set up Cloud SDK + uses: google-github-actions/setup-gcloud@v0 + - name: Copy secrets + shell: bash + run: | + mkdir ~/.scalr-labs + gsutil cp gs://drone_bucket/prod/private.d/.secrets.yaml fatmouse/tacobell/.secrets.yaml + gsutil cp gs://drone_bucket/prod/private.d/github.json ~/.scalr-labs/github.json + - name: Configure docker + shell: bash + run: gcloud auth configure-docker eu.gcr.io + - name: Pull python builder + shell: bash + run: | + docker pull eu.gcr.io/development-156220/fatmouse/python-builder:master + docker tag eu.gcr.io/development-156220/fatmouse/python-builder:master fatmouse/python-builder:master +# - name: Create container +# id: create +# uses: Scalr/gh-action-revizor@master +# with: +# command: create +# - name: Run tests +# env: +# SCALR_ADDRESS: https://${{ steps.create.outputs.hostname }} +# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} +# TEST_AWS_ACCESS_KEY: ${{ secrets.TEST_AWS_ACCESS_KEY }} +# TEST_AWS_SECRET_KEY: ${{ secrets.TEST_AWS_SECRET_KEY }} +# TEST_AWS_ROLE_ARN: ${{ secrets.TEST_AWS_ROLE_ARN }} +# TEST_AWS_EXTERNAL_ID: ${{ secrets.TEST_AWS_EXTERNAL_ID }} +# TEST_ARM_CLIENT_ID: ${{ secrets.TEST_ARM_CLIENT_ID }} +# TEST_ARM_CLIENT_SECRET: ${{ secrets.TEST_ARM_CLIENT_SECRET }} +# TEST_ARM_TENANT_ID: ${{ secrets.TEST_ARM_TENANT_ID }} +# TEST_ARM_SUBSCRIPTION_ID: ${{ secrets.TEST_ARM_SUBSCRIPTION_ID }} +# run: make test +# - name: Install goveralls +# env: +# GO111MODULE: off +# run: go get github.com/mattn/goveralls +# - name: Send coverage +# env: +# COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }} +# run: goveralls -coverprofile=covprofile -service=github +# - name: Delete container +# id: delete +# if: ${{ always() && steps.create.outputs.container_id }} +# uses: Scalr/gh-action-revizor@master +# with: +# command: delete +# container_id: ${{ steps.create.outputs.container_id }} From 1cea6569e233200194604735ebea76f9ba6de1c1 Mon Sep 17 00:00:00 2001 From: Volodymyr Yahello Date: Fri, 3 Feb 2023 11:03:04 +0200 Subject: [PATCH 2/2] SCALRCORE-25157: Migrate go-scalr tests to tev2 --- .github/workflows/default.yml | 121 ++++++++++++++++++++++++---------- 1 file changed, 86 insertions(+), 35 deletions(-) diff --git a/.github/workflows/default.yml b/.github/workflows/default.yml index 0225b82..9e99337 100644 --- a/.github/workflows/default.yml +++ b/.github/workflows/default.yml @@ -21,8 +21,6 @@ jobs: env: SCALR_TOKEN: ${{ secrets.SCALR_TOKEN }} UPSTREAM_ID: ${{ github.run_number }} - GCP: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }} - GH_PAT: ${{ secrets.GH_PAT }} steps: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 @@ -58,38 +56,91 @@ jobs: - name: Pull python builder shell: bash run: | + echo "::group::Pull python builder image" docker pull eu.gcr.io/development-156220/fatmouse/python-builder:master docker tag eu.gcr.io/development-156220/fatmouse/python-builder:master fatmouse/python-builder:master -# - name: Create container -# id: create -# uses: Scalr/gh-action-revizor@master -# with: -# command: create -# - name: Run tests -# env: -# SCALR_ADDRESS: https://${{ steps.create.outputs.hostname }} -# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} -# TEST_AWS_ACCESS_KEY: ${{ secrets.TEST_AWS_ACCESS_KEY }} -# TEST_AWS_SECRET_KEY: ${{ secrets.TEST_AWS_SECRET_KEY }} -# TEST_AWS_ROLE_ARN: ${{ secrets.TEST_AWS_ROLE_ARN }} -# TEST_AWS_EXTERNAL_ID: ${{ secrets.TEST_AWS_EXTERNAL_ID }} -# TEST_ARM_CLIENT_ID: ${{ secrets.TEST_ARM_CLIENT_ID }} -# TEST_ARM_CLIENT_SECRET: ${{ secrets.TEST_ARM_CLIENT_SECRET }} -# TEST_ARM_TENANT_ID: ${{ secrets.TEST_ARM_TENANT_ID }} -# TEST_ARM_SUBSCRIPTION_ID: ${{ secrets.TEST_ARM_SUBSCRIPTION_ID }} -# run: make test -# - name: Install goveralls -# env: -# GO111MODULE: off -# run: go get github.com/mattn/goveralls -# - name: Send coverage -# env: -# COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }} -# run: goveralls -coverprofile=covprofile -service=github -# - name: Delete container -# id: delete -# if: ${{ always() && steps.create.outputs.container_id }} -# uses: Scalr/gh-action-revizor@master -# with: -# command: delete -# container_id: ${{ steps.create.outputs.container_id }} + echo "::endgroup::" + - name: Get current job log URL + uses: Tiryoh/gha-jobid-action@v0 + id: get-job-id + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + job_name: ${{ github.job }} + - 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: | + if [ -z ${{ env.API_BRANCH }} ]; then + FATMOUSE_BRANCH="" + else + FATMOUSE_BRANCH="--fatmouse-branch ${{ env.API_BRANCH }}" + fi + + if [ -z ${{ env.DB_BRANCH }} ]; then + SCALR_BRANCH="" + else + SCALR_BRANCH="--scalr-branch ${{ env.DB_BRANCH }}" + fi + + if [ "${{ env.API_BRANCH }}" = "staging" ]; then + IMAGE="--scalr-server-image-tag staging" + else + IMAGE="" + fi + + docker run --rm \ + -e GITHUB_WORKSPACE=true \ + -e GITHUB_OUTPUT=/fatmouse/output \ + -w /fatmouse \ + -v $PWD/fatmouse:/fatmouse \ + -v $GITHUB_OUTPUT:/fatmouse/output \ + -v ~/.scalr-labs:/etc/scalr-labs \ + fatmouse/python-builder:master python -u clickfile.py te up \ + ${FATMOUSE_BRANCH} ${SCALR_BRANCH} ${IMAGE} \ + --run-url ${{ steps.get-job-id.outputs.html_url }} \ + --skip-ui-build \ + --cpu=1 \ + --ram=2G \ + ${{ env.RUN_TAG }} + - name: Run tests + env: + SCALR_ADDRESS: ${{ steps.create.outputs.host }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + TEST_AWS_ACCESS_KEY: ${{ secrets.TEST_AWS_ACCESS_KEY }} + TEST_AWS_SECRET_KEY: ${{ secrets.TEST_AWS_SECRET_KEY }} + TEST_AWS_ROLE_ARN: ${{ secrets.TEST_AWS_ROLE_ARN }} + TEST_AWS_EXTERNAL_ID: ${{ secrets.TEST_AWS_EXTERNAL_ID }} + TEST_ARM_CLIENT_ID: ${{ secrets.TEST_ARM_CLIENT_ID }} + TEST_ARM_CLIENT_SECRET: ${{ secrets.TEST_ARM_CLIENT_SECRET }} + TEST_ARM_TENANT_ID: ${{ secrets.TEST_ARM_TENANT_ID }} + TEST_ARM_SUBSCRIPTION_ID: ${{ secrets.TEST_ARM_SUBSCRIPTION_ID }} + run: make test + - name: Install goveralls + env: + GO111MODULE: off + run: go get github.com/mattn/goveralls + - name: Send coverage + env: + COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: goveralls -coverprofile=covprofile -service=github + - name: Delete container + id: delete + if: ${{ always() }} + shell: bash + run: | + docker run --rm \ + -w /fatmouse \ + -v $PWD/fatmouse:/fatmouse \ + -v ~/.scalr-labs:/etc/scalr-labs \ + fatmouse/python-builder:master \ + python -u clickfile.py te rm \ + --no-wait ${{ env.RUN_TAG }}