-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
add method for determining base commit on GitHub actions #9169
Merged
Conversation
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
The latest updates on your projects. Learn more about Vercel for Git ↗︎
8 Skipped Deployments
|
dimitropoulos
force-pushed
the
dimitri/affected-github
branch
from
September 19, 2024 16:25
d487f92
to
8dcf500
Compare
dimitropoulos
force-pushed
the
dimitri/affected-github
branch
from
September 24, 2024 02:15
8dcf500
to
464a82d
Compare
NicholasLYang
requested changes
Sep 24, 2024
Co-authored-by: Chris Olszewski <[email protected]>
Co-authored-by: Nicholas Yang <[email protected]>
two tests still failing
tknickman
reviewed
Sep 25, 2024
chris-olszewski
approved these changes
Sep 25, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aside from adding logging when the github base ref doesn't resolve, LGTM.
tknickman
approved these changes
Sep 26, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thanks!
NicholasLYang
approved these changes
Sep 26, 2024
chris-olszewski
added a commit
that referenced
this pull request
Oct 3, 2024
…kout (#9214) ### Description Fixes #9208 With #9169 we started using `GITHUB_BASE_REF` to determine the base of our `--affected` comparison. This can return a commit that doesn't exist in the current checkout, but will pass `rev-parse` since the reference exists. This PR avoids crashing by treating `bad object` git errors the same as `no merge base` so if we get passed a commit that is valid, but non-existent in the checkout we still run. ### Testing Instructions I only have a manual test as creating a repository where a commit exists according to `rev-parse`, but not as part of the checkout is beyond my git-fu levels. Create a shallow checkout: `git clone [email protected]:vercel/turborepo.git --depth=1` Find a commit that exists in the repo, but does not exist in the checkout e.g. `ce11d86705632160dd234ec4cf04bb1bd4ddeebc` ``` [0 olszewski@chriss-mbp] /tmp/turborepo $ git rev-parse ce11d86 ce11d86 [0 olszewski@chriss-mbp] /tmp/turborepo $ git log commit 18807de (grafted, HEAD -> main, origin/main, origin/HEAD) Author: Anthony Shew <[email protected]> Date: Wed Oct 2 23:06:06 2024 -0600 (docs) Fix spacing on link. (#9213) ### Description <!-- ✍️✍ Write a short summary of your work. If necessary, include relevant screenshots. --> ### Testing Instructions <!-- Give a quick description of steps to test your changes. --> [0 olszewski@chriss-mbp] /tmp/turborepo $ git checkout ce11d86 fatal: reference is not a tree: ce11d86 ``` Verify that `turbo ls --affected` crashes with "bad object" message: ``` GITHUB_ACTIONS=1 GITHUB_BASE_REF=ce11d86705632160dd234ec4cf04bb1bd4ddeebc turbo ls --affected WARNING No locally installed `turbo` found. Using version: 2.1.4-canary.0. turbo 2.1.4-canary.0 WARNING ls command is experimental and may change in the future Resolved base ref from GitHub Actions event: ce11d86 × Unable to query SCM: git error: fatal: bad object ce11d86 │ ╰─▶ git error: fatal: bad object ce11d86 ``` Test PR and verify that since we can't diff the commit we assume everything has changed: ``` GITHUB_ACTIONS=1 GITHUB_BASE_REF=ce11d86705632160dd234ec4cf04bb1bd4ddeebc turbo_dev ls --affected WARNING No locally installed `turbo` found. Using version: 2.1.4-canary.0. turbo 2.1.4-canary.0 WARNING ls command is experimental and may change in the future Resolved base ref from GitHub Actions event: ce11d86 WARNING unable to detect git range, assuming all files have changed: git error: fatal: bad object ce11d86 37 packages (pnpm) @turbo-internal/top-issues-gh-action packages/top-issues @turbo/benchmark packages/turbo-benchmark ... ```
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
If you're running
--affected
and you're running in the context of a GitHub action there are some additional env vars that are available that give more context (pull request action, push action, each have their own thing). In a push even it's a previous commit, and in the pull request event it's the base of the pull request. We want to use those to be the base of --affected instead of just defaulting to main or whatever we have. You can still override it as normal.This is a problem right now for running in GitHub actions right now because it clones to a limited depth (shallow clone). We might therefore need to check that the commit in question actually exists.
Testing Instructions
see tests (there are quite a few) - ultimately the only way to "really" test this is to see it run in GitHub runners.