Skip to content

Commit cc39ec7

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

File tree

6 files changed

+134
-72
lines changed

6 files changed

+134
-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: 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'
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'
48+
runs-on: ubuntu-latest
49+
steps:
50+
- name: Run Slow Tests
51+
uses: ./.github/workflows/slow-tests.yml
52+
with:
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'
58+
runs-on: ubuntu-latest
59+
steps:
60+
- name: Run Local Mode Tests
61+
uses: ./.github/workflows/localmode-tests.yml
62+
with:
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.

.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)