Skip to content

Commit

Permalink
run extras on comment
Browse files Browse the repository at this point in the history
  • Loading branch information
benieric committed Jul 30, 2024
1 parent 1676a30 commit cc39ec7
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 72 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/codebuild-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
uses: actions/github-script@v7
id: collab-check
env:
PR_USER_LOGIN: ${{ github.event.pull_request.user.login }}
GH_USER_LOGIN: ${{ github.event.pull_request.user.login }}
with:
github-token: ${{ secrets.COLLAB_CHECK_TOKEN }}
result-encoding: string
Expand All @@ -35,7 +35,7 @@ jobs:
const res = await github.rest.repos.checkCollaborator({
owner: context.repo.owner,
repo: context.repo.repo,
username: "${{ env.PR_USER_LOGIN }}",
username: "${{ env.GH_USER_LOGIN }}",
});
console.log("Verifed user is a repo collaborator. Auto Approving PR Checks.")
return res.status == "204" ? "auto-approve" : "manual-approval"
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/localmode-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Run Local Mode Tests

on:
workflow_call:
inputs:
prNumber:
required: true
type: number
commitSha:
required: true
type: string

concurrency:
group: ${{ github.workflow }}-${{ inputs.prNumber }}
cancel-in-progress: true

permissions:
id-token: write # This is required for requesting the JWT

jobs:
local-mode-tests:
runs-on: ubuntu-latest
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.CI_AWS_ROLE_ARN }}
aws-region: us-west-2
role-duration-seconds: 10800
- name: Run Test
uses: aws-actions/aws-codebuild-run-build@v1
with:
project-name: ${{ github.repository.name }}-ci-localmode-tests
source-version-override: 'refs/pull/${{ inputs.prNumber }}/head^{${{ inputs.commitSha }}}'
64 changes: 64 additions & 0 deletions .github/workflows/run-extras.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Run Extras

on:
pull_request_review:
types: [submitted]

permissions:
id-token: write # This is required for requesting the JWT

jobs:
check-comment:
if: github.event.review.body == '/run slow' || github.event.review.body == '/run localmode'
runs-on: ubuntu-latest
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.MONITORING_AWS_ROLE_ARN }}
aws-region: us-west-2
- name: Collaborator Check
uses: actions/github-script@v7
id: collab-check
env:
GH_USER_LOGIN: ${{ github.event.review.user.login }}
with:
github-token: ${{ secrets.COLLAB_CHECK_TOKEN }}
result-encoding: string
script: |
try {
const res = await github.rest.repos.checkCollaborator({
owner: context.repo.owner,
repo: context.repo.repo,
username: "${{ env.GH_USER_LOGIN }}",
});
console.log("Verifed user is a repo collaborator.")
return
} catch (error) {
if (error.message == "Bad credentials") {
console.log("Token Expired. Please update the COLLAB_CHECK_TOKEN secret.")
const { execSync } = require('child_process')
execSync('aws cloudwatch put-metric-data --namespace "GitHubActions" --metric-name "BadCredentials" --value 1')
}
throw new Error("Collaborator status could not be verified.")
}
run-slow-tests:
needs: [check-comment]
if: needs.check-comment.result == 'success' && github.event.review.body == '/run slow'
runs-on: ubuntu-latest
steps:
- name: Run Slow Tests
uses: ./.github/workflows/slow-tests.yml
with:
prNumber: ${{ github.event.pull_request.number }}
commitSha: ${{ github.event.pull_request.head.sha }}
run-localmode-tests:
needs: [check-comment]
if: needs.check-comment.result == 'success' && github.event.review.body == '/run localmode'
runs-on: ubuntu-latest
steps:
- name: Run Local Mode Tests
uses: ./.github/workflows/localmode-tests.yml
with:
prNumber: ${{ github.event.pull_request.number }}
commitSha: ${{ github.event.pull_request.head.sha }}
35 changes: 0 additions & 35 deletions .github/workflows/run-local-mode-tests.yml

This file was deleted.

35 changes: 0 additions & 35 deletions .github/workflows/run-slow-tests.yml

This file was deleted.

34 changes: 34 additions & 0 deletions .github/workflows/slow-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Run Slow Tests

on:
workflow_call:
inputs:
prNumber:
required: true
type: number
commitSha:
required: true
type: string

concurrency:
group: ${{ github.workflow }}-${{ inputs.prNumber }}
cancel-in-progress: true

permissions:
id-token: write # This is required for requesting the JWT

jobs:
local-mode-tests:
runs-on: ubuntu-latest
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.CI_AWS_ROLE_ARN }}
aws-region: us-west-2
role-duration-seconds: 10800
- name: Run Test
uses: aws-actions/aws-codebuild-run-build@v1
with:
project-name: ${{ github.repository.name }}-ci-slow-tests
source-version-override: 'refs/pull/${{ inputs.prNumber }}/head^{${{ inputs.commitSha }}}'

0 comments on commit cc39ec7

Please sign in to comment.