Skip to content

Commit ecfca75

Browse files
daviesrobpd3
authored andcommitted
Add Github actions builds for Linux and Mac OS (needs htslib#2000)
As Cirrus CI is closing down, tests need to migrate elsewhere. As Windows tests already run using Github actions, using it for Linux and Mac OS builds is the easiest solution. Adds Github actions workflows for Linux (specifically ubuntu as it's the only flavour supported natively), and Mac OS. Updates actions/checkout on the Windows build to the latest release. The reference to it is also changed from a tag name to a sha hash to reduce the risk of supply-chain attack. Adds --enable-libgsl to Windows configure options. Adjusts HTS_PROG_CC_WARNINGS and HTS_PROG_CC_WERROR to remove a directory left behind by the Mac OS compiler, and to redirect compiler messages to the log file. Remove quotes around $CC invocations in HTS_PROG_CC_WARNINGS and HTS_PROG_CC_WERROR. AC_PROG_CC may add flags after the C compiler path to $CC, so it needs to be used unquoted so that field splitting can be done on the value.
1 parent 16b9462 commit ecfca75

4 files changed

Lines changed: 267 additions & 25 deletions

File tree

.github/workflows/linux-build.yml

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
name: Linux CI
2+
on: [push, pull_request]
3+
4+
jobs:
5+
build-linux:
6+
runs-on: ${{ matrix.os }}
7+
strategy:
8+
fail-fast: false
9+
matrix:
10+
# Fully declare each matrix entry here, as otherwise it's possible
11+
# to get unexpected results due to the way the entries get expanded
12+
# (See https://magmanu.github.io/blog/tech/matrices-github-actions/)
13+
include:
14+
# x86-64, clang, configure
15+
- os: ubuntu-latest
16+
use-configure: use-configure
17+
htssrc: hidden-htslib
18+
compiler: clang
19+
sanitize: no-sanitize
20+
21+
# x86-64, gcc, configure, sanitize
22+
- os: ubuntu-latest
23+
use-configure: use-configure
24+
htssrc: hidden-htslib
25+
compiler: gcc
26+
sanitize: sanitize
27+
28+
# x86-64, gcc, no configure, run extra checks
29+
- os: ubuntu-latest
30+
use-configure: no-configure
31+
htssrc: htslib
32+
compiler: gcc
33+
sanitize: no-sanitize
34+
35+
# arm, gcc, configure
36+
- os: ubuntu-24.04-arm
37+
use-configure: use-configure
38+
htssrc: hidden-htslib
39+
compiler: gcc
40+
sanitize: no-sanitize
41+
42+
defaults:
43+
run:
44+
working-directory: ./bcftools
45+
46+
steps:
47+
- name: Checkout
48+
# This is actions/checkout@v6.0.2
49+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
50+
with:
51+
persist-credentials: false
52+
path: bcftools
53+
54+
- name: Run apt
55+
working-directory: .
56+
run: |
57+
sudo apt-get update
58+
sudo apt-get install -y --no-install-suggests --no-install-recommends autoconf automake make ${{ matrix.compiler }} perl zlib1g-dev libbz2-dev liblzma-dev libcurl4-gnutls-dev libssl-dev libdeflate-dev libperl-dev libgsl0-dev libio-pty-perl
59+
60+
- name: Clone htslib
61+
working-directory: .
62+
run: |
63+
mkdir -p ${{ matrix.htssrc }}
64+
htslib_pr=`git log -2 --format='%s' | sed -n 's/.*htslib#\([0-9]*\).*/\1/p'`
65+
./bcftools/.ci_helpers/clone ${GITHUB_REPOSITORY_OWNER} htslib ${{ matrix.htssrc }} ${GITHUB_HEAD_REF:-$GITHUB_REF_NAME} $htslib_pr
66+
67+
- name: Set build options
68+
run: |
69+
cc='clang'
70+
configure_opts='--enable-werror --enable-perl-filters --enable-libgsl'
71+
cflags='-g -O3'
72+
ldflags=''
73+
74+
if [ '${{ matrix.sanitize }}' = 'sanitize' ] ; then
75+
cflags="-g -Og -fsanitize=address,undefined -Wno-format-truncation -Wno-format-overflow -DHTS_ALLOW_UNALIGNED=0"
76+
ldflags='-fsanitize=address,undefined'
77+
fi
78+
79+
echo "cc=${cc}" >> "$GITHUB_ENV"
80+
echo "configure_opts=${configure_opts}" >> "$GITHUB_ENV"
81+
echo "cflags=${cflags}" >> "$GITHUB_ENV"
82+
echo "ldflags=${ldflags}" >> "$GITHUB_ENV"
83+
84+
- name: Build htslib
85+
working-directory: ${{ matrix.htssrc }}
86+
run: |
87+
htsdir="`realpath ..`/installed-htslib"
88+
echo "htsdir=${htsdir}" >> "$GITHUB_ENV"
89+
90+
autoreconf -i
91+
{ ./configure --prefix="$htsdir" ${configure_opts} ${cc:+CC="$cc"} ${cflags:+CFLAGS="$cflags"} ${ldflags:+LDFLAGS="$ldflags"} ||
92+
{ cat config.log ; false ; } ; } &&
93+
make -j 5 &&
94+
make install
95+
96+
- name: Configure bcftools
97+
if: ${{ matrix.use-configure == 'use-configure' }}
98+
run: |
99+
autoreconf -i
100+
101+
with_htslib="--with-htslib=$htsdir"
102+
ldflags="${ldflags:+$ldflags }-Wl,-rpath=${htsdir}/lib"
103+
104+
printf "\nRunning ./configure ${with_htslib} ${configure_opts}${cc:+ CC='$cc'}${cflags:+ CFLAGS='$cflags'}${ldflags:+ LDFLAGS='$ldflags'} ...\n\n"
105+
106+
{ ./configure $with_htslib ${configure_opts} ${cc:+CC="$cc"} ${cflags:+CFLAGS="$cflags"} ${ldflags:+LDFLAGS="$ldflags"} &&
107+
{ grep -qE 'CFLAGS *=.*-Werror' config.mk ||
108+
{ printf "\nStopping as -Werror was not set.\n" 1>&2 ; false ; } ;
109+
} ;
110+
} || { printf "\n### config.log content follows...\n\n" 1>&2 ; cat config.log ; false ; }
111+
112+
- name: Compile bcftools
113+
run: |
114+
if [ '${{ matrix.use-configure }}' = 'use-configure' ] ; then
115+
make -j5
116+
else
117+
make -j5 ${cc:+CC="$cc"} ${cflags:+CFLAGS="$cflags -Werror"}
118+
fi
119+
120+
- name: Check
121+
run: |
122+
if [ '${{ matrix.use-configure }}' = 'use-configure' ] ; then
123+
make check BGZIP=$htsdir/bin/bgzip TABIX=$htsdir/bin/tabix
124+
else
125+
make check ${cc:+CC="$cc"} ${cflags:+CFLAGS="$cflags -Werror"}
126+
fi

.github/workflows/macos-build.yml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
name: Mac OS CI
2+
on: [push, pull_request]
3+
4+
jobs:
5+
build-macos:
6+
runs-on: macos-latest
7+
strategy:
8+
fail-fast: false
9+
matrix:
10+
# Fully declare each matrix entry here, as otherwise it's possible
11+
# to get unexpected results due to the way the entries get expanded
12+
# (See https://magmanu.github.io/blog/tech/matrices-github-actions/)
13+
include:
14+
# configure
15+
- use-configure: use-configure
16+
htssrc: hidden-htslib
17+
sanitize: no-sanitize
18+
19+
# make only
20+
- use-configure: no-configure
21+
htssrc: htslib
22+
sanitize: no-sanitize
23+
24+
# configure, sanitize
25+
- use-configure: use-configure
26+
htssrc: hidden-htslib
27+
sanitize: sanitize
28+
29+
defaults:
30+
run:
31+
working-directory: ./bcftools
32+
33+
steps:
34+
- name: Checkout
35+
# This is actions/checkout@v6.0.2
36+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
37+
with:
38+
persist-credentials: false
39+
path: bcftools
40+
41+
- name: Install autotools
42+
working-directory: .
43+
run: |
44+
brew install autoconf automake libtool
45+
46+
- name: Clone htslib
47+
working-directory: .
48+
run: |
49+
mkdir -p ${{ matrix.htssrc }}
50+
htslib_pr=`git log -2 --format='%s' | sed -n 's/.*htslib#\([0-9]*\).*/\1/p'`
51+
./bcftools/.ci_helpers/clone ${GITHUB_REPOSITORY_OWNER} htslib ${{ matrix.htssrc }} ${GITHUB_HEAD_REF:-$GITHUB_REF_NAME} $htslib_pr
52+
53+
- name: Set build options
54+
run: |
55+
cc='clang'
56+
configure_opts='--enable-werror'
57+
cflags='-g -O3 -arch arm64 -arch x86_64'
58+
ldflags='-arch arm64 -arch x86_64'
59+
60+
if [ '${{ matrix.sanitize }}' = 'sanitize' ] ; then
61+
cflags="-g -Og -fsanitize=address,undefined -Wno-format-truncation -Wno-format-overflow -arch arm64 -arch x86_64 -DHTS_ALLOW_UNALIGNED=0"
62+
ldflags='-fsanitize=address,undefined -arch arm64 -arch x86_64'
63+
fi
64+
65+
echo "cc=${cc}" >> "$GITHUB_ENV"
66+
echo "configure_opts=${configure_opts}" >> "$GITHUB_ENV"
67+
echo "cflags=${cflags}" >> "$GITHUB_ENV"
68+
echo "ldflags=${ldflags}" >> "$GITHUB_ENV"
69+
70+
- name: Build htslib
71+
working-directory: ${{ matrix.htssrc }}
72+
run: |
73+
htsdir="`realpath ..`/installed-htslib"
74+
echo "htsdir=${htsdir}" >> "$GITHUB_ENV"
75+
76+
autoreconf -i
77+
{ ./configure --prefix="$htsdir" ${configure_opts} ${cc:+CC="$cc"} ${cflags:+CFLAGS="$cflags"} ${ldflags:+LDFLAGS="$ldflags"} ||
78+
{ cat config.log ; false ; } ; } &&
79+
make -j 5 &&
80+
make install
81+
82+
- name: Configure bcftools
83+
if: ${{ matrix.use-configure == 'use-configure' }}
84+
run: |
85+
autoreconf -i
86+
87+
with_htslib="--with-htslib=$htsdir"
88+
ldflags="${ldflags:+$ldflags }-Wl,-rpath,${htsdir}/lib"
89+
90+
printf "\nRunning ./configure ${with_htslib} ${configure_opts}${cc:+ CC='$cc'}${cflags:+ CFLAGS='$cflags'}${ldflags:+ LDFLAGS='$ldflags'} ...\n\n"
91+
92+
{ ./configure $with_htslib ${configure_opts} ${cc:+CC="$cc"} ${cflags:+CFLAGS="$cflags"} ${ldflags:+LDFLAGS="$ldflags"} &&
93+
{ grep -qE 'CFLAGS *=.*-Werror' config.mk ||
94+
{ printf "\nStopping as -Werror was not set.\n" 1>&2 ; false ; } ;
95+
} ;
96+
} || { printf "\n### config.log content follows...\n\n" 1>&2 ; cat config.log ; false ; }
97+
98+
- name: Compile bcftools
99+
run: |
100+
if [ '${{ matrix.use-configure }}' = 'use-configure' ] ; then
101+
make -j5
102+
else
103+
make -j5 ${cc:+CC="$cc"} ${cflags:+CFLAGS="$cflags -Werror"}
104+
fi
105+
106+
- name: Check
107+
run: |
108+
if [ '${{ matrix.use-configure }}' = 'use-configure' ] ; then
109+
make check BGZIP=$htsdir/bin/bgzip TABIX=$htsdir/bin/tabix
110+
else
111+
make check ${cc:+CC="$cc"} ${cflags:+CFLAGS="$cflags -Werror"}
112+
fi

.github/workflows/windows-build.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ name: Windows/MinGW-W64 CI
22
on: [push, pull_request]
33

44
jobs:
5-
build:
5+
build-windows:
66
runs-on: windows-latest
77
steps:
88
- name: Checkout
9-
uses: actions/checkout@v4
9+
# This is actions/checkout@v6.0.2
10+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
1011
with:
1112
ref: ${{ github.event.pull_request.head.sha }}
1213
- name: Set up MSYS2 MinGW-W64
@@ -23,6 +24,7 @@ jobs:
2324
mingw-w64-x86_64-zlib
2425
mingw-w64-x86_64-bzip2
2526
mingw-w64-x86_64-xz
27+
mingw-w64-x86_64-gsl
2628
- name: Clone htslib
2729
shell: msys2 {0}
2830
run: |
@@ -41,7 +43,7 @@ jobs:
4143
export MSYSTEM=MINGW64
4244
autoheader
4345
autoconf -Wno-syntax
44-
./configure --enable-werror
46+
./configure --enable-werror --enable-libgsl
4547
make -j4
4648
- name: Check bcftools
4749
shell: msys2 {0}

m4/hts_prog_cc_warnings.m4

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -65,75 +65,76 @@ dnl an option that includes a hash sign...
6565
# Tests for flags to enable C compiler warnings
6666
# GCC compatible
6767
AS_IF([test "x$GCC" = "xyes" &&
68-
"$CC" -c -Wall conftest.c > /dev/null 2>&1 &&
68+
$CC -c -Wall conftest.c >&AS_MESSAGE_LOG_FD 2>&1 &&
6969
test -f conftest.o],[dnl
7070
AS_IF([test "x$ansi" = "x"],
7171
[hts_cv_prog_cc_warnings="-Wall"],
7272
[hts_cv_prog_cc_warnings="-Wall -ansi -pedantic"])
7373
],
7474
# Sun Studio or Solaris C compiler
75-
["$CC" -V 2>&1 | $GREP -i -E "WorkShop|Sun C" > /dev/null 2>&1 &&
76-
"$CC" -c -v -Xc conftest.c > /dev/null 2>&1 &&
75+
[$CC -V 2>&1 | $GREP -i -E "WorkShop|Sun C" >&AS_MESSAGE_LOG_FD 2>&1 &&
76+
$CC -c -v -Xc conftest.c >&AS_MESSAGE_LOG_FD 2>&1 &&
7777
test -f conftest.o],[dnl
7878
AS_IF([test "x$ansi" = "x"],
7979
[hts_cv_prog_cc_warnings="-v"],
8080
[hts_cv_prog_cc_warnings="-v -Xc"])
8181
],
8282
# Digital Unix C compiler
83-
["$CC" -V 2>&1 | $GREP -i "Digital UNIX Compiler" > /dev/null 2>&1 &&
84-
"$CC" -c -verbose -w0 -warnprotos -std1 conftest.c > /dev/null 2>&1 &&
83+
[$CC -V 2>&1 | $GREP -i "Digital UNIX Compiler" >&AS_MESSAGE_LOG_FD 2>&1 &&
84+
$CC -c -verbose -w0 -warnprotos -std1 conftest.c >&AS_MESSAGE_LOG_FD 2>&1 &&
8585
test -f conftest.o], [dnl
8686
AS_IF([test "x$ansi" = "x"],
8787
[hts_cv_prog_cc_warnings="-verbose -w0 -warnprotos"],
8888
[hts_cv_prog_cc_warnings="-verbose -w0 -warnprotos -std1"])
8989
],
9090
# C for AIX Compiler
91-
["$CC" 2>&1 | $GREP -i "C for AIX Compiler" > /dev/null 2>&1 &&
92-
"$CC" -c -qlanglvl=ansi -qinfo=all conftest.c > /dev/null 2>&1 &&
91+
[$CC 2>&1 | $GREP -i "C for AIX Compiler" >&AS_MESSAGE_LOG_FD 2>&1 &&
92+
$CC -c -qlanglvl=ansi -qinfo=all conftest.c >&AS_MESSAGE_LOG_FD 2>&1 &&
9393
test -f conftest.o],[dnl
9494
AS_IF([test "x$ansi" = "x"],
9595
[hts_cv_prog_cc_warnings="-qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd"],
9696
[hts_cv_prog_cc_warnings="-qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd -qlanglvl=ansi"])
9797
],
9898
# IRIX C compiler
99-
["$CC" -version 2>&1 | $GREP -i "MIPSpro Compilers" > /dev/null 2>&1 &&
100-
"$CC" -c -fullwarn -ansi -ansiE conftest.c > /dev/null 2>&1 &&
99+
[$CC -version 2>&1 | $GREP -i "MIPSpro Compilers" >&AS_MESSAGE_LOG_FD 2>&1 &&
100+
$CC -c -fullwarn -ansi -ansiE conftest.c >&AS_MESSAGE_LOG_FD 2>&1 &&
101101
test -f conftest.o],[dnl
102102
AS_IF([test "x$ansi" = "x"],
103103
[hts_cv_prog_cc_warnings="-fullwarn"],
104104
[hts_cv_prog_cc_warnings="-fullwarn -ansi -ansiE"])
105105
],
106106
# HP-UX C compiler
107-
[what "$CC" 2>&1 | $GREP -i "HP C Compiler" > /dev/null 2>&1 &&
108-
"$CC" -c -Aa +w1 conftest.c > /dev/null 2>&1 &&
107+
[what "$CC" 2>&1 | $GREP -i "HP C Compiler" >&AS_MESSAGE_LOG_FD 2>&1 &&
108+
$CC -c -Aa +w1 conftest.c >&AS_MESSAGE_LOG_FD 2>&1 &&
109109
test -f conftest.o],[dnl
110110
AS_IF([test "x$ansi" = "x"],
111111
[hts_cv_prog_cc_warnings="+w1"],
112112
[hts_cv_prog_cc_warnings="+w1 -Aa"])
113113
],
114114
# The NEC SX series (Super-UX 10) C compiler
115-
["$CC" -V 2>&1 | $GREP "/SX" > /dev/null 2>&1 &&
116-
"$CC" -c -pvctl[,]fullmsg -Xc conftest.c > /dev/null 2>&1 &&
115+
[$CC -V 2>&1 | $GREP "/SX" >&AS_MESSAGE_LOG_FD 2>&1 &&
116+
$CC -c -pvctl[,]fullmsg -Xc conftest.c >&AS_MESSAGE_LOG_FD 2>&1 &&
117117
test -f conftest.o],[
118118
AS_IF([test "x$ansi" = "x"],
119119
[hts_cv_prog_cc_warnings="-pvctl[,]fullmsg"],
120120
[hts_cv_prog_cc_warnings="-pvctl[,]fullmsg -Xc"])
121121
],
122122
# The Cray C compiler (Unicos)
123-
["$CC" -V 2>&1 | $GREP -i "Cray" > /dev/null 2>&1 &&
124-
"$CC" -c -h msglevel_2 conftest.c > /dev/null 2>&1 &&
123+
[$CC -V 2>&1 | $GREP -i "Cray" >&AS_MESSAGE_LOG_FD 2>&1 &&
124+
$CC -c -h msglevel_2 conftest.c >&AS_MESSAGE_LOG_FD 2>&1 &&
125125
test -f conftest.o],[dnl
126126
AS_IF([test "x$ansi" = "x"],
127127
[hts_cv_prog_cc_warnings="-h#msglevel_2"],
128128
[hts_cv_prog_cc_warnings="-h#msglevel_2,conform"])
129129
],
130130
# The Tiny C Compiler
131-
["$CC" -v 2>&1 | $GREP "tcc version" > /dev/null &&
132-
"$CC" -Wall -c conftest.c > /dev/null 2>&1 &&
131+
[$CC -v 2>&1 | $GREP "tcc version" >&AS_MESSAGE_LOG_FD &&
132+
$CC -Wall -c conftest.c >&AS_MESSAGE_LOG_FD 2>&1 &&
133133
test -f conftest.o],[dnl
134134
hts_cv_prog_cc_warnings="-Wall"
135135
])
136136
rm -f conftest.*
137+
rm -rf conftest.dSYM
137138
])
138139
])
139140
@@ -183,19 +184,20 @@ EOF
183184
# Tests for flags to make the C compiler treat warnings as errors
184185
# GCC compatible
185186
[test "x$GCC" = "xyes" &&
186-
"$CC" -c -Werror conftest.c > /dev/null 2>&1 &&
187+
$CC -c -Werror conftest.c >&AS_MESSAGE_LOG_FD 2>&1 &&
187188
test -f conftest.o],[hts_cv_prog_cc_werror="-Werror"],
188189
# Sun Studio or Solaris C compiler
189-
["$CC" -V 2>&1 | $GREP -i -E "WorkShop|Sun C" > /dev/null 2>&1 &&
190-
"$CC" -c -errwarn=%all conftest.c > /dev/null 2>&1 &&
190+
[$CC -V 2>&1 | $GREP -i -E "WorkShop|Sun C" >&AS_MESSAGE_LOG_FD 2>&1 &&
191+
$CC -c -errwarn=%all conftest.c >&AS_MESSAGE_LOG_FD 2>&1 &&
191192
test -f conftest.o],[hts_cv_prog_cc_werror="-errwarn=%all"],
192193
# The Tiny C Compiler
193-
["$CC" -v 2>&1 | $GREP "tcc version" > /dev/null &&
194-
"$CC" -Wall -c conftest.c > /dev/null 2>&1 &&
194+
[$CC -v 2>&1 | $GREP "tcc version" >&AS_MESSAGE_LOG_FD &&
195+
$CC -Wall -c conftest.c >&AS_MESSAGE_LOG_FD 2>&1 &&
195196
test -f conftest.o],[hts_cv_prog_cc_werror="-Werror"]
196197
dnl TODO: Add more compilers
197198
)
198199
rm -f conftest.*
200+
rm -rf conftest.dSYM
199201
])
200202
])
201203
AS_IF([test "x$hts_cv_prog_cc_werror" != x],[

0 commit comments

Comments
 (0)