-
Notifications
You must be signed in to change notification settings - Fork 11
260 lines (248 loc) · 8.47 KB
/
default.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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
name: default
on:
push:
branches:
- master
- release/**
paths-ignore:
- CHANGELOG.md
- CONTRIBUTING.md
- README.md
pull_request:
branches:
- master
- release/**
paths-ignore:
- CHANGELOG.md
- CONTRIBUTING.md
- README.md
env:
RDME_VERSION: 0.0.5
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.23"
cache: false
- name: Lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.62.0
args: --timeout 2m
- name: Validate Generated Code
run: |
go generate
if [ -z "$(git status --porcelain)" ]; then
echo "ok";
else
echo "*** Unexpected differences after code generation. Run 'go generate' and commit.";
exit 1;
fi
unit-tests:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.23"
- name: Run unit tests
run: make test
docs-preview:
name: Preview Docs
needs: [ lint ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Preview
uses: readmeio/rdme@v8
with:
rdme: docs ./docs --key=${{ secrets.README_API_KEY }} --version=${{ env.RDME_VERSION }} --dryRun
acc-tests:
runs-on: ubuntu-latest
name: acc-tests
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.23"
- name: Check if Same Branch Exists in Fatmouse Repo
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 = "${{ github.head_ref || github.ref_name }}";
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 Repo
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
with:
ref: ${{ github.head_ref || github.ref_name }}
ignore_missing_branches: true
github_token: ${{ steps.generate_token.outputs.token }}
google_cloud_credentials: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
run_prefix: e2e-provider-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
run: |
SCALR_HOST=${{ steps.create-preview-env.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: Install Goveralls
run: go install github.com/mattn/goveralls@latest
- name: Send Coverage
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: goveralls -coverprofile=covprofile -service=github
- name: Delete Container
id: delete
working-directory: fatmouse
if: ${{ always() }}
run: |
python -u clickfile.py te rm --no-wait ${{ steps.create-preview-env.outputs.env_name }}
notify:
name: Notify About Tests Failure
needs: [lint, unit-tests, acc-tests]
runs-on: ubuntu-latest
if: contains(needs.*.result, 'failure') && startsWith(github.ref, 'refs/heads/master/')
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get Last Commit User Email
id: get_email
run: |
LAST_COMMIT_EMAIL=$(git log -1 --pretty=format:'%ae')
echo "Last commit email: $LAST_COMMIT_EMAIL"
echo "commit_email=$LAST_COMMIT_EMAIL" | tee -a $GITHUB_ENV
- name: Notification
uses: slackapi/[email protected]
with:
payload: |
{
"channel" : "#area-backend",
"text": "The Provider Tests on the Master Branch has been Failed. Last Comitter: ${{steps.get_email.outputs.commit_email}}",
"attachments": [
{
"color": "b52c2a",
"fields": [
{
"title": "Job URL",
"value": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}",
"short": false
}
]
}
]
}
upload-dev:
name: upload-dev
needs: [lint, unit-tests, acc-tests]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Import GPG key
id: import_gpg
uses: Scalr/[email protected]
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
- id: Auth
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.DEV_GCP_SA_KEY }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2
- name: Create Development Tag
run: |
BRANCH=${{ github.head_ref || github.ref_name }}
CLEAN_BRANCH=$(echo "$BRANCH" | sed 's/[\/]/-/g')
git tag v1.0.0-rc-$CLEAN_BRANCH
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.23"
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
version: "~> v2"
args: release --skip=publish
env:
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
- name: Upload Provider to Registry
uses: ./.github/actions/upload-provider
with:
gcs-bucket: ${{ secrets.DEV_BUCKET_NAME }}
registry-domain: ${{ secrets.DEV_DOMAIN }}
gpg-key-id: ${{ steps.import_gpg.outputs.fingerprint }}
gpg-pub-key: ${{ steps.import_gpg.outputs.pubkey }}
- name: Update Network Mirror
uses: ./.github/actions/update-network-mirror
with:
gcs-bucket: ${{ secrets.DEV_BUCKET_NAME }}
registry-domain: ${{ secrets.DEV_DOMAIN }}
dry-run: false