diff mbox series

[v3,01/21] travis: fix skipping tagged releases

Message ID 75ec97b3921f3ed346e9ab119ebff2546f03fade.1547645770.git.gitgitgadget@gmail.com (mailing list archive)
State New, archived
Headers show
Series Offer to run CI/PR builds in Azure Pipelines | expand

Commit Message

Linus Arver via GitGitGadget Jan. 16, 2019, 1:36 p.m. UTC
From: Johannes Schindelin <johannes.schindelin@gmx.de>

When building a PR, TRAVIS_BRANCH refers to the *target branch*.
Therefore, if a PR targets `master`, and `master` happened to be tagged,
we skipped the build by mistake.

Fix this by using TRAVIS_PULL_REQUEST_BRANCH (i.e. the *source branch*)
when available, falling back to TRAVIS_BRANCH (i.e. for CI builds, also
known as "push builds").

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 ci/lib-travisci.sh | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Junio C Hamano Jan. 17, 2019, 8:55 p.m. UTC | #1
"Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
writes:

> From: Johannes Schindelin <johannes.schindelin@gmx.de>
>
> When building a PR, TRAVIS_BRANCH refers to the *target branch*.
> Therefore, if a PR targets `master`, and `master` happened to be tagged,
> we skipped the build by mistake.

Good spotting.

>
> Fix this by using TRAVIS_PULL_REQUEST_BRANCH (i.e. the *source branch*)
> when available, falling back to TRAVIS_BRANCH (i.e. for CI builds, also
> known as "push builds").
>
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
>  ci/lib-travisci.sh | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/ci/lib-travisci.sh b/ci/lib-travisci.sh
> index 69dff4d1ec..d9d4f1a9d7 100755
> --- a/ci/lib-travisci.sh
> +++ b/ci/lib-travisci.sh
> @@ -1,5 +1,9 @@
>  # Library of functions shared by all CI scripts
>  
> +# When building a PR, TRAVIS_BRANCH refers to the *target* branch. Not what we
> +# want here. We want the source branch instead.
> +TRAVIS_BRANCH="${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}"

To those who are familiar with Travis [*1*], I suspect that
TRAVIS_BRANCH has a specific meaning (e.g. with PR, it is target
branch), and assigning a different value that is taken from another
variable with different meanings to TravisCI would confuse them.

Perhaps introduce a new variable, like so...

	BRANCH_TO_BUILD="${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}"

and then s/TRAVIS_BRANCH/BRANCH_TO_BUILD/g on the body of the
skip_branch_tip_with_tag helper function.

Thanks.


[Footnote]

*1* I obviously am not among them; otherwise we would have caught
this while reviewing 09f5e974 ("travis-ci: skip a branch build if
equal tag is present", 2017-09-10).




>  skip_branch_tip_with_tag () {
>  	# Sometimes, a branch is pushed at the same time the tag that points
>  	# at the same commit as the tip of the branch is pushed, and building
Johannes Schindelin Jan. 18, 2019, 10:05 a.m. UTC | #2
Hi Junio,

On Thu, 17 Jan 2019, Junio C Hamano wrote:

> "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
> writes:
> 
> > Fix this by using TRAVIS_PULL_REQUEST_BRANCH (i.e. the *source branch*)
> > when available, falling back to TRAVIS_BRANCH (i.e. for CI builds, also
> > known as "push builds").
> >
> > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> > ---
> >  ci/lib-travisci.sh | 4 ++++
> >  1 file changed, 4 insertions(+)
> >
> > diff --git a/ci/lib-travisci.sh b/ci/lib-travisci.sh
> > index 69dff4d1ec..d9d4f1a9d7 100755
> > --- a/ci/lib-travisci.sh
> > +++ b/ci/lib-travisci.sh
> > @@ -1,5 +1,9 @@
> >  # Library of functions shared by all CI scripts
> >  
> > +# When building a PR, TRAVIS_BRANCH refers to the *target* branch. Not what we
> > +# want here. We want the source branch instead.
> > +TRAVIS_BRANCH="${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}"
> 
> To those who are familiar with Travis [*1*], I suspect that
> TRAVIS_BRANCH has a specific meaning (e.g. with PR, it is target
> branch), and assigning a different value that is taken from another
> variable with different meanings to TravisCI would confuse them.
> 
> Perhaps introduce a new variable, like so...
> 
> 	BRANCH_TO_BUILD="${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}"
> 
> and then s/TRAVIS_BRANCH/BRANCH_TO_BUILD/g on the body of the
> skip_branch_tip_with_tag helper function.

I already introduce such a variable later in the same patch series:
`CI_BRANCH`. It is a good idea to introduce that already here, as it
declutters that later patch a bit, I would think.

Will change,
Dscho

> 
> Thanks.
> 
> 
> [Footnote]
> 
> *1* I obviously am not among them; otherwise we would have caught
> this while reviewing 09f5e974 ("travis-ci: skip a branch build if
> equal tag is present", 2017-09-10).
> 
> 
> 
> 
> >  skip_branch_tip_with_tag () {
> >  	# Sometimes, a branch is pushed at the same time the tag that points
> >  	# at the same commit as the tip of the branch is pushed, and building
>
diff mbox series

Patch

diff --git a/ci/lib-travisci.sh b/ci/lib-travisci.sh
index 69dff4d1ec..d9d4f1a9d7 100755
--- a/ci/lib-travisci.sh
+++ b/ci/lib-travisci.sh
@@ -1,5 +1,9 @@ 
 # Library of functions shared by all CI scripts
 
+# When building a PR, TRAVIS_BRANCH refers to the *target* branch. Not what we
+# want here. We want the source branch instead.
+TRAVIS_BRANCH="${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}"
+
 skip_branch_tip_with_tag () {
 	# Sometimes, a branch is pushed at the same time the tag that points
 	# at the same commit as the tip of the branch is pushed, and building