Skip to content

Commit

Permalink
watchdog triggers subsets
Browse files Browse the repository at this point in the history
Signed-off-by: Oliver Koenig <[email protected]>
  • Loading branch information
ko3n1g committed May 15, 2024
1 parent f71c124 commit b03dba0
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 26 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/_ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ permissions:
jobs:
pre-flight:
runs-on: ubuntu-22.04
env:
VALID_SUBSETS: "base core levanter equinox triton upstream-t5x rosetta-t5x upstream-pax rosetta-pax maxtext grok"
outputs:
BUILD_TRITON: ${{ steps.run-conditions.outputs.BUILD_TRITON }}
BUILD_EQUINOX: ${{ steps.run-conditions.outputs.BUILD_EQUINOX }}
Expand All @@ -72,10 +70,15 @@ jobs:
TEST_ROSETTA_PAX: ${{ steps.run-conditions.outputs.TEST_ROSETTA_PAX }}
TEST_ROSETTA_T5X: ${{ steps.run-conditions.outputs.TEST_ROSETTA_T5X }}
steps:
- name: Check out the repository under ${GITHUB_WORKSPACE}
uses: actions/checkout@v4

- name: Validate input `TEST_SUBSET`
shell: bash
run: |
if [[ " $VALID_SUBSETS " != *" ${{ inputs.TEST_SUBSET }} "* ]]; then
valid_subsets=$(yq '.on.workflow_dispatch.inputs.TEST_SUBSET.options | join(",")' .github/workflows/ci.yaml)
if [[ "$valid_subsets" != *"${{ inputs.TEST_SUBSET }}"* ]]; then
echo "Invalid value for \`TEST_SUBSET\` provided. Expected one of: ($valid_inputs), Actual: ${{ inputs.TEST_SUBSET }}"
exit 1
fi
Expand Down
89 changes: 80 additions & 9 deletions .github/workflows/_watchdog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,64 @@ on:
types: [created]

jobs:
woof:
pre-woof:
runs-on: ubuntu-22.04
if: >
github.event_name == 'issue_comment' &&
github.event.issue.pull_request &&
startsWith(github.event.comment.body, '/ci') &&
contains('ko3n1g,nouiz,joker-eph,yhtang,terrykong,hemildesai,chaserileyroberts,CliveUnger,DwarKapex,mingxu1067,kocchop,SahilJain314,ashors1,maanug-nv,hmonishN,gspschmid', format('{0},', github.actor))
outputs:
test_subset: ${{ steps.state.outputs.test_subset }}
steps:
- name: Check out the repository under ${GITHUB_WORKSPACE}
uses: actions/checkout@v4

- name: Verify state
shell: bash
id: state
run: |
test_subset=$(echo "${{ github.event.comment.body }} " | cut -d' ' -f2- | tr -d ' ')
valid_test_subsets=$(yq '.on.workflow_dispatch.inputs.TEST_SUBSET.options | join(",")' .github/workflows/ci.yaml)
if [[ "$valid_test_subsets" != *"$test_subset"* ]]; then
message="Invalid value for '/ci \$TEST_SUBSET' provided ❌. Expected one of: ($valid_test_subsets), Actual: $test_subset"
echo "message=$message" >> "$GITHUB_OUTPUT"
exit 1
else
message="About to trigger presubmit CI on '$test_subset'. Stay tuned for the next update ⏳."
echo "message=$message" >> "$GITHUB_OUTPUT"
fi
echo "test_subset=$test_subset" >> "$GITHUB_OUTPUT"
- name: Update PR issue comment
shell: bash
if: always()
run: |
message="${{ github.event.comment.body}}<woof>
---
Watchdog 🤖: ${{ steps.state.outputs.message }}
</woof>
"
# GitHub needs HTML tags instead of newline chars
message="${message//$'\n'/<br>}"
# Fire
curl -L \
-X PATCH \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${{ github.repository }}/issues/comments/${{ github.event.comment.id }} \
-d '{"body":"'"$message"'"}'
woof:
runs-on: ubuntu-22.04
needs: pre-woof
steps:
- name: Get PR number
shell: bash
Expand Down Expand Up @@ -43,22 +94,42 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
wait-for-completion: false
ref: ${{ steps.get-pr-branch.outputs.result }}

- name: Update `GITHUB_STEP_SUMMARY`
shell: bash
run: echo "Click [here](${{ steps.trigger.outputs.workflow-url }}) to navigate to the workflow run." >> $GITHUB_STEP_SUMMARY

- name: Update PR issue comment
inputs: '{ "TEST_SUBSET": "${{ needs.pre-woof.outputs.test_subset }}" }'

- name: Create result message
shell: bash
id: result
if: always()
run: |
message="${{ github.event.comment.body}}
if [[ "${{ steps.trigger.outcome }}" == "success" ]]; then
dispatch_result_message="presubmit CI was successfully triggered ✅. Click [here](${{ steps.trigger.outputs.workflow-url }}) to navigate to the workflow run."
else
dispatch_result_message="presubmit CI was not successfully triggered ❌. Click [here](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for more information."
fi
dispatch_result_message="Watchdog 🤖: $dispatch_result_message"
echo "${{ steps.message.outputs.message }}" >> $GITHUB_STEP_SUMMARY
# Fetch original commit issue message
message="${{ github.event.comment.body}}"
# Remove previous woof-response
message=$(awk -F '<woof>' '{print $1}' <<< "$message")
# Add new woof-response
message="$message<woof>
---
Watchdog 🤖: presubmit CI was automatically triggered. Click [here](${{ steps.trigger.outputs.workflow-url }}) to navigate to the workflow run.
$dispatch_result_message
</woof>
"
# GitHub needs HTML tags instead of newline chars
message="${message//$'\n'/<br>}"
# Fire
curl -L \
-X PATCH \
-H "Accept: application/vnd.github+json" \
Expand Down
14 changes: 0 additions & 14 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ on:
- synchronize
paths-ignore:
- '**.md'
issue_comment:
types: [created]
workflow_dispatch:
inputs:
PUBLISH:
Expand Down Expand Up @@ -68,20 +66,8 @@ env:
DEFAULT_MANIFEST_ARTIFACT_NAME: bumped-manifest

jobs:
pre-flight:
runs-on: ubuntu-22.04
if: >
github.event_name == 'issue_comment' &&
github.event.issue.pull_request &&
contains(github.event.comment.body, '/cicd')
steps:
- name: Triggered by comment
shell: bash
run: exit 0

metadata:
runs-on: ubuntu-22.04
needs: pre-flight
outputs:
BUILD_DATE: ${{ steps.date.outputs.BUILD_DATE }}
PUBLISH: ${{ steps.if-publish.outputs.PUBLISH }}
Expand Down

0 comments on commit b03dba0

Please sign in to comment.