Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SCALRCORE-33080: Tech debt: Use preview-env action in go-scalr and pr… #164

Merged
merged 3 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 19 additions & 82 deletions .github/workflows/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,86 +78,28 @@ 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
env:
JOB_NAME: Tests
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.GCP_SA_KEY }}
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
Expand Down Expand Up @@ -187,12 +129,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 }}
92 changes: 19 additions & 73 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,77 +84,28 @@ 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
env:
JOB_NAME: Tests
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.GCP_SA_KEY }}
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
Expand Down Expand Up @@ -219,12 +170,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 }}