ci: Fix COMMIT_RANGE variable value for PRs#20697
ci: Fix COMMIT_RANGE variable value for PRs#20697hebasto wants to merge 4 commits intobitcoin:masterfrom
Conversation
maflcko
left a comment
There was a problem hiding this comment.
this still "fails" because master doesn't exist when the repo was cloned with go. I think creating the master branch after git fetch will do.
ci/lint/06_script.sh
Outdated
| COMMIT_RANGE="$CIRRUS_BASE_BRANCH..HEAD" | ||
| test/lint/commit-script-check.sh $COMMIT_RANGE | ||
| else | ||
| COMMIT_RANGE="$(git fetch $CIRRUS_REPO_CLONE_URL $CIRRUS_LAST_GREEN_CHANGE && git merge-base $CIRRUS_LAST_GREEN_CHANGE HEAD)..HEAD" |
There was a problem hiding this comment.
we don't run the linters on any branch because it is too late to fixup any issues that have been merged
There was a problem hiding this comment.
Correct. But this is for forked repos and personal Cirrus accounts.
test/lint/lint-git-commit-check.sh and test/lint/lint-whitespace.sh work in all scenarios now.
There was a problem hiding this comment.
Maybe submit this as a separate pull? ;)
7f8643b to
9d17a14
Compare
9d17a14 to
144250e
Compare
ci/lint/06_script.sh
Outdated
| COMMIT_RANGE="$CIRRUS_BASE_BRANCH..HEAD" | ||
| test/lint/commit-script-check.sh $COMMIT_RANGE | ||
| else | ||
| COMMIT_RANGE="$(git fetch $CIRRUS_REPO_CLONE_URL $CIRRUS_LAST_GREEN_CHANGE && git merge-base $CIRRUS_LAST_GREEN_CHANGE HEAD)..HEAD" |
There was a problem hiding this comment.
Maybe submit this as a separate pull? ;)
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsNo conflicts as of last run. |
144250e to
83c07d1
Compare
|
Updated 144250e -> 83c07d1 (pr20697.03 -> pr20697.04):
See: #20728.
|
ci/lint/06_script.sh
Outdated
| # by a pull request this is the name of the branch targeted by the pull request. | ||
| # https://cirrus-ci.org/guide/writing-tasks/#environment-variables | ||
| COMMIT_RANGE="$CIRRUS_BRANCH..HEAD" | ||
| git fetch $CIRRUS_REPO_CLONE_URL $CIRRUS_BASE_SHA |
There was a problem hiding this comment.
Actually, it replaces the git fetch command from the removed ci/lint/05_before_script.sh
Oh, I see. The CIRRUS_BASE_SHA must already be in the commit history for pulls, right?
I'll push another change without this command.
83c07d1 to
b4cd93d
Compare
|
Updated 83c07d1 -> b4cd93d (pr20697.04 -> pr20697.05, diff):
|
ci/lint/06_script.sh
Outdated
| # by a pull request this is the name of the branch targeted by the pull request. | ||
| # https://cirrus-ci.org/guide/writing-tasks/#environment-variables | ||
| COMMIT_RANGE="$CIRRUS_BRANCH..HEAD" | ||
| COMMIT_RANGE="$(git merge-base $CIRRUS_BASE_SHA $CIRRUS_CHANGE_IN_REPO)..$GIT_HEAD" |
There was a problem hiding this comment.
Why is this changed again? Now it will include master commits, because master has already been merged in for pull requests (see .cirrus.yml)
COMMIT_RANGE="${CIRRUS_BASE_SHA}..$GIT_HEAD" was correct.
There was a problem hiding this comment.
... master has already been merged in for pull requests (see .cirrus.yml)
Right.
For described case "when a changed PR is force pushed into the base branch that has already grown, i.e., the pull is effectively based on the non-top commit of the base branch" I think COMMIT_RANGE="${CIRRUS_BASE_SHA}..$GIT_HEAD" is wrong, as $CIRRUS_BASE_SHA is not the commit on which the pull is based on.
There was a problem hiding this comment.
$CIRRUS_BASE_SHA is not the commit on which the pull is based on.
It is the commit that this pull is de-facto based on, assuming that git merge A is approximately doing the same like git rebase A.
As I mentioned previously the current version is broken and will include all commits that have been pushed to master since. See:
https://cirrus-ci.com/task/5396234322051072?command=lint#L931
There was a problem hiding this comment.
In .cirrus.yml the base branch is merged into the pull one. That's why I think that listed commits are correct COMMIT_RANGE to lint.
OTOH, we could merge the pull branch into the base one. In that case $CIRRUS_BASE_SHA will work as documented.
There was a problem hiding this comment.
That's why I think that listed commits are correct COMMIT_RANGE to lint.
It is not the way it worked on travis
There was a problem hiding this comment.
Agree.
Is it acceptable to s/git merge A/git rebase A/ ?
There was a problem hiding this comment.
I've tested COMMIT_RANGE="${CIRRUS_BASE_SHA}..$GIT_HEAD". It works for all cases.
git is smart enough to know what to do :)
But for a human the value of COMMIT_RANGE is a bit cryptic (regarding to pull commits) in cases of a pull based on the non-top commit of the base branch. So going to skip output of it.
There was a problem hiding this comment.
Is it acceptable to s/git merge A/git rebase A/ ?
In theory yes, in practise it doesn't work with subtree bumps.
b4cd93d to
3c2478c
Compare
|
ACK 3c2478c |
3c2478c to
f89d374
Compare
3c2478c ci: Print COMMIT_RANGE to the log as it was in Travis CI (Hennadii Stepanov) c123892 ci: Drop Travis-specific workaround for shellcheck (Hennadii Stepanov) 10af252 ci: Drop Travis-specific way to set COMMIT_RANGE variable (Hennadii Stepanov) 93504da ci: Fix COMMIT_RANGE variable value for PRs (Hennadii Stepanov) Pull request description: This PR: - is a #20658 and #20682 followup - set the `COMMIT_RANGE` variable correctly for PRs - cleans up Travis-specific code - prints COMMIT_RANGE value to the log for convenience as it was in Travis CI ACKs for top commit: MarcoFalke: ACK 3c2478c Tree-SHA512: beb933352b10fd5eb3e66373ddb62439e4f3a03b50fb037ee89fa92c0706cec41d05f2d307f15bb18d1e634e6464f4e123b7e2f88703c8edfd145d8d6eff0b1a
|
Updated b4cd93d -> f89d374 (pr20697.05 -> pr20697.07, diff):
|
|
This was merged two seconds before you force pushed 😅 |
slow typing :) |
3c2478c ci: Print COMMIT_RANGE to the log as it was in Travis CI (Hennadii Stepanov) c123892 ci: Drop Travis-specific workaround for shellcheck (Hennadii Stepanov) 10af252 ci: Drop Travis-specific way to set COMMIT_RANGE variable (Hennadii Stepanov) 93504da ci: Fix COMMIT_RANGE variable value for PRs (Hennadii Stepanov) Pull request description: This PR: - is a bitcoin#20658 and bitcoin#20682 followup - set the `COMMIT_RANGE` variable correctly for PRs - cleans up Travis-specific code - prints COMMIT_RANGE value to the log for convenience as it was in Travis CI ACKs for top commit: MarcoFalke: ACK 3c2478c Tree-SHA512: beb933352b10fd5eb3e66373ddb62439e4f3a03b50fb037ee89fa92c0706cec41d05f2d307f15bb18d1e634e6464f4e123b7e2f88703c8edfd145d8d6eff0b1a
This PR:
COMMIT_RANGEvariable correctly for PRs