这是indexloc提供的服务,不要输入任何密码
Skip to content

fix(affected): handle Github Actions provided commit not part of checkout #9214

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

Conversation

chris-olszewski
Copy link
Member

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 git@github.com: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 ce11d86705632160dd234ec4cf04bb1bd4ddeebc                                           
ce11d86705632160dd234ec4cf04bb1bd4ddeebc
[0 olszewski@chriss-mbp] /tmp/turborepo $ git log
commit 18807def30191221415f027d446079fff3e9f722 (grafted, HEAD -> main, origin/main, origin/HEAD)
Author: Anthony Shew <anthony.shew@vercel.com>
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 ce11d86705632160dd234ec4cf04bb1bd4ddeebc
fatal: reference is not a tree: ce11d86705632160dd234ec4cf04bb1bd4ddeeb

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: ce11d86705632160dd234ec4cf04bb1bd4ddeebc
  × Unable to query SCM: git error: fatal: bad object ce11d86705632160dd234ec4cf04bb1bd4ddeebc
  │ 
  ╰─▶ git error: fatal: bad object ce11d86705632160dd234ec4cf04bb1bd4ddeebc

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: ce11d86705632160dd234ec4cf04bb1bd4ddeebc
 WARNING  unable to detect git range, assuming all files have changed: git error: fatal: bad object ce11d86705632160dd234ec4cf04bb1bd4ddeebc

37 packages (pnpm)

  @turbo-internal/top-issues-gh-action packages/top-issues
  @turbo/benchmark packages/turbo-benchmark
...

Copy link

vercel bot commented Oct 3, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
examples-nonmonorepo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 3, 2024 2:05pm
8 Skipped Deployments
Name Status Preview Comments Updated (UTC)
examples-basic-web ⬜️ Ignored (Inspect) Visit Preview Oct 3, 2024 2:05pm
examples-designsystem-docs ⬜️ Ignored (Inspect) Visit Preview Oct 3, 2024 2:05pm
examples-gatsby-web ⬜️ Ignored (Inspect) Visit Preview Oct 3, 2024 2:05pm
examples-kitchensink-blog ⬜️ Ignored (Inspect) Visit Preview Oct 3, 2024 2:05pm
examples-native-web ⬜️ Ignored (Inspect) Visit Preview Oct 3, 2024 2:05pm
examples-svelte-web ⬜️ Ignored (Inspect) Visit Preview Oct 3, 2024 2:05pm
examples-tailwind-web ⬜️ Ignored (Inspect) Visit Preview Oct 3, 2024 2:05pm
examples-vite-web ⬜️ Ignored (Inspect) Visit Preview Oct 3, 2024 2:05pm

@chris-olszewski chris-olszewski marked this pull request as ready for review October 3, 2024 13:35
@chris-olszewski chris-olszewski requested a review from a team as a code owner October 3, 2024 13:35
@chris-olszewski chris-olszewski merged commit 7f13523 into main Oct 3, 2024
40 checks passed
@chris-olszewski chris-olszewski deleted the chrisolszewski/turbo-4058-investigate-reliability-of-rev-parse-for-commit-data branch October 3, 2024 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

turbo xxx yyy --affected seems broken after updating to v2.1.3
2 participants