Skip to content
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

Fix handling of shallow clones when checking for change files #780

Merged
merged 1 commit into from
Sep 22, 2022

Conversation

ecraig12345
Copy link
Member

@ecraig12345 ecraig12345 commented Sep 21, 2022

By default, github actions/checkout only fetches the current merge ref of the PR (no history and no other branches). This causes problems for beachball check, because it doesn't have all the history that it needs to compare against.

These problems have existed for quite some time, in any repo using actions/checkout > v1 without fetch-depth: 0. And the workspace-tools git changed files helpers were hiding the issue by returning empty arrays if git commands failed.

Fix is to add explicit checks on the beachball side for various conditions related to missing history. If history is missing and fetching is enabled, it will fetch the extra history. If fetching is disabled, it will print informative error messages.

(You can see that it works because this PR's initial build includes the log about unshallowing, and ultimately failed due to a missing change file!)

// Fetch more history (if needed, this could be optimized later to only deepen by e.g. 100 commits at a time)
try {
console.log('This is a shallow clone. Unshallowing to check for changes...');
git(['fetch', '--unshallow'], { cwd, throwOnError: true });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you confirm this "throwOnError" flag? I can't find doc for it: https://nodejs.org/api/child_process.html#child_processspawnsynccommand-args-options

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah it's added in microsoft/workspace-tools#193 which isn't actually merged yet (I was testing this branch against a tgz of those changes at first)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got rid of the part that required the workspace-tools update

@kenotron kenotron merged commit f1a2f86 into master Sep 22, 2022
@kenotron kenotron deleted the ecraig/checkchange branch September 22, 2022 15:23
@rajsite rajsite mentioned this pull request Mar 5, 2024
1 task
rajsite added a commit to ni/nimble that referenced this pull request Mar 6, 2024
# Pull Request

## 🤨 Rationale

- Updated `fetch-depth: 0` comment from being [needed by
beachball](microsoft/beachball#780) to being
[needed by
chromatic](https://github.com/ni/nimble/actions/runs/8164295790/job/22319288123#step:14:50).
- Updated renovate to make a single PR for npm updates that we can let
update to latest.
  - Angular and it's related packages are ignored
    - `^@angular`, `ng-packagr`, `zone.js`, `typescript`
  - Pinned packages are ignored
- `@microsoft/fast-foundation` and `@microsoft/fast-react-wrapper` due
to [fast issue](microsoft/fast#6906)
- `comlink` as it is partially vendored into workers and needs a
controlled and pinned update
- `remark-gfm` as [updating breaks
mdx](storybookjs/storybook#24743 (comment))
- Removed npm version specific install that was now downgrading the npm
version accidentally.
- Removed file permission workaround [no longer needed to prevent
warnings](actions/upload-pages-artifact#45).
- Updated the beachball patch-package

## 👩‍💻 Implementation

See above.

## 🧪 Testing

Relying on CI.

## ✅ Checklist

- [x] I have updated the project documentation to reflect my changes or
determined no changes are needed.
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.

None yet

2 participants