This repository has been archived by the owner on Oct 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aa9ac75
commit 8e94e82
Showing
5 changed files
with
354 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: Update Slash Command Dispatch Comment | ||
|
||
description: Update Slash Command Dispatch comment with the run URL | ||
|
||
inputs: | ||
token: | ||
description: Personal Access Token (PAT) used to update the comment | ||
required: true | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Create URL to the run output | ||
id: vars | ||
shell: bash -e -o pipefail {0} | ||
run: echo "run-url=https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" >> $GITHUB_OUTPUT | ||
|
||
# Will update the comment that triggered the /test comment and add the run-url | ||
- name: Update comment | ||
if: github.event_name == 'repository_dispatch' | ||
uses: peter-evans/create-or-update-comment@v3 | ||
with: | ||
token: ${{ inputs.token }} | ||
repository: ${{ github.event.client_payload.github.payload.repository.full_name }} | ||
comment-id: ${{ github.event.client_payload.github.payload.comment.id }} | ||
body: | | ||
:robot: [View pipeline run][1] | ||
[1]: ${{ steps.vars.outputs.run-url }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
name: Run E2E Tests | ||
|
||
description: Run E2E Tests | ||
|
||
inputs: | ||
token: | ||
description: Personal Access Token (PAT) used to update the comment | ||
required: true | ||
region: | ||
description: The AWS region to deploy to | ||
required: true | ||
role-to-assume: | ||
description: The AWS IAM Role to assume in the target account | ||
required: true | ||
github-context: | ||
description: The GitHub Status Context to use when updating the status | ||
required: true | ||
aws-availability-zone: | ||
description: The AWS Availability Zone to use | ||
required: true | ||
ghcr-username: | ||
description: The Github container registry username to use | ||
required: true | ||
ghcr-password: | ||
description: The Github container registry password to use | ||
required: true | ||
registry1-username: | ||
description: The Registry1 container registry password to use | ||
required: true | ||
registry1-password: | ||
description: The Registry1 container registry password to use | ||
required: true | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
# Update GitHub status for pending pipeline run | ||
- name: "Update GitHub Status for pending" | ||
if: github.event_name == 'repository_dispatch' | ||
uses: docker://cloudposse/github-status-updater | ||
with: | ||
args: "-action update_state -state pending -ref ${{ env.REPO_SHA }} -repo ${{ env.REPO_NAME }}" | ||
env: | ||
REPO_SHA: ${{ github.event.client_payload.pull_request.head.sha || github.sha }} | ||
REPO_NAME: ${{ github.event.client_payload.github.payload.repository.name || github.event.repository.name }} | ||
GITHUB_TOKEN: ${{ inputs.token }} | ||
GITHUB_CONTEXT: ${{ inputs.github-context }} | ||
GITHUB_DESCRIPTION: "started by @${{ github.event.client_payload.github.actor || github.actor }}" | ||
GITHUB_TARGET_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} | ||
GITHUB_REF: ${{ github.event.client_payload.pull_request.head.ref || github.ref_name }} | ||
GITHUB_OWNER: ${{ github.event.client_payload.github.payload.repository.owner.login || github.repository_owner }} | ||
|
||
- name: Init gopath cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: "${{ github.workspace }}/.cache/go" | ||
key: "gopath|${{ hashFiles('.tool-versions') }}|${{ hashFiles('go.sum') }}" | ||
|
||
- name: Init gobuild cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: "${{ github.workspace }}/.cache/go-build" | ||
key: "gobuild|${{ hashFiles('.tool-versions') }}|${{ hashFiles('go.sum') }}" | ||
|
||
- name: Init zarf cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: "${{ github.workspace }}/.cache/.zarf-cache" | ||
key: "zarf|${{ hashFiles('.tool-versions') }}" | ||
|
||
- name: Init docker cache | ||
id: init-docker-cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: "${{ github.workspace }}/.cache/docker" | ||
key: "docker|${{ hashFiles('.env') }}" | ||
|
||
- name: Docker save build harness | ||
if: steps.init-docker-cache.outputs.cache-hit != 'true' | ||
shell: bash -e -o pipefail {0} | ||
run: | | ||
make docker-save-build-harness | ||
- name: Load build harness | ||
shell: bash -e -o pipefail {0} | ||
run: | | ||
make docker-load-build-harness | ||
- name: Get Terraform version from .tool-versions | ||
id: get_tf_version | ||
shell: bash -e -o pipefail {0} | ||
run: echo "tf_version=$(grep 'terraform ' .tool-versions)" >> $GITHUB_OUTPUT | ||
|
||
- name: Configure AWS Credentials for Commercial | ||
uses: aws-actions/configure-aws-credentials@v2 | ||
with: | ||
role-to-assume: ${{ inputs.role-to-assume }} | ||
role-session-name: ${{ github.event.client_payload.pull_request.head.sha || github.sha }} | ||
aws-region: ${{ inputs.region }} | ||
# 21600 seconds == 6 hours | ||
role-duration-seconds: 21600 | ||
|
||
- name: "Run E2E tests" | ||
shell: bash -e -o pipefail {0} | ||
env: | ||
AWS_AVAILABILITY_ZONE: ${{ inputs.aws-availability-zone }} | ||
AWS_DEFAULT_REGION: us-east-2 | ||
REGISTRY1_USERNAME: ${{ inputs.registry1-username }} | ||
REGISTRY1_PASSWORD: ${{ inputs.registry1-password }} | ||
GHCR_USERNAME: ${{ inputs.ghcr-username }} | ||
GHCR_PASSWORD: ${{ inputs.ghcr-password }} | ||
REPO_URL: https://github.com/${{ github.repository }}.git | ||
GIT_BRANCH: ${{ github.event.client_payload.pull_request.head.ref || github.ref_name }} | ||
run: | | ||
make test fix-cache-permissions | ||
# Update GitHub status for successful pipeline run | ||
- name: "Update GitHub Status for success" | ||
if: ${{ success() && github.event_name == 'repository_dispatch' }} | ||
uses: docker://cloudposse/github-status-updater | ||
with: | ||
args: "-action update_state -state success -ref ${{ env.REPO_SHA }} -repo ${{ env.REPO_NAME }}" | ||
env: | ||
REPO_SHA: ${{ github.event.client_payload.pull_request.head.sha || github.sha }} | ||
REPO_NAME: ${{ github.event.client_payload.github.payload.repository.name || github.event.repository.name }} | ||
GITHUB_TOKEN: ${{ inputs.token }} | ||
GITHUB_CONTEXT: ${{ inputs.github-context }} | ||
GITHUB_DESCRIPTION: "run passed" | ||
GITHUB_TARGET_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} | ||
GITHUB_REF: ${{ github.event.client_payload.pull_request.head.ref || github.ref_name }} | ||
GITHUB_OWNER: ${{ github.event.client_payload.github.payload.repository.owner.login || github.repository_owner }} | ||
|
||
# Update GitHub status for failing pipeline run | ||
- name: "Update GitHub Status for failure" | ||
if: ${{ failure() && github.event_name == 'repository_dispatch' }} | ||
uses: docker://cloudposse/github-status-updater | ||
with: | ||
args: "-action update_state -state failure -ref ${{ env.REPO_SHA }} -repo ${{ env.REPO_NAME }}" | ||
env: | ||
REPO_SHA: ${{ github.event.client_payload.pull_request.head.sha || github.sha }} | ||
REPO_NAME: ${{ github.event.client_payload.github.payload.repository.name || github.event.repository.name }} | ||
GITHUB_TOKEN: ${{ inputs.token }} | ||
GITHUB_CONTEXT: ${{ inputs.github-context }} | ||
GITHUB_DESCRIPTION: "run failed" | ||
GITHUB_TARGET_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} | ||
GITHUB_REF: ${{ github.event.client_payload.pull_request.head.ref || github.ref_name }} | ||
GITHUB_OWNER: ${{ github.event.client_payload.github.payload.repository.owner.login || github.repository_owner }} | ||
|
||
# Update GitHub status for cancelled pipeline run | ||
- name: "Update GitHub Status for cancelled" | ||
if: ${{ cancelled() && github.event_name == 'repository_dispatch' }} | ||
uses: docker://cloudposse/github-status-updater | ||
with: | ||
args: "-action update_state -state error -ref ${{ env.REPO_SHA }} -repo ${{ env.REPO_NAME }}" | ||
env: | ||
REPO_SHA: ${{ github.event.client_payload.pull_request.head.sha || github.sha }} | ||
REPO_NAME: ${{ github.event.client_payload.github.payload.repository.name || github.event.repository.name }} | ||
GITHUB_TOKEN: ${{ inputs.token }} | ||
GITHUB_CONTEXT: ${{ inputs.github-context }} | ||
GITHUB_DESCRIPTION: "run cancelled" | ||
GITHUB_TARGET_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} | ||
GITHUB_REF: ${{ github.event.client_payload.pull_request.head.ref || github.ref_name }} | ||
GITHUB_OWNER: ${{ github.event.client_payload.github.payload.repository.owner.login || github.repository_owner }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: Parse Slash Command Dispatch (/test) | ||
|
||
description: Parse Slash Command Dispatch (/test) | ||
|
||
outputs: | ||
run-ping: | ||
description: Will be 'true' if the 'ping' job should run | ||
value: ${{ steps.parse.outputs.ping }} | ||
run-e2e: | ||
description: Will be 'true' if the 'e2e' job should run | ||
value: ${{ steps.parse.outputs.e2e }} | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Parse Args | ||
id: parse | ||
env: | ||
DEBUG: ${{ toJSON(github.event.client_payload.slash_command) }} | ||
ARGS_V1: ${{ github.event.client_payload.slash_command.arg1 }} | ||
ARGS_V2: ${{ github.event.client_payload.slash_command.args.unnamed.all }} | ||
EVENT_NAME: ${{ github.event_name }} | ||
shell: bash -e -o pipefail {0} | ||
run: | | ||
ARGS="${ARGS_V1}${ARGS_V2}" | ||
# set ARGS to "all" if EVENT_NAME is "push" | ||
if [[ "${EVENT_NAME}" == "push" ]]; then | ||
ARGS="all" | ||
fi | ||
printf "Event name is %s\n" "$EVENT_NAME" | ||
printf "Args are %s\n" "$ARGS" | ||
printf "\n\nslash_command is %s\n\n" "$DEBUG" | ||
COMMANDS=(PING E2E) #all options here | ||
if printf "%s" "${ARGS^^}" | grep -qE '\bALL\b'; then | ||
# "all" explicitly does not include "ping" | ||
for cmd in "${COMMANDS[@]}"; do | ||
[[ $cmd == "PING" ]] && ! { printf "%s" "${ARGS^^}" | grep -qE '\bPING\b'; } && continue | ||
printf -v "$cmd" "true" | ||
done | ||
else | ||
for cmd in "${COMMANDS[@]}"; do | ||
if printf "%s" "${ARGS^^}" | grep -qE "\b${cmd}\b"; then | ||
printf -v "$cmd" "true" | ||
fi | ||
done | ||
fi | ||
for out in "${COMMANDS[@]}"; do | ||
printf "%s=%s\n" "${out,,}" "${!out:-false}" >> $GITHUB_OUTPUT | ||
printf "%s=%s\n" "${out,,}" "${!out:-false}" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: Slash Command Dispatch | ||
on: | ||
issue_comment: | ||
types: [created] | ||
jobs: | ||
slashCommandDispatch: | ||
if: github.event.issue.pull_request && contains(github.event.comment.body, '/test') | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Slash Command Dispatch | ||
uses: peter-evans/slash-command-dispatch@v3 | ||
with: | ||
token: ${{ secrets.PAT }} | ||
commands: test | ||
permission: write | ||
issue-type: pull-request |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
# Attribution for a bunch of this goes to CloudPosse | ||
# https://github.com/cloudposse/actions/blob/master/.github/workflows/test-command.yml | ||
|
||
name: test | ||
on: | ||
repository_dispatch: | ||
types: [test-command] | ||
push: | ||
branches: | ||
- main | ||
|
||
permissions: | ||
id-token: write | ||
contents: read | ||
|
||
defaults: | ||
run: | ||
# We need -e -o pipefail for consistency with GitHub Actions' default behavior | ||
shell: bash -e -o pipefail {0} | ||
|
||
jobs: | ||
# Parse the command so we can decide which tests to run. Examples: "/test all", "/test validate", "/test e2e" | ||
# We can do as many of these as we want to get as granular as we want. | ||
parse: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
run-ping: ${{ steps.parse.outputs.run-ping }} | ||
run-e2e: ${{ steps.parse.outputs.run-e2e }} | ||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@v3 | ||
with: | ||
token: ${{ secrets.PAT }} | ||
repository: ${{ github.event.client_payload.pull_request.head.repo.full_name || github.repository }} | ||
ref: ${{ github.event.client_payload.pull_request.head.ref || github.ref_name }} | ||
- name: Parse Args | ||
id: parse | ||
uses: ./.github/actions/parse-test | ||
|
||
# Update the comment that triggered the /test command to show the run url | ||
comment: | ||
if: github.event_name == 'repository_dispatch' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@v3 | ||
with: | ||
token: ${{ secrets.PAT }} | ||
repository: ${{ github.event.client_payload.pull_request.head.repo.full_name || github.repository }} | ||
ref: ${{ github.event.client_payload.pull_request.head.ref || github.ref_name }} | ||
- name: Update Comment | ||
uses: ./.github/actions/comment | ||
with: | ||
token: ${{ secrets.PAT }} | ||
|
||
# Do a simple ping/pong status update to validate things are working | ||
ping: | ||
runs-on: ubuntu-latest | ||
needs: parse | ||
if: needs.parse.outputs.run-ping == 'true' | ||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@v3 | ||
with: | ||
token: ${{ secrets.PAT }} | ||
repository: ${{ github.event.client_payload.pull_request.head.repo.full_name || github.repository }} | ||
ref: ${{ github.event.client_payload.pull_request.head.ref || github.ref_name }} | ||
- name: Ping Test | ||
uses: ./.github/actions/ping | ||
with: | ||
token: ${{ secrets.PAT }} | ||
|
||
# Run the E2E tests | ||
e2e: | ||
runs-on: ubuntu-latest | ||
needs: parse | ||
if: needs.parse.outputs.run-e2e == 'true' | ||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@v3 | ||
with: | ||
token: ${{ secrets.PAT }} | ||
repository: ${{ github.event.client_payload.pull_request.head.repo.full_name || github.repository }} | ||
ref: ${{ github.event.client_payload.pull_request.head.ref || github.ref_name }} | ||
- name: Run E2E Tests | ||
uses: ./.github/actions/e2e | ||
with: | ||
token: ${{ secrets.PAT }} | ||
role-to-assume: ${{ secrets.AWS_COMMERCIAL_ROLE_TO_ASSUME }} | ||
region: ${{ vars.AWS_REGION }} | ||
github-context: "test / e2e (${{github.event_name}})" | ||
aws-availability-zone: ${{ vars.AWS_AVAILABILITY_ZONE }} | ||
ghcr-username: ${{ github.actor }} | ||
ghcr-password: ${{ secrets.GITHUB_TOKEN }} | ||
registry1-username: ${{ secrets.REGISTRY1_USERNAME }} | ||
registry1-password: ${{ secrets.REGISTRY1_PASSWORD }} |