Skip to content

Commit da0f49a

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

File tree

6 files changed

+131
-72
lines changed

6 files changed

+131
-72
lines changed

.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/localmode-tests.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Run Local Mode Tests
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
prNumber:
7+
required: true
8+
type: number
9+
commitSha:
10+
required: true
11+
type: string
12+
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ 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 Test
31+
uses: aws-actions/aws-codebuild-run-build@v1
32+
with:
33+
project-name: ${{ github.repository.name }}-ci-localmode-tests
34+
source-version-override: 'refs/pull/${{ inputs.prNumber }}/head^{${{ inputs.commitSha }}}'

.github/workflows/run-extras.yml

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

.github/workflows/slow-tests.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Run Slow Tests
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
prNumber:
7+
required: true
8+
type: number
9+
commitSha:
10+
required: true
11+
type: string
12+
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ 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 Test
31+
uses: aws-actions/aws-codebuild-run-build@v1
32+
with:
33+
project-name: ${{ github.repository.name }}-ci-slow-tests
34+
source-version-override: 'refs/pull/${{ inputs.prNumber }}/head^{${{ inputs.commitSha }}}'

0 commit comments

Comments
 (0)