Skip to content

Commit acf7d3e

Browse files
committed
fix build
1 parent 98bdf48 commit acf7d3e

File tree

2 files changed

+142
-107
lines changed

2 files changed

+142
-107
lines changed

.github/workflows/build.yml

Lines changed: 141 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# copied from Daniel Cook's Seq collection
22
name: Build
33

4-
on:
4+
on:
55
push:
66
branches:
77
- master
@@ -13,116 +13,151 @@ on:
1313

1414
jobs:
1515
build:
16-
1716
runs-on: ${{ matrix.os }}
1817
strategy:
1918
fail-fast: false
2019
matrix:
21-
os: [ubuntu-20.04, macos-14]
20+
os: [ubuntu-22.04, macos-14]
2221
version:
23-
- 1.6.18
24-
- 2.0.2
25-
22+
- 1.6.18
23+
- 2.0.2
2624

2725
steps:
28-
- uses: actions/checkout@v4
29-
30-
# Caching
31-
- name: Cache choosenim
32-
id: cache-choosenim
33-
uses: actions/cache@v4
34-
with:
35-
path: ~/.choosenim
36-
key: ${{ runner.os }}-choosenim-stable
37-
38-
- name: Cache nimble
39-
id: cache-nimble
40-
uses: actions/cache@v4
41-
with:
42-
path: ~/.nimble
43-
key: ${{ runner.os }}-nimble-stable
44-
45-
- name: Cache htslib
46-
id: cache-htslib
47-
uses: actions/cache@v4
48-
with:
49-
path: $HOME/htslib
50-
key: ${{ runner.os }}-htslib-1.10
51-
52-
# Install Dependencies
53-
- name: Install dependencies (Linux)
54-
if: runner.os == 'Linux'
55-
run: |
56-
sudo apt-get update
57-
sudo apt-get -qy install bwa make build-essential cmake libncurses-dev ncurses-dev libbz2-dev lzma-dev liblzma-dev \
58-
curl libssl-dev libtool autoconf automake libcurl4-openssl-dev zlib1g-dev
59-
60-
# Setup htslib
61-
- name: Install htslib (linux)
62-
if: runner.os == 'Linux'
63-
run: |
64-
cd
65-
git clone -b 1.22.1 --recursive https://github.com/samtools/htslib.git
66-
cd htslib && autoheader && autoconf && ./configure --enable-libcurl
67-
sudo make -j 4 install
68-
sudo ldconfig
69-
#echo "::set-env name=LD_LIBRARY_PATH::${LD_LIBRARY_PATH}:${HOME}/htslib"
70-
#ls -lh $HOME/htslib/*.so
71-
72-
- name: Install hstlib (macos)
73-
if: runner.os == 'macOS'
74-
run: |
75-
brew install htslib
76-
77-
- name: Set DYLD_LIBRARY_PATH
78-
if: runner.os == 'macOS'
79-
run: |
26+
- uses: actions/checkout@v4
27+
with:
28+
submodules: true
29+
fetch-depth: 0
30+
31+
# Caching
32+
- name: Cache choosenim
33+
id: cache-choosenim
34+
uses: actions/cache@v4
35+
with:
36+
path: ~/.choosenim
37+
key: ${{ runner.os }}-choosenim-stable
38+
39+
- name: Cache nimble
40+
id: cache-nimble
41+
uses: actions/cache@v4
42+
with:
43+
path: ~/.nimble
44+
key: ${{ runner.os }}-nimble-stable
45+
46+
- name: Cache htslib
47+
id: cache-htslib
48+
uses: actions/cache@v4
49+
with:
50+
path: $HOME/htslib
51+
key: ${{ runner.os }}-htslib-1.10
52+
53+
# Install Dependencies
54+
- name: Install dependencies (Linux)
55+
if: runner.os == 'Linux'
56+
run: |
57+
sudo apt-get update
58+
sudo apt-get -qy install bwa make build-essential cmake libncurses-dev ncurses-dev libbz2-dev lzma-dev liblzma-dev \
59+
curl libssl-dev libtool autoconf automake libcurl4-openssl-dev zlib1g-dev
60+
61+
# Setup htslib
62+
- name: Install htslib (linux)
63+
if: runner.os == 'Linux'
64+
run: |
65+
cd
66+
git clone -b 1.22.1 --recursive https://github.com/samtools/htslib.git
67+
cd htslib && autoheader && autoconf && autoreconf -i && ./configure --enable-libcurl
68+
sudo make -j 4 install
69+
sudo ldconfig
70+
#echo "::set-env name=LD_LIBRARY_PATH::${LD_LIBRARY_PATH}:${HOME}/htslib"
71+
#ls -lh $HOME/htslib/*.so
72+
73+
- name: Install hstlib (macos)
74+
if: runner.os == 'macOS'
75+
run: |
76+
brew install htslib
77+
78+
- name: Set DYLD_LIBRARY_PATH
79+
if: runner.os == 'macOS'
80+
run: |
8081
echo "DYLD_LIBRARY_PATH=$(brew --prefix htslib)/lib" >> $GITHUB_ENV
81-
82-
- name: Install d4
83-
run: |
84-
#export HTSLIB=system
85-
git clone https://github.com/38/d4-format
86-
echo 'location' >> ~/.curlrc # https://github.com/38/d4-format/pull/77#issuecomment-2044438359
87-
cd d4-format
88-
cargo build --release --all-features --package=d4binding
89-
sudo cp target/release/libd4binding.* /usr/local/lib
90-
sudo cp d4binding/include/d4.h /usr/local/include/
91-
sudo ldconfig || true
92-
93-
94-
- uses: iffy/install-nim@v5
95-
with:
96-
version: ${{ matrix.version }}
97-
98-
- name: Rust Toolchain
99-
uses: dtolnay/rust-toolchain@nightly
100-
with:
101-
toolchain: stable
102-
103-
# Build and Test
104-
- name: Build test executable
105-
run: nimble build -Y mosdepth.nimble
106-
107-
- name: "Copy binary"
108-
run: chmod +x mosdepth && mkdir bin && cp mosdepth bin/mosdepth_debug_${{ matrix.os }}
109-
110-
- name: "Build and Copy release binary"
111-
run: nim c --mm:refc -d:danger -d:release -o:bin/mosdepth_${{ matrix.os }} mosdepth
112-
113-
- name: Functional Tests
114-
env:
115-
TERM: "xterm"
116-
run: |
117-
bash ./functional-tests.sh
118-
119-
- name: Unit Tests
120-
run: |
121-
nim c -r tests/all.nim
122-
123-
- name: Upload Artifact
124-
if: success()
125-
uses: actions/upload-artifact@v4
126-
with:
127-
name: mosdepth_${{ matrix.os }}_nim${{ matrix.version }}_executable
128-
path: bin/
82+
echo "DYLD_INCLUDE_PATH=$(brew --prefix htslib)/include" >> $GITHUB_ENV
83+
echo "LIBRARY_PATH=$(brew --prefix htslib)/lib" >> $GITHUB_ENV
84+
echo "CPATH=$(brew --prefix htslib)/include" >> $GITHUB_ENV
85+
86+
- name: Set DYLD_LIBRARY_PATH (Linux)
87+
if: runner.os == 'Linux'
88+
run: |
89+
echo "DYLD_LIBRARY_PATH=/usr/local/lib" >> $GITHUB_ENV
90+
echo "DYLD_INCLUDE_PATH=/usr/local/include" >> $GITHUB_ENV
91+
92+
- name: Make libhts discoverable for tests
93+
run: |
94+
# Detect htslib location via Homebrew or fallback to $HOME/htslib
95+
HTS_LIB_DIR=""
96+
if command -v brew >/dev/null 2>&1; then
97+
BREW_PREFIX="$(brew --prefix htslib 2>/dev/null || true)"
98+
if [ -n "$BREW_PREFIX" ] && [ -d "$BREW_PREFIX/lib" ]; then
99+
HTS_LIB_DIR="$BREW_PREFIX/lib"
100+
fi
101+
fi
102+
if [ -z "$HTS_LIB_DIR" ] && [ -d "$HOME/htslib" ]; then
103+
HTS_LIB_DIR="$HOME/htslib"
104+
fi
105+
if [ -z "$HTS_LIB_DIR" ]; then
106+
echo "ERROR: libhts not found via Homebrew or at \$HOME/htslib" >&2
107+
exit 1
108+
fi
109+
echo "Using htslib dir: $HTS_LIB_DIR"
110+
if [ "${RUNNER_OS:-}" = "macOS" ]; then
111+
#echo "DYLD_LIBRARY_PATH=$HTS_LIB_DIR:${DYLD_LIBRARY_PATH:-}" >> "$GITHUB_ENV"
112+
echo "DYLD_LIBRARY_PATH=$HTS_LIB_DIR" >> "$GITHUB_ENV"
113+
else
114+
#echo "LD_LIBRARY_PATH=$HTS_LIB_DIR:${LD_LIBRARY_PATH:-}" >> "$GITHUB_ENV"
115+
echo "LD_LIBRARY_PATH=$HTS_LIB_DIR" >> "$GITHUB_ENV"
116+
fi
117+
118+
- name: Install d4
119+
run: |
120+
#export HTSLIB=system
121+
git clone https://github.com/38/d4-format
122+
echo 'location' >> ~/.curlrc # https://github.com/38/d4-format/pull/77#issuecomment-2044438359
123+
cd d4-format
124+
cargo build --release --all-features --package=d4binding
125+
sudo cp target/release/libd4binding.* $DYLD_LIBRARY_PATH
126+
sudo cp d4binding/include/d4.h $DYLD_INCLUDE_PATH
127+
sudo ldconfig || true
128+
129+
- uses: iffy/install-nim@v5
130+
with:
131+
version: ${{ matrix.version }}
132+
133+
- name: Rust Toolchain
134+
uses: dtolnay/rust-toolchain@nightly
135+
with:
136+
toolchain: stable
137+
138+
# Build and Test
139+
- name: Build test executable
140+
run: nimble build -Y mosdepth.nimble
141+
142+
- name: "Copy binary"
143+
run: chmod +x mosdepth && mkdir bin && cp mosdepth bin/mosdepth_debug_${{ matrix.os }}
144+
145+
- name: "Build and Copy release binary"
146+
run: nim c --mm:refc -d:danger -d:release -o:bin/mosdepth_${{ matrix.os }} mosdepth
147+
148+
- name: Functional Tests
149+
env:
150+
TERM: "xterm"
151+
run: |
152+
bash ./functional-tests.sh
153+
154+
- name: Unit Tests
155+
run: |
156+
nim c -r tests/all.nim
157+
158+
- name: Upload Artifact
159+
if: success()
160+
uses: actions/upload-artifact@v4
161+
with:
162+
name: mosdepth_${{ matrix.os }}_nim${{ matrix.version }}_executable
163+
path: bin/

mosdepth.nimble

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ license = "MIT"
77

88
# Dependencies
99

10-
requires "hts >= 0.3.27", "docopt == 0.7.1", "nim >= 1.0.0", "https://github.com/brentp/d4-nim >= 0.0.5"
10+
requires "hts >= 0.3.29", "docopt == 0.7.1", "nim >= 1.0.0", "https://github.com/brentp/d4-nim >= 0.0.5"
1111

1212
bin = @["mosdepth"]
1313
skipDirs = @["tests"]

0 commit comments

Comments
 (0)