Skip to content

Abstract away git repo during tests#82594

Closed
ZainRizvi wants to merge 4 commits intomasterfrom
zainr/fix-tests
Closed

Abstract away git repo during tests#82594
ZainRizvi wants to merge 4 commits intomasterfrom
zainr/fix-tests

Conversation

@ZainRizvi
Copy link
Contributor

@ZainRizvi ZainRizvi commented Aug 1, 2022

Description

During unit tests we want to return fake data for any methods that rely on a local git repository. Otherwise those tests will fail when run in an environment that doesn't have the pytorch repo checked out (such as fbinternal or a tarball download)

Also refactored existing tests to use the new DummyGitRepo

Issue

N/A

Testing

Validating old behavior:
Removed the .git folder locally to effectively delete the git repository. Then ran python3 .github/scripts/test_trymerge.py to ensure the test failed

Validating fix:
Ran python3 .github/scripts/test_trymerge.py both with and without the .git folder

@pytorch-bot
Copy link

pytorch-bot bot commented Aug 1, 2022

🔗 Helpful Links

🧪 See artifacts and rendered test results here

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures, 3 Pending

As of commit 295387a:
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@ZainRizvi ZainRizvi marked this pull request as ready for review August 1, 2022 19:36
@ZainRizvi ZainRizvi requested a review from a team as a code owner August 1, 2022 19:36
@ZainRizvi ZainRizvi requested a review from malfet August 1, 2022 19:36
Copy link
Contributor

@zengk95 zengk95 left a comment

Choose a reason for hiding this comment

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

lgtm pending lint

Copy link
Contributor

@huydhn huydhn left a comment

Choose a reason for hiding this comment

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

LGTM! Just FYI that the OLD test before this PR could also fail when you do a shallow checkout, i.e. git clone --depth 1, which is used commonly in CI. It's still a git repo, but it wouldn't have the commit you are looking for :P

Copy link
Contributor

@malfet malfet left a comment

Choose a reason for hiding this comment

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

Please fix lint, otherwise LGTM
Consider nit

ZainRizvi and others added 2 commits August 1, 2022 16:26
Co-authored-by: Nikita Shulga <nshulga@fb.com>
@ZainRizvi
Copy link
Contributor Author

@pytorchmergebot merge

@pytorchmergebot
Copy link
Collaborator

@pytorchbot successfully started a merge and created land time checks. See merge status here and land check progress here

@pytorchmergebot
Copy link
Collaborator

Merge failed due to Refusing to merge as mandatory check(s) Lint failed for rule OSS CI
Raised by https://github.com/pytorch/pytorch/actions/runs/2778033540

@ZainRizvi
Copy link
Contributor Author

@pytorchmergebot merge

@pytorchmergebot
Copy link
Collaborator

@pytorchbot successfully started a merge and created land time checks. See merge status here and land check progress here

pytorchmergebot pushed a commit that referenced this pull request Aug 1, 2022
### Description
During unit tests we want to return fake data for any methods that rely on a local git repository. Otherwise those tests will fail when run in an environment that doesn't have the pytorch repo checked out (such as fbinternal or a tarball download)

Also refactored existing tests to use the new DummyGitRepo

### Issue
N/A

### Testing
Validating old behavior:
Removed the `.git` folder locally to effectively delete the git repository. Then ran `python3 .github/scripts/test_trymerge.py` to ensure the test failed

Validating fix:
Ran `python3 .github/scripts/test_trymerge.py` both with and without the `.git` folder
Pull Request resolved: #82594
Approved by: https://github.com/zengk95, https://github.com/huydhn, https://github.com/malfet
@pytorchmergebot
Copy link
Collaborator

Merge failed due to Failed to merge; some land checks failed: pull, pull / linux-docs / build-docs (cpp)
Raised by https://github.com/pytorch/pytorch/actions/runs/2778162819

@kit1980
Copy link
Contributor

kit1980 commented Aug 2, 2022

@pytorchmergebot merge

@pytorchmergebot
Copy link
Collaborator

@pytorchbot successfully started a merge and created land time checks. See merge status here and land check progress here

pytorchmergebot pushed a commit that referenced this pull request Aug 2, 2022
### Description
During unit tests we want to return fake data for any methods that rely on a local git repository. Otherwise those tests will fail when run in an environment that doesn't have the pytorch repo checked out (such as fbinternal or a tarball download)

Also refactored existing tests to use the new DummyGitRepo

### Issue
N/A

### Testing
Validating old behavior:
Removed the `.git` folder locally to effectively delete the git repository. Then ran `python3 .github/scripts/test_trymerge.py` to ensure the test failed

Validating fix:
Ran `python3 .github/scripts/test_trymerge.py` both with and without the `.git` folder
Pull Request resolved: #82594
Approved by: https://github.com/zengk95, https://github.com/huydhn, https://github.com/malfet
@github-actions
Copy link
Contributor

github-actions bot commented Aug 2, 2022

Hey @ZainRizvi.
You've committed this PR, but it does not have both a 'release notes: ...' and 'topics: ...' label. Please add one of each to the PR. The 'release notes: ...' label should represent the part of PyTorch that this PR changes (fx, autograd, distributed, etc) and the 'topics: ...' label should represent the kind of PR it is (not user facing, new feature, bug fix, perf improvement, etc). The list of valid labels can be found here for the 'release notes: ...' and here for the 'topics: ...'.
For changes that are 'topic: not user facing' there is no need for a release notes label.

facebook-github-bot pushed a commit that referenced this pull request Aug 3, 2022
Summary:
### Description
During unit tests we want to return fake data for any methods that rely on a local git repository. Otherwise those tests will fail when run in an environment that doesn't have the pytorch repo checked out (such as fbinternal or a tarball download)

Also refactored existing tests to use the new DummyGitRepo

### Issue
N/A

### Testing
Validating old behavior:
Removed the `.git` folder locally to effectively delete the git repository. Then ran `python3 .github/scripts/test_trymerge.py` to ensure the test failed

Validating fix:
Ran `python3 .github/scripts/test_trymerge.py` both with and without the `.git` folder

Pull Request resolved: #82594
Approved by: https://github.com/zengk95, https://github.com/huydhn, https://github.com/malfet

Test Plan: contbuild & OSS CI, see https://hud.pytorch.org/commit/pytorch/pytorch/87a11f112b1d7a172fb98004421dc98a35d25415

Reviewed By: kit1980

Differential Revision: D38359475

Pulled By: ZainRizvi

fbshipit-source-id: 21c58d074468162e0de5d5701250d098e89f1f91
@ZainRizvi ZainRizvi deleted the zainr/fix-tests branch September 30, 2022 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants