Skip to content

Commit

Permalink
test: Add PR status check reporting for snapshot runs (#4117)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-innis committed Jun 23, 2023
1 parent 77224e8 commit 29d8de2
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 8 deletions.
36 changes: 36 additions & 0 deletions .github/actions/e2e/commit-status/end/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: CommitStatusEnd
description: 'Adds a commit status at the end of the test run based on success, failure, or cancelled'
inputs:
suite:
description: "Suite that's running"
required: true
git_ref:
description: "The git commit, tag, or branch to check out. Requires a corresponding Karpenter snapshot release"
required: true
runs:
using: "composite"
steps:
- uses: actions/github-script@v6
if: job.status == 'success'
with:
script: |
github.rest.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
context: "${{ github.workflow }} / e2e (${{ inputs.suite }}) / ${{ github.job }}",
sha: "${{ inputs.git_ref }}",
state: "success",
target_url: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} (snapshot)",
});
- uses: actions/github-script@v6
if: job.status == 'failure' || job.status == 'cancelled'
with:
script: |
github.rest.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
context: "${{ github.workflow }} / e2e (${{ inputs.suite }}) / ${{ github.job }} (snapshot)",
sha: "${{ inputs.git_ref }}",
state: "failure",
target_url: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
});
24 changes: 24 additions & 0 deletions .github/actions/e2e/commit-status/start/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: CommitStatusStart
description: 'Adds a commit status at the start of the test run to set the status to pending'
inputs:
suite:
description: "Suite that's running"
required: true
git_ref:
description: "The git commit, tag, or branch to check out. Requires a corresponding Karpenter snapshot release"
required: true
runs:
using: "composite"
steps:
- uses: actions/github-script@v6
if: always()
with:
script: |
github.rest.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
context: "${{ github.workflow }} / e2e (${{ inputs.suite }}) / ${{ github.job }} (snapshot)",
sha: "${{ inputs.git_ref }}",
state: "pending",
target_url: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
});
2 changes: 1 addition & 1 deletion .github/actions/e2e/slack/notify/action.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: NotifySlack
name: SlackNotify
description: 'Notifies slack of the success or failure of the suite'
inputs:
suite:
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/e2e/slack/send-message/action.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: NotifySlack
name: SlackSendMessage
description: 'Notifies slack of the success or failure of the suite'
inputs:
message:
Expand Down
21 changes: 18 additions & 3 deletions .github/workflows/e2e-upgrade.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,29 @@ on:
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
statuses: write
jobs:
run-suite:
runs-on: ubuntu-latest
steps:
# This additional checkout can be removed when the commit status action is added to the from_git_ref version of Karpenter
- uses: actions/checkout@v3
with:
ref: ${{ inputs.to_git_ref }}
- if: always() && inputs.event_name == 'workflow_run'
uses: ./.github/actions/e2e/commit-status/start
with:
suite: Upgrade
git_ref: ${{ inputs.to_git_ref }}
- uses: actions/checkout@v3
with:
ref: ${{ inputs.from_git_ref }}
- name: configure aws credentials
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: arn:aws:iam::${{ vars.ACCOUNT_ID }}:role/${{ vars.ROLE_NAME }}
aws-region: ${{ vars.AWS_REGION }}
role-duration-seconds: 21600
- uses: actions/checkout@v3
with:
ref: ${{ inputs.from_git_ref }}
- name: generate cluster name
run: |
CLUSTER_NAME="upgrade-$RANDOM$RANDOM"
Expand Down Expand Up @@ -152,3 +162,8 @@ jobs:
region: ${{ vars.AWS_REGION }}
cluster_name: ${{ env.CLUSTER_NAME }}
git_ref: ${{ inputs.to_git_ref }}
- if: always() && inputs.event_name == 'workflow_run'
uses: ./.github/actions/e2e/commit-status/end
with:
suite: Upgrade
git_ref: ${{ inputs.to_git_ref }}
17 changes: 14 additions & 3 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,25 @@ on:
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
statuses: write
jobs:
run-suite:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ inputs.git_ref }}
- if: always() && inputs.event_name == 'workflow_run'
uses: ./.github/actions/e2e/commit-status/start
with:
suite: ${{ inputs.suite }}
git_ref: ${{ inputs.git_ref }}
- name: configure aws credentials
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: arn:aws:iam::${{ vars.ACCOUNT_ID }}:role/${{ vars.ROLE_NAME }}
aws-region: ${{ vars.AWS_REGION }}
role-duration-seconds: 21600
- uses: actions/checkout@v3
with:
ref: ${{ inputs.git_ref }}
- name: generate cluster name
run: |
CLUSTER_NAME=$(echo ${{ inputs.suite }}-$RANDOM$RANDOM | awk '{print tolower($0)}')
Expand Down Expand Up @@ -123,3 +129,8 @@ jobs:
region: ${{ vars.AWS_REGION }}
cluster_name: ${{ env.CLUSTER_NAME }}
git_ref: ${{ inputs.git_ref }}
- if: always() && inputs.event_name == 'workflow_run'
uses: ./.github/actions/e2e/commit-status/end
with:
suite: ${{ inputs.suite }}
git_ref: ${{ inputs.git_ref }}

0 comments on commit 29d8de2

Please sign in to comment.