generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 8
Fix Synchronization of Create Channel & Sanity Tests #339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
91ac060
Added dispatcher and removed triggers for create-channel and sanity-test
41af0db
new branch check
6e9b5b5
minor optimizations
1353036
make dispatch a separate script and invoke
d45eb8b
simplified trigger
050917b
diff against recent successful build
e1e136c
change job name and use branch name
86147a8
print branch name for clarity
e62fb62
change job names
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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,67 @@ | ||
| #!/bin/bash | ||
| set -e | ||
|
|
||
| # checks for previous successful runs on the branch | ||
| BRANCH="${GITHUB_REF_NAME}" | ||
| echo "Checking for previous successful runs on this branch: $BRANCH" | ||
| COMMIT_ID=$(gh run list -w="Dispatcher Workflow" --branch="$BRANCH" --json conclusion,headSha --jq 'first(.[] | select(.conclusion == "success")) | .headSha // empty' ) | ||
| if [[ -z "$COMMIT_ID" ]]; then | ||
| echo "Found no successful dispatch runs on this branch." | ||
| echo "trigger_create=true" >> $GITHUB_OUTPUT | ||
| echo "trigger_sanity_test=true" >> $GITHUB_OUTPUT | ||
| exit 0 | ||
| fi | ||
|
|
||
| # check if new changes on push requires re-running the create-channel | ||
| # we look at diffs from the last successful workflow run to current commit | ||
| if ! git fetch origin $COMMIT_ID; then | ||
| echo "Failed to fetch commit $COMMIT_ID." | ||
| echo "Setting create and sanity test to true because this might be a new branch with the same name." | ||
| echo "trigger_create=true" >> $GITHUB_OUTPUT | ||
| echo "trigger_sanity_test=true" >> $GITHUB_OUTPUT | ||
| exit 0 | ||
| fi | ||
|
|
||
| SHORT_HASH=$(git rev-parse --short $COMMIT_ID) | ||
| COMMIT_MESSAGE=$(git log --format="%s" -n 1 $COMMIT_ID) | ||
| echo "Found previous successful run for commit $SHORT_HASH: $COMMIT_MESSAGE" | ||
|
|
||
| CHANGED="$(git diff --name-only $COMMIT_ID $GITHUB_SHA)" | ||
|
|
||
| echo "---------------------" | ||
| echo "CHANGES" | ||
| echo "---------------------" | ||
| echo "$CHANGED" | ||
|
|
||
| CHANGES_THAT_TRIGGER_CREATE="(^\.github/actions/.*)|"\ | ||
| "(^\.github/workflows/[^/]*\.sh$)|"\ | ||
| "(^\.github/workflows/(create-channel|dispatcher)\.yml$)|"\ | ||
| "(^\.github/docker-images/.*$)|"\ | ||
| "(^builder/.*)" | ||
|
|
||
| CHANGES_THAT_TRIGGERED_CREATE=$(echo "$CHANGED" | grep -E "$CHANGES_THAT_TRIGGER_CREATE") || true # job should continue if no matches are found | ||
|
|
||
| if [ -n "$CHANGES_THAT_TRIGGERED_CREATE" ]; then | ||
| echo "---------------------" | ||
| echo "CHANGES THAT TRIGGERED CREATE AND SANITY TEST" | ||
| echo "---------------------" | ||
| echo "$CHANGES_THAT_TRIGGERED_CREATE" | ||
| echo "trigger_create=true" >> $GITHUB_OUTPUT | ||
| echo "trigger_sanity_test=true" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "No changes detected that would require channel-create flow to run." | ||
| echo "trigger_create=false" >> $GITHUB_OUTPUT | ||
|
|
||
| CHANGES_THAT_DO_NOT_TRIGGER_SANITY_TEST="(^.*\.md$)|(^.gitignore)|(NOTICE)|(LICENSE)" | ||
|
|
||
| if [[ -n $(echo "$CHANGED" | grep -vE "$CHANGES_THAT_DO_NOT_TRIGGER_SANITY_TEST") ]]; then | ||
| echo "---------------------" | ||
| echo "CHANGES THAT TRIGGER SANITY TEST" | ||
| echo "---------------------" | ||
| echo "$CHANGED" | grep -vE "$CHANGES_THAT_DO_NOT_TRIGGER_SANITY_TEST" | ||
| echo "trigger_sanity_test=true" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "No changes detected that would require a sanity test." | ||
| echo "trigger_sanity_test=false" >> $GITHUB_OUTPUT | ||
| fi | ||
| fi | ||
This file contains hidden or 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,77 @@ | ||
| name: Dispatcher Workflow | ||
|
|
||
| permissions: | ||
| contents: read | ||
| actions: read | ||
| id-token: write | ||
|
|
||
| on: | ||
| push: | ||
| branches-ignore: | ||
| - 'main' | ||
|
|
||
| jobs: | ||
| setup_dispatch: # This job sets up variables that determine if create and/or sanity test need to be run. | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| trigger_create: ${{ steps.set_trigger.outputs.trigger_create }} | ||
| trigger_sanity_test: ${{ steps.set_trigger.outputs.trigger_sanity_test }} | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Set flags for create channel and sanity test | ||
| id: set_trigger | ||
| run: './.github/workflows/dispatcher.sh' | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| GITHUB_SHA: ${{ github.sha }} | ||
| GITHUB_REF: ${{ github.ref }} | ||
|
|
||
| - name: results | ||
| run: | | ||
| echo "trigger_create: ${{ steps.set_trigger.outputs.trigger_create }}" | ||
| echo "trigger_sanity_test: ${{ steps.set_trigger.outputs.trigger_sanity_test }}" | ||
|
|
||
| run_create: | ||
azkrishpy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| needs: setup_dispatch | ||
| if: ${{ needs.setup_dispatch.outputs.trigger_create == 'true' }} | ||
| uses: ./.github/workflows/create-channel.yml | ||
| secrets: | ||
| AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }} | ||
| CRT_CI_ROLE_ARN: ${{ secrets.CRT_CI_ROLE_ARN }} | ||
| AWS_ECR_REPO: ${{ secrets.AWS_ECR_REPO }} | ||
|
|
||
| run_sanity_test: | ||
azkrishpy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| needs: [setup_dispatch, run_create] | ||
| if: ${{ needs.setup_dispatch.outputs.trigger_sanity_test == 'true' && needs.setup_dispatch.outputs.trigger_create == 'true' }} | ||
| uses: ./.github/workflows/sanity-test.yml | ||
| secrets: | ||
| AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }} | ||
| CRT_CI_ROLE_ARN: ${{ secrets.CRT_CI_ROLE_ARN }} | ||
| AWS_ECR_REPO: ${{ secrets.AWS_ECR_REPO }} | ||
|
|
||
| run_sanity_test_only: | ||
azkrishpy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| needs: setup_dispatch | ||
| if: ${{ needs.setup_dispatch.outputs.trigger_sanity_test == 'true' && needs.setup_dispatch.outputs.trigger_create != 'true' }} | ||
| uses: ./.github/workflows/sanity-test.yml | ||
| secrets: | ||
| AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }} | ||
| CRT_CI_ROLE_ARN: ${{ secrets.CRT_CI_ROLE_ARN }} | ||
| AWS_ECR_REPO: ${{ secrets.AWS_ECR_REPO }} | ||
|
|
||
| validate_tests_passed: | ||
| needs: [setup_dispatch, run_create, run_sanity_test, run_sanity_test_only] | ||
| if: always() | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Check all jobs succeeded | ||
| run: | | ||
| for result in "${{ needs.run_create.result }}" "${{ needs.run_sanity_test.result }}" "${{ needs.run_sanity_test_only.result }}"; do | ||
| if [[ "$result" != "success" && "$result" != "skipped" ]]; then | ||
| echo "One or more jobs failed, were cancelled, or had errors (result: $result)" | ||
| exit 1 | ||
| fi | ||
| done | ||
| echo "All required jobs have completed successfully" | ||
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.