-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(repo): skip hangar when not needed (#3791)
### Goal Skip e2e tests when the changes in the PR don't effect it. Notably, this usually means unit tests, README, or anything in the console. "changes" here means one of 2 things: - **If non-pr:** Last successful build workflow on the same branch - **If pr:** git diff of the PR compared to the base, ignoring any commits from upstream This high-level logic is the same that we've been using to determine whether or not we deploy the vscode extension, so this extends it to the e2e and benchmarking tests as well. Unfortunately turbo itself was not sufficient for this goal (see note at the top of `tools/bump-pack/src/turbo-diff.ts`), so I had to write some junk to properly determine "what changed". I swear I've had to write something like this like 9 times already at various points in my life. #### Limitations The "Last successful build workflow on the same branch" does not apply to PRs, even though I wish it did. Implementing this safely is more difficult than it seems. ### The future of bump-pack Part of the this PR is also effectively turning "bump-pack" into a general-purpose toolkit. In a followup PR I plan to simply turn the entire package into a full CLI to serve misc repo development purposes. My hope is that this will make it easier to actually add testing to it with a fixture based on https://github.com/kiegroup/mock-github and https://github.com/kiegroup/act-js ### Misc - Added a script for the git patching stuff, didn't like so much repetitious bash in the workflow - ~Effectively forked `nrwl/nx-set-shas` since it was not sufficient for the workflow I wanted here (It always assumed you wanted to compare against `main` in a PR)~ Nevermind, it turns out that the original action is actually good enough *By submitting this pull request, I confirm that my contribution is made under the terms of the [Wing Cloud Contribution License](https://github.com/winglang/wing/blob/main/CONTRIBUTION_LICENSE.md)*.
- Loading branch information
1 parent
27aa725
commit bfbd81d
Showing
14 changed files
with
269 additions
and
60 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
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
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,31 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Check if running in GitHub Actions | ||
if [ -z "$GITHUB_ACTIONS" ]; then | ||
echo "Not running in GitHub Actions, skipping patch creation" | ||
exit 0 | ||
fi | ||
|
||
# Get patch name from args | ||
if [ -z "$1" ]; then | ||
echo "No patch name specified, skipping patch creation" | ||
exit 1 | ||
fi | ||
|
||
PATCH_NAME=$1 | ||
START_SHA=$2 | ||
END_SHA=$3 | ||
|
||
git add --all | ||
if [ -z "$START_SHA" ]; then | ||
git diff --staged --binary --patch > $1 | ||
else | ||
git diff --staged --binary --patch $START_SHA $END_SHA > $1 | ||
fi | ||
|
||
if [ -s $1 ]; then | ||
echo "Diff found, creating a patch to apply later" | ||
cat $1 | ||
echo "diff=true" >> $GITHUB_OUTPUT | ||
echo "diff_name=$1" >> $GITHUB_OUTPUT | ||
fi |
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
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
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,10 @@ | ||
#!/usr/bin/env -S node | ||
const { execSync } = require("node:child_process"); | ||
const { resolve, relative } = require("node:path"); | ||
|
||
const which = require("npm-which")(__dirname); | ||
const tsx = relative(process.cwd(), which.sync("tsx")); | ||
const cliSource = relative(process.cwd(), resolve(__dirname, "../src/turbo-diff.ts")); | ||
execSync(`${tsx} ${cliSource} ${process.argv.slice(2).join(" ")}`, { | ||
stdio: "inherit", | ||
}); |
Oops, something went wrong.