Skip to content

Commit

Permalink
Merge branch 'main' into rakechill/nodeclaim-e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
rakechill authored Nov 9, 2023
2 parents 22cee60 + 62a8b3c commit f3bf540
Show file tree
Hide file tree
Showing 8 changed files with 156 additions and 7 deletions.
36 changes: 36 additions & 0 deletions .github/actions/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:
name:
description: "Name of the check"
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: "${{ inputs.name }}",
sha: "${{ inputs.git_ref }}",
state: "success",
target_url: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
});
- 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: "${{ inputs.name }}",
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/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:
name:
description: "Name of the check"
required: true
git_ref:
description: "The git commit, tag, or branch to check out"
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: "${{ inputs.name }}",
sha: "${{ inputs.git_ref }}",
state: "pending",
target_url: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
});
32 changes: 32 additions & 0 deletions .github/actions/download-artifact/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: DownloadArtifacts
description: 'Downloads and unarchives artifacts for a workflow that runs on workflow_run so that it can use its data'
runs:
using: "composite"
steps:
- uses: actions/github-script@v6
with:
script: |
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
return artifact.name == "artifacts"
})[0];
let download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
let fs = require('fs');
fs.writeFileSync(`/tmp/artifacts.zip`, Buffer.from(download.data));
- run: |
mkdir -p /tmp/artifacts
unzip /tmp/artifacts.zip -d /tmp/artifacts
shell: bash
- run: |
echo "Downloaded artifacts:"
ls -ablh /tmp/artifacts
shell: bash
17 changes: 14 additions & 3 deletions .github/workflows/approval-comment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,20 @@ on:

jobs:
approval-comment:
if: startsWith(github.event.review.body, '/e2e')
if: startsWith(github.event.review.body, '/test')
runs-on: ubuntu-latest
steps:
- name: run e2e
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Save info about the review comment as an artifact for other workflows that run on workflow_run to download them
env:
REVIEW_BODY: ${{ github.event.review.body }}
run: |
echo "run e2e"
mkdir -p /tmp/artifacts
{ echo ${{ github.event.pull_request.number }}; echo ${{ github.event.review.commit_id }}; } >> /tmp/artifacts/metadata.txt
cat /tmp/artifacts/metadata.txt
- uses: actions/upload-artifact@v3
with:
name: artifacts
path: /tmp/artifacts
13 changes: 10 additions & 3 deletions .github/workflows/e2e-matrix-trigger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,22 @@ on:
workflow_dispatch:
push:
branches: [main]
pull_request_review: # TODO(charliedmcb): come back to this and factor out the E2E trigger like AWS and clean it up
types: [submitted]
workflow_run:
workflows: [ApprovalComment]
types: [completed]
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
statuses: write # ./.github/actions/commit-status/*
jobs:
resolve:
if: github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success'
uses: ./.github/workflows/resolve-args.yaml
e2e-matrix:
if: github.event_name != 'pull_request_review' || startsWith(github.event.review.body ,'/test')
needs: [resolve]
uses: ./.github/workflows/e2e-matrix.yaml
with:
git_ref: ${{ needs.resolve.outputs.GIT_REF }}
secrets:
E2E_CLIENT_ID: ${{ secrets.E2E_CLIENT_ID }}
E2E_TENANT_ID: ${{ secrets.E2E_TENANT_ID }}
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/e2e-matrix.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
name: E2EMatrix
on:
workflow_call:
# inputs:
inputs:
git_ref:
type: string
# region:
# type: string
# default: "us-east-2"
Expand Down Expand Up @@ -34,6 +36,7 @@ jobs:
suite: [Nonbehavioral, Utilization, GPU, Drift, Integration, NodeClaim]
uses: ./.github/workflows/e2e.yaml
with:
git_ref: ${{ inputs.git_ref }}
suite: ${{ matrix.suite }}
hash: ${{ needs.initialize-generative-params.outputs.E2E_HASH }}
# region: ${{ inputs.region }}
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:
# region:
# type: string
# default: "us-east-2"
git_ref:
type: string
suite:
type: string
required: true
Expand All @@ -24,6 +26,7 @@ on:
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
statuses: write # ./.github/actions/commit-status/*
jobs:
run-suite:
name: suite-${{ inputs.suite }}
Expand All @@ -32,6 +35,11 @@ jobs:
AZURE_SUBSCRIPTION_ID: ${{ secrets.E2E_SUBSCRIPTION_ID }}
steps:
- uses: actions/checkout@v3
- if: always() && github.event_name == 'workflow_run'
uses: ./.github/actions/commit-status/start
with:
name: ${{ github.workflow }} / e2e (${{ inputs.suite }})
git_ref: ${{ inputs.git_ref }}
- uses: ./.github/actions/install-deps
- name: az login
uses: azure/login@v1
Expand Down Expand Up @@ -120,3 +128,8 @@ jobs:
resource_group: ${{ env.RG_NAME }}
cluster_name: ${{ env.CLUSTER_NAME }}
acr_name: ${{ env.ACR_NAME }}
- if: always() && github.event_name == 'workflow_run'
uses: ./.github/actions/commit-status/end
with:
name: ${{ github.workflow }} / e2e (${{ inputs.suite }})
git_ref: ${{ inputs.git_ref }}
23 changes: 23 additions & 0 deletions .github/workflows/resolve-args.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: ResolveArgs
on:
workflow_call:
outputs:
GIT_REF:
value: ${{ jobs.resolve.outputs.GIT_REF }}
jobs:
resolve:
runs-on: ubuntu-latest
outputs:
GIT_REF: ${{ steps.resolve-step.outputs.GIT_REF }}
steps:
# Download the artifact and resolve the GIT_REF
- uses: actions/checkout@v4
- if: github.event_name == 'workflow_run'
uses: ./.github/actions/download-artifact
- id: resolve-step
run: |
if [[ "${{ github.event_name }}" == "workflow_run" ]]; then
echo GIT_REF="$(tail -n 1 /tmp/artifacts/metadata.txt)" >> "$GITHUB_OUTPUT"
else
echo GIT_REF="" >> "$GITHUB_OUTPUT"
fi

0 comments on commit f3bf540

Please sign in to comment.