From 4c6e8aa6e29109f6a4a2b7300bf273ad760eb2a4 Mon Sep 17 00:00:00 2001 From: Chris Evich Date: Thu, 18 Jul 2019 16:23:30 -0400 Subject: Cirrus: Fix post-merge env. var. not set. Cirrus-CI automatically sets `$CIRRUS_BASE_BRANCH` during PR testing. This is used for the `build_each_commit` task, in order to compute the commit-chain properly. However, prior to this commit and after a PR merges, the post-merge `build_each_commit` task would fail with something similar to: ``` make build-all-new-commits GIT_BASE_BRANCH=origin/$CIRRUS_BASE_BRANCH |& ${TIMESTAMP} [12:28:59] START - All [+xxxx] lines that follow are relative to right now. [+0000s] # Validate that all the commits build on top of origin/ [+0000s] git rebase origin/ -x make [+0000s] fatal: invalid upstream 'origin/' [+0000s] make: *** [Makefile:426: build-all-new-commits] Error 128 [12:28:59] END - [+0000s] total duration since START Exit status: 2 ``` This is because `$CIRRUS_BASE_BRANCH` is undefined when CI runs against a branch (by design). This commit fixes the problem by referring to `$DEST_BRANCH` instead. This variable must always point at the intended destination branch for testing, and so can be used in this context as well. Also updated a few comments to help steer understanding of the `$DEST_BRANCH` purpose. Signed-off-by: Chris Evich --- .cirrus.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to '.cirrus.yml') diff --git a/.cirrus.yml b/.cirrus.yml index 70c3cb3da..578a3eef0 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -13,7 +13,7 @@ env: #### #### Global variables used for all tasks #### - # Name of the ultimate destination branch for this build + # Name of the ultimate destination branch for this CI run, PR or post-merge. DEST_BRANCH: "master" # Overrides default location (/tmp/cirrus) for repo clone GOPATH: "/var/tmp/go" @@ -194,7 +194,6 @@ build_each_commit_task: - "vendor" - "varlink_api" - # $CIRRUS_BASE_BRANCH is only set when testing a PR only_if: $CIRRUS_BRANCH != $DEST_BRANCH && $CIRRUS_CHANGE_MESSAGE !=~ '.*\*\*\*\s*CIRRUS:\s*TEST\s*IMAGES\s*\*\*\*.*' @@ -210,9 +209,10 @@ build_each_commit_task: setup_environment_script: '$SCRIPT_BASE/setup_environment.sh |& ${TIMESTAMP}' build_each_commit_script: - - 'source $SCRIPT_BASE/lib.sh' - - 'git fetch --depth $CIRRUS_CLONE_DEPTH origin $CIRRUS_BASE_BRANCH |& ${TIMESTAMP}' - - 'make build-all-new-commits GIT_BASE_BRANCH=origin/$CIRRUS_BASE_BRANCH |& ${TIMESTAMP}' + # set -x by default, no need to spew contents of lib.sh + - 'source $SCRIPT_BASE/lib.sh &> /dev/null' + - 'git fetch --depth $CIRRUS_CLONE_DEPTH origin $DEST_BRANCH |& ${TIMESTAMP}' + - 'make build-all-new-commits GIT_BASE_BRANCH=origin/$DEST_BRANCH |& ${TIMESTAMP}' on_failure: failed_branch_script: '$CIRRUS_WORKING_DIR/$SCRIPT_BASE/notice_branch_failure.sh' @@ -225,7 +225,6 @@ build_without_cgo_task: - "vendor" - "varlink_api" - # $CIRRUS_BASE_BRANCH is only set when testing a PR only_if: $CIRRUS_BRANCH != $DEST_BRANCH && $CIRRUS_CHANGE_MESSAGE !=~ '.*\*\*\*\s*CIRRUS:\s*TEST\s*IMAGES\s*\*\*\*.*' -- cgit v1.2.3-54-g00ecf