Skip to content

Conversation

@samestep
Copy link
Contributor

@samestep samestep commented Mar 25, 2021

Context: #53406 added a lint for trailing whitespace at the ends of lines. However, in order to pass FB-internal lints, that PR also had to normalize the trailing newlines in four of the files it touched. This PR adds an OSS lint to normalize trailing newlines.

The changes to the following files (made in 54847d0) are the only manually-written parts of this PR:

  • .github/workflows/lint.yml
  • mypy-strict.ini
  • tools/README.md
  • tools/test/test_trailing_newlines.py
  • tools/trailing_newlines.py

I would have liked to make this just a shell one-liner like the other three similar lints, but nothing I could find quite fit the bill. Specifically, all the answers I tried from the following Stack Overflow questions were far too slow (at least a minute and a half to run on this entire repository):

To avoid giving false positives during the few days after this PR is merged, we should probably only merge it after #54967.

Test plan:

Running the shell script from the "Ensure correct trailing newlines" step in the quick-checks job of .github/workflows/lint.yml should print no output and exit in a fraction of a second with a status of 0. That was not the case prior to this PR, as shown by this failing GHA workflow run on an earlier draft of this PR:

In contrast, this run (after correcting the trailing newlines in this PR) succeeded:

To unit-test tools/trailing_newlines.py itself (this is run as part of our "Test tools" GitHub Actions workflow):

python tools/test/test_trailing_newlines.py

@facebook-github-bot
Copy link
Contributor

facebook-github-bot commented Mar 25, 2021

💊 CI failures summary and remediations

As of commit ef871b6 (more details on the Dr. CI page):


None of the CI failures appear to be your fault 💚



🚧 1 ongoing upstream failure:

These were probably caused by upstream breakages that are not fixed yet.


This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions to the (internal) Dr. CI Users group.

@codecov
Copy link

codecov bot commented Mar 27, 2021

Codecov Report

Merging #54737 (41c36f2) into master (4e5af53) will decrease coverage by 0.02%.
The diff coverage is 44.44%.

❗ Current head 41c36f2 differs from pull request most recent head ef871b6. Consider uploading reports for the commit ef871b6 to get more accurate results

@@            Coverage Diff             @@
##           master   #54737      +/-   ##
==========================================
- Coverage   77.45%   77.43%   -0.03%     
==========================================
  Files        1894     1892       -2     
  Lines      186401   186399       -2     
==========================================
- Hits       144377   144329      -48     
- Misses      42024    42070      +46     

@samestep samestep marked this pull request as ready for review March 29, 2021 20:58
@samestep samestep requested a review from a team March 29, 2021 20:58
@facebook-github-bot
Copy link
Contributor

@samestep has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@samestep has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

facebook-github-bot pushed a commit that referenced this pull request Mar 30, 2021
Summary:
PRs #53652 and #54693 attempted to increase the consistency of our choice of commit (head vs merge) for CI on PRs, and have so far been unsuccessful. This PR takes a less ambitious approach to the problem by clarifying the choice in one specific way (see the following paragraph) and documenting it in `CONTRIBUTING.md`.

In addition to documentation, this PR also removes the current behavior of our GHA jobs that checkout the PR tip instead of the merge commit. At first glance, this behavior seems to increase consistency (by eliminating the special-case for `ghstack` PRs), but in reality, it actually just means that for non-`ghstack` PRs, the question "Which commit is used in CI?" has *two* answers instead of just one; see the description of #53652 for more details.

Once merged, this PR will unblock other PRs that add modify our GHA workflows in breaking ways, such as #54737.

Pull Request resolved: #54967

Test Plan: None.

Reviewed By: walterddr, seemethere

Differential Revision: D27435913

Pulled By: samestep

fbshipit-source-id: 405fb419cf015cf88107d5eb2498cfb5bcb7ce33
@facebook-github-bot
Copy link
Contributor

@samestep has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@samestep merged this pull request in 5bcbbf5.

@samestep samestep deleted the lint-trailing-newlines branch April 5, 2021 21:13
SplitInfinity pushed a commit that referenced this pull request Apr 5, 2021
**Summary**
The `clang-format` reference hashes committed in #54737 have newlines at
the end but the locally computed ones do not. This commit removes these
newlines so that the `clang-format` binary verification step doesn't
fail.

**Test Plan**
`./tools/clang_format_all.py`, ran successfully.

**Fixes**
This commit fixes ##54790.

[ghstack-poisoned]
SplitInfinity pushed a commit that referenced this pull request Apr 5, 2021
**Summary**
The `clang-format` reference hashes committed in #54737 have newlines at
the end but the locally computed ones do not. This commit removes these
newlines so that the `clang-format` binary verification step doesn't
fail.

**Test Plan**
`./tools/clang_format_all.py`, ran successfully.

**Fixes**
This commit fixes ##54790.

[ghstack-poisoned]
SplitInfinity pushed a commit that referenced this pull request Apr 5, 2021
**Summary**
The `clang-format` reference hashes committed in #54737 have newlines at
the end but the locally computed ones do not. This commit removes these
newlines so that the `clang-format` binary verification step doesn't
fail.

**Test Plan**
`./tools/clang_format_all.py`, ran successfully.

**Fixes**
This commit fixes ##54790.

ghstack-source-id: f856a00
Pull Request resolved: #55328
SplitInfinity pushed a commit that referenced this pull request Apr 6, 2021
…eference hashes"


**Summary**
The `clang-format` reference hashes committed in #54737 have newlines at
the end but the locally computed ones do not. This commit removes these
newlines so that the `clang-format` binary verification step doesn't
fail.

**Test Plan**
`./tools/clang_format_all.py`, ran successfully.

**Fixes**
This commit fixes #54790.

Differential Revision: [D27577398](https://our.internmc.facebook.com/intern/diff/D27577398)

[ghstack-poisoned]
SplitInfinity pushed a commit that referenced this pull request Apr 6, 2021
**Summary**
The `clang-format` reference hashes committed in #54737 have newlines at
the end but the locally computed ones do not. This commit removes these
newlines so that the `clang-format` binary verification step doesn't
fail.

**Test Plan**
`./tools/clang_format_all.py`, ran successfully.

**Fixes**
This commit fixes #54790.

Differential Revision: [D27577398](https://our.internmc.facebook.com/intern/diff/D27577398)

[ghstack-poisoned]
SplitInfinity pushed a commit that referenced this pull request Apr 6, 2021
Pull Request resolved: #55328


**Summary**
The `clang-format` reference hashes committed in #54737 have newlines at
the end but the locally computed ones do not. This commit removes these
newlines so that the `clang-format` binary verification step doesn't
fail.

**Test Plan**
`./tools/clang_format_all.py`, ran successfully.

**Fixes**
This commit fixes #54790.

Differential Revision: [D27577398](https://our.internmc.facebook.com/intern/diff/D27577398/)
ghstack-source-id: 125877245
facebook-github-bot pushed a commit that referenced this pull request Apr 7, 2021
Summary:
Pull Request resolved: #55328

**Summary**
The `clang-format` reference hashes committed in #54737 have newlines at
the end but the locally computed ones do not. This commit removes these
newlines so that the `clang-format` binary verification step doesn't
fail.

**Test Plan**
`./tools/clang_format_all.py`, ran successfully.

**Fixes**
This commit fixes #54790.

Test Plan: Imported from OSS

Reviewed By: nikithamalgifb

Differential Revision: D27577398

Pulled By: SplitInfinity

fbshipit-source-id: e30bee58c2eb5ea96ed0a503480dea4f67b86aca
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.

3 participants