Skip to content

SCALRCORE-32726 Add the ability to disable the Scalr backend to API/P… #733

SCALRCORE-32726 Add the ability to disable the Scalr backend to API/P…

SCALRCORE-32726 Add the ability to disable the Scalr backend to API/P… #733

Workflow file for this run

name: default
on: push
jobs:
lint:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.18"
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v4
with:
version: v1.45.2
tests:
name: Tests
runs-on: ubuntu-latest
env:
SCALR_TOKEN: ${{ secrets.SCALR_TOKEN }}
UPSTREAM_ID: ${{ github.run_number }}
steps:
- name: Sudo GitHub Token
id: generate_token
uses: tibdex/github-app-token@v1
with:
app_id: ${{vars.SUDO_GHA_APP_ID}}
installation_id: ${{vars.SUDO_GHA_APP_INSTALLATION_ID}}
private_key: ${{secrets.SUDO_GHA_APP_PRIVATE_KEY}}
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.18"
- name: Set API_BRANCH
run: echo "API_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
- name: Check if Same Branch Exists in Fatmouse Repository
id: check-branch
uses: actions/github-script@v7
with:
github-token: ${{steps.generate_token.outputs.token}}
script: |
const owner = "Scalr";
const repo = "fatmouse";
const targetBranch = "${{ env.API_BRANCH }}";
const default_branch = "master";
try {
const { data: branch } = await github.request('GET /repos/{owner}/{repo}/branches/{branch}', {
owner: owner,
repo: repo,
branch: targetBranch
});
console.log(`Branch found in the ${repo} repository: ${branch.name}`);
core.setOutput('branch', branch.name);
} catch (error) {
if (error.status === 404) {
console.log(`Branch not found in ${repo} repository.`);
core.setOutput('branch', default_branch);
} else {
console.error('Unexpected error:', error);
core.setFailed('Unexpected error');
}
}
- name: Clone Fatmouse Repository
uses: actions/checkout@v4
with:
repository: Scalr/fatmouse
path: fatmouse
ref: ${{ steps.check-branch.outputs.branch }}
token: ${{steps.generate_token.outputs.token}}
- uses: ./fatmouse/.github/actions/preview-env
name: Create preview environment
id: create-preview-env
env:
JOB_NAME: Tests
with:
ref: ${{ env.API_BRANCH }}
ignore_missing_branches: true
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-preview-env.outputs.host }}
echo "SCALR_ADDRESS=https://mainiacp.${SCALR_HOST/https:\/\//}" >> $GITHUB_ENV
- name: Run Tests
env:
SCALR_ADDRESS: ${{ env.SCALR_ADDRESS }}
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() }}
working-directory: fatmouse
shell: bash
run: |
python -u clickfile.py te rm --no-wait ${{ steps.create-preview-env.outputs.env_name }}