-
Notifications
You must be signed in to change notification settings - Fork 11
158 lines (156 loc) · 6.44 KB
/
upstream.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
name: upstream
on:
workflow_dispatch:
inputs:
upstream-sha:
description: "Upstream commit SHA"
required: true
api-branch:
description: "API Branch"
required: true
default: "master"
db-branch:
description: "Not used, left for backward compatibility"
required: false
default: "master"
py-req:
description: "Whether to upgrade python requirements"
required: false
default: "no"
upstream-base-ref:
description: "Upstream base branch (e.g. 'master' or 'release/8.57.0')"
required: false
pr-id:
description: The number of the pull request
required: false
jobs:
acc-tests:
runs-on: ubuntu-latest
name: acc-tests
concurrency:
group: ${{ github.workflow }}-${{ inputs.pr-id }}
cancel-in-progress: true
env:
SCALR_TOKEN: ${{ secrets.SCALR_TOKEN }}
API_BRANCH: ${{ github.event.inputs.api-branch }}
PY_REQ: ${{ github.event.inputs.py-req }}
UPSTREAM_ID: ${{ github.run_number }}
UPSTREAM_BASE_REF: ${{ github.event.inputs.upstream-base-ref }}
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
- name: Notify Upstream about Pending
run: make notify-upstream org_admin_token=${{steps.generate_token.outputs.token}} upstream_sha=${{ github.event.inputs.upstream-sha }} state=pending run_id=${{ github.run_id }}
- uses: actions/setup-go@v5
with:
go-version: "1.23"
- name: Clone Fatmouse Repo
uses: actions/checkout@v4
with:
repository: Scalr/fatmouse
path: fatmouse
ref: ${{ env.API_BRANCH }}
token: ${{steps.generate_token.outputs.token}}
- name: Get Pull Request Labels
id: pr-labels
if: ${{ inputs.pr-id != '' }}
uses: ./fatmouse/.github/actions/pr-labels
with:
github_token: ${{steps.generate_token.outputs.token}}
owner: Scalr
repo: fatmouse
pr_id: ${{ inputs.pr-id }}
- name: Set py-req on PR with Label
if: ${{ inputs.pr-id != '' && contains(steps.pr-labels.outputs.labels, ' py-req ') }}
run: echo "PY_REQ=yes" >> $GITHUB_ENV
- id: auth
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
- name: Set Up Cloud SDK
uses: google-github-actions/setup-gcloud@v2
- name: Copy secrets
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
run: gcloud auth configure-docker us-central1-docker.pkg.dev --quiet
- name: Pull Python Builder
run: |
echo "::group::Pull python builder image"
docker pull us-central1-docker.pkg.dev/scalr-dev/main-docker/fatmouse/python-builder:master
docker tag us-central1-docker.pkg.dev/scalr-dev/main-docker/fatmouse/python-builder:master fatmouse/python-builder:master
echo "::endgroup::"
- name: Get Current Job Log URL
uses: Tiryoh/gha-jobid-action@v1
id: get-job-id
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
job_name: acc-tests
- name: Generate Run Tag
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
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:master python -u clickfile.py te up \
--branch ${{ env.API_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 }}
- name: Get Scalr Hostname
run: |
SCALR_HOST=${{ steps.create.outputs.host }}
echo "SCALR_HOSTNAME=mainiacp.${SCALR_HOST/https:\/\//}" >> $GITHUB_ENV
- name: Run acceptance tests
env:
SCALR_HOSTNAME: ${{ env.SCALR_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 testacc
- name: Delete Container
id: delete
if: ${{ always() }}
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 }}
- name: Notify Upstream about Success
if: ${{ success() }}
run: make notify-upstream org_admin_token=${{steps.generate_token.outputs.token}} upstream_sha=${{ github.event.inputs.upstream-sha }} state=success run_id=${{ github.run_id }}
- name: Notify Upstream about Failure
if: ${{ failure() }}
run: make notify-upstream org_admin_token=${{steps.generate_token.outputs.token}} upstream_sha=${{ github.event.inputs.upstream-sha }} state=failure run_id=${{ github.run_id }}