Skip to content

Commit

Permalink
Improve cirrus-CI for shared htslib/bcftools PRs.
Browse files Browse the repository at this point in the history
  • Loading branch information
jkbonfield authored and daviesrob committed Oct 21, 2024
1 parent 4dd56e3 commit a781f5b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
18 changes: 15 additions & 3 deletions .ci_helpers/clone
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,25 @@
# omitted or if there is no branch with that name, checks out origin/HEAD
# from the samtools/htslib repository.

repository=$1
localdir=$2
branch=$3
echo CLONE: ${@+"$@"}

owner=$1
repository="https://github.com/$owner/$2"
localdir=$3
branch=$4
htslib_PR=$5

ref=''
[ -n "$branch" ] && ref=$(git ls-remote --heads "$repository" "$branch" 2>/dev/null)
[ -z "$ref" ] && repository='https://github.com/samtools/htslib.git'

set -x
git clone --recurse-submodules --shallow-submodules --depth=1 ${ref:+--branch="$branch"} "$repository" "$localdir"

# NB: "samtools" as the owner/organisation, not the repo name
if [ "x$owner" = "xsamtools" -a -z "$ref" -a "x$htslib_PR" != "x" ]
then
cd "$localdir"
git fetch origin "pull/$htslib_PR/head"
git checkout FETCH_HEAD
fi
12 changes: 10 additions & 2 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,16 @@ timeout_in: 10m
# clone with our own commands too.
clone_template: &HTSLIB_CLONE
htslib_clone_script: |
.ci_helpers/clone "https://github.com/${CIRRUS_REPO_OWNER}/htslib" "${HTSDIR}" "${CIRRUS_BRANCH}"
# Tricky, but when run as a PR Cirrus-CI obscures the branch name and
# replaces it by pull/<num>. This means we can't automatically get PRs
# to test whether the user has a similarly named branch to compiler and
# test against.
#
# Instead if we add htslib#NUM into the first line of the commit then
# we will use that PR from htslib instead. This is only needed when
# making a PR, so for development prior to the PR being made the
# CIRRUS_BRANCH will be used in preference.
.ci_helpers/clone ${CIRRUS_REPO_OWNER} htslib "${HTSDIR}" "${CIRRUS_BRANCH}" `printenv CIRRUS_CHANGE_TITLE | sed -n 's/.*htslib#\([0-9]*\).*/\1/p'`
#--------------------------------------------------
# Template: bcftools compile and test
Expand Down

0 comments on commit a781f5b

Please sign in to comment.