Skip to content

Conversation

maflcko
Copy link
Member

@maflcko maflcko commented Mar 15, 2024

COMMIT_RANGE has problems on forks or local branches:

  • When LOCAL_BRANCH is set, it assumes the presence of a master branch, and that the master branch is up-to-date. Both of which may be false. (See also discussion in Fix issues with CI on forks #29274 (comment))
  • When COMMIT_RANGE isn't set in lint-git-commit-check.py, and --prev-commits isn't set either, it has the same (broken) assumptions.

Fix all issues by simply assuming a merge commit exists. This allows to drop LOCAL_BRANCH. It also allows to drop SKIP_EMPTY_NOT_A_PR, because scripts will already skip an empty range. Finally, it allows to drop --prev-commits n, because one can simply say COMMIT_RANGE='HEAD~n..HEAD' to achieve the same.

@DrahtBot
Copy link
Contributor

DrahtBot commented Mar 15, 2024

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage

For detailed information about the code coverage, see the test coverage report.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK Sjors

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

@DrahtBot
Copy link
Contributor

🚧 At least one of the CI tasks failed. Make sure to run all tests locally, according to the
documentation.

Possibly this is due to a silent merge conflict (the changes in this pull request being
incompatible with the current code in the target branch). If so, make sure to rebase on the latest
commit of the target branch.

Leave a comment here, if you need help tracking down a confusing failure.

Debug: https://github.com/bitcoin/bitcoin/runs/22707944823

@fanquake fanquake requested a review from Sjors March 19, 2024 17:15
@Sjors
Copy link
Member

Sjors commented Mar 19, 2024

Where is lint-git-commit-check.py called from?

@maflcko
Copy link
Member Author

maflcko commented Mar 19, 2024

The lint-*.py scripts were always called by iterating over all python files in the folder and executing any that match the lint-*.py pattern. They are called by the lint test_runner.

Copy link
Member

@Sjors Sjors left a comment

Choose a reason for hiding this comment

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

I tested this on top of #29274 in Sjors#30. My fork has an out of date master branch, and the pull request isn't against the master branch. So that seems like a good test case.

IIUC this PR only impacts the Cirrus linter job, which is not running self-hosted on forks, with or without #29274 (not sure why that is, but it's not a big deal).

I pushed once with a single commit and then again with a second commit. The linter passed:

The CI log shows the right commit(s) for git log --no-merges --oneline HEAD~..HEAD.

I don't think I've ever used LOCAL_BRANCH. I tested locally on macOS 14.4 building the rust lint test_runner and calling it with COMMIT_RANGE="HEAD~..HEAD" which seems to work.

@maflcko maflcko force-pushed the 2403-lint-commit-range- branch from fa61600 to fa1146d Compare March 21, 2024 19:16
@Sjors
Copy link
Member

Sjors commented Mar 22, 2024

tACK fa1146d

Demonstration that the git-commit-check linter still works: https://cirrus-ci.com/task/6732599670865920?logs=lint#L746

It also allows to drop SKIP_EMPTY_NOT_A_PR, because scripts will already skip an empty range.

When called from 06_script.sh then COMMIT_RANGE is never empty I think? I didn't test how this behaves with (not PR) branch pushes.

@maflcko
Copy link
Member Author

maflcko commented Mar 22, 2024

When called from 06_script.sh then COMMIT_RANGE is never empty I think? I didn't test how this behaves with (not PR) branch pushes.

It may be empty on non-pull requests, when the top commit on the branch is a merge commit. This is preserving the behavior of SKIP_EMPTY_NOT_A_PR.

@maflcko maflcko requested a review from fanquake March 25, 2024 12:27
@fanquake fanquake merged commit 2e1c84b into bitcoin:master Mar 25, 2024
@maflcko maflcko deleted the 2403-lint-commit-range- branch March 25, 2024 14:46
@bitcoin bitcoin locked and limited conversation to collaborators Mar 25, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants