Skip to content

Commit 1676a30

Browse files
committed
Manually run extra tests & emit metric if token expired
1 parent e09693c commit 1676a30

File tree

3 files changed

+87
-4
lines changed

3 files changed

+87
-4
lines changed

.github/workflows/codebuild-ci.yml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,16 @@ jobs:
1717
outputs:
1818
approval-env: ${{ steps.collab-check.outputs.result }}
1919
steps:
20+
- name: Configure AWS Credentials
21+
uses: aws-actions/configure-aws-credentials@v4
22+
with:
23+
role-to-assume: ${{ secrets.MONITORING_AWS_ROLE_ARN }}
24+
aws-region: us-west-2
2025
- name: Collaborator Check
2126
uses: actions/github-script@v7
2227
id: collab-check
28+
env:
29+
PR_USER_LOGIN: ${{ github.event.pull_request.user.login }}
2330
with:
2431
github-token: ${{ secrets.COLLAB_CHECK_TOKEN }}
2532
result-encoding: string
@@ -28,13 +35,19 @@ jobs:
2835
const res = await github.rest.repos.checkCollaborator({
2936
owner: context.repo.owner,
3037
repo: context.repo.repo,
31-
username: "${{ github.event.pull_request.user.login }}",
38+
username: "${{ env.PR_USER_LOGIN }}",
3239
});
33-
console.log("Verifed ${{ github.event.pull_request.user.login }} is a repo collaborator. Auto Approving PR Checks.")
40+
console.log("Verifed user is a repo collaborator. Auto Approving PR Checks.")
3441
return res.status == "204" ? "auto-approve" : "manual-approval"
3542
} catch (error) {
36-
console.log("${{ github.event.pull_request.user.login }} is not a collaborator. Requiring Manual Approval to run PR Checks.")
37-
return "manual-approval"
43+
if (error.message == "Bad credentials") {
44+
console.log("Token Expired. Please update the COLLAB_CHECK_TOKEN secret. Requiring Manual Approval to run PR Checks becuase the collaborator status could not be verified.")
45+
const { execSync } = require('child_process')
46+
execSync('aws cloudwatch put-metric-data --namespace "GitHubActions" --metric-name "BadCredentials" --value 1')
47+
} else {
48+
console.log("User is not a collaborator. Requiring Manual Approval to run PR Checks.")
49+
}
50+
return "manual-approval"
3851
}
3952
wait-for-approval:
4053
runs-on: ubuntu-latest
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Run Local Mode Tests
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
prNumber:
7+
description: 'Pull Request Number'
8+
required: true
9+
commitSha:
10+
description: 'Commit SHA'
11+
required: true
12+
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.event.inputs.prNumber }}
15+
cancel-in-progress: true
16+
17+
permissions:
18+
id-token: write # This is required for requesting the JWT
19+
20+
jobs:
21+
local-mode-tests:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Configure AWS Credentials
25+
uses: aws-actions/configure-aws-credentials@v4
26+
with:
27+
role-to-assume: ${{ secrets.CI_AWS_ROLE_ARN }}
28+
aws-region: us-west-2
29+
role-duration-seconds: 10800
30+
- name: Run Slow Tests
31+
uses: aws-actions/aws-codebuild-run-build@v1
32+
with:
33+
project-name: ${{ github.event.repository.name }}-ci-localmode-tests
34+
source-version-override: 'refs/pull/${{ github.event.inputs.prNumber}}/head^{${{ github.event.inputs.commitSha }}}'
35+

.github/workflows/run-slow-tests.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Run Slow Tests
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
prNumber:
7+
description: 'Pull Request Number'
8+
required: true
9+
commitSha:
10+
description: 'Commit SHA'
11+
required: true
12+
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.event.inputs.prNumber }}
15+
cancel-in-progress: true
16+
17+
permissions:
18+
id-token: write # This is required for requesting the JWT
19+
20+
jobs:
21+
slow-tests:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Configure AWS Credentials
25+
uses: aws-actions/configure-aws-credentials@v4
26+
with:
27+
role-to-assume: ${{ secrets.CI_AWS_ROLE_ARN }}
28+
aws-region: us-west-2
29+
role-duration-seconds: 10800
30+
- name: Run Slow Tests
31+
uses: aws-actions/aws-codebuild-run-build@v1
32+
with:
33+
project-name: ${{ github.event.repository.name }}-ci-slow-tests
34+
source-version-override: 'refs/pull/${{ github.event.inputs.prNumber}}/head^{${{ github.event.inputs.commitSha }}}'
35+

0 commit comments

Comments
 (0)