Skip to content

Commit ae1e742

Browse files
committed
run extras on comment
1 parent 1676a30 commit ae1e742

File tree

6 files changed

+146
-72
lines changed

6 files changed

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

.github/workflows/codebuild-ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
uses: actions/github-script@v7
2727
id: collab-check
2828
env:
29-
PR_USER_LOGIN: ${{ github.event.pull_request.user.login }}
29+
GH_USER_LOGIN: ${{ github.event.pull_request.user.login }}
3030
with:
3131
github-token: ${{ secrets.COLLAB_CHECK_TOKEN }}
3232
result-encoding: string
@@ -35,7 +35,7 @@ jobs:
3535
const res = await github.rest.repos.checkCollaborator({
3636
owner: context.repo.owner,
3737
repo: context.repo.repo,
38-
username: "${{ env.PR_USER_LOGIN }}",
38+
username: "${{ env.GH_USER_LOGIN }}",
3939
});
4040
console.log("Verifed user is a repo collaborator. Auto Approving PR Checks.")
4141
return res.status == "204" ? "auto-approve" : "manual-approval"

.github/workflows/run-extras.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Run Extras
2+
3+
on:
4+
pull_request_review:
5+
types: [submitted]
6+
7+
permissions:
8+
id-token: write # This is required for requesting the JWT
9+
10+
jobs:
11+
check-comment:
12+
if: github.event.review.body == '/run slow' || github.event.review.body == '/run localmode' || github.event.review.body == '/run extras'
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Configure AWS Credentials
16+
uses: aws-actions/configure-aws-credentials@v4
17+
with:
18+
role-to-assume: ${{ secrets.MONITORING_AWS_ROLE_ARN }}
19+
aws-region: us-west-2
20+
- name: Collaborator Check
21+
uses: actions/github-script@v7
22+
id: collab-check
23+
env:
24+
GH_USER_LOGIN: ${{ github.event.review.user.login }}
25+
with:
26+
github-token: ${{ secrets.COLLAB_CHECK_TOKEN }}
27+
result-encoding: string
28+
script: |
29+
try {
30+
const res = await github.rest.repos.checkCollaborator({
31+
owner: context.repo.owner,
32+
repo: context.repo.repo,
33+
username: "${{ env.GH_USER_LOGIN }}",
34+
});
35+
console.log("Verifed user is a repo collaborator.")
36+
return
37+
} catch (error) {
38+
if (error.message == "Bad credentials") {
39+
console.log("Token Expired. Please update the COLLAB_CHECK_TOKEN secret.")
40+
const { execSync } = require('child_process')
41+
execSync('aws cloudwatch put-metric-data --namespace "GitHubActions" --metric-name "BadCredentials" --value 1')
42+
}
43+
throw new Error("Collaborator status could not be verified.")
44+
}
45+
run-slow-tests:
46+
needs: [check-comment]
47+
if: needs.check-comment.result == 'success' && github.event.review.body == '/run slow' || github.event.review.body == '/run extras'
48+
uses: ./.github/workflows/trigger-codebuild.yml
49+
secrets:
50+
CI_AWS_ROLE_ARN: ${{ secrets.CI_AWS_ROLE_ARN }}
51+
with:
52+
codeBuildProjectName: "${{ github.repository.name }}-ci-slow-tests"
53+
prNumber: ${{ github.event.pull_request.number }}
54+
commitSha: ${{ github.event.pull_request.head.sha }}
55+
run-localmode-tests:
56+
needs: [check-comment]
57+
if: needs.check-comment.result == 'success' && github.event.review.body == '/run localmode' || github.event.review.body == '/run extras'
58+
uses: ./.github/workflows/trigger-codebuild.yml
59+
secrets:
60+
CI_AWS_ROLE_ARN: ${{ secrets.CI_AWS_ROLE_ARN }}
61+
with:
62+
codeBuildProjectName: "${{ github.repository.name }}-ci-localmode-tests"
63+
prNumber: ${{ github.event.pull_request.number }}
64+
commitSha: ${{ github.event.pull_request.head.sha }}

.github/workflows/run-local-mode-tests.yml

Lines changed: 0 additions & 35 deletions
This file was deleted.

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

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

0 commit comments

Comments
 (0)