Skip to content

Commit 2bc7a23

Browse files
committed
fix build
1 parent 98bdf48 commit 2bc7a23

File tree

2 files changed

+140
-107
lines changed

2 files changed

+140
-107
lines changed

.github/workflows/build.yml

Lines changed: 139 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,149 @@ 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+
84+
- name: Set DYLD_LIBRARY_PATH (Linux)
85+
if: runner.os == 'Linux'
86+
run: |
87+
echo "DYLD_LIBRARY_PATH=/usr/local/lib" >> $GITHUB_ENV
88+
echo "DYLD_INCLUDE_PATH=/usr/local/include" >> $GITHUB_ENV
89+
90+
- name: Make libhts discoverable for tests
91+
run: |
92+
# Detect htslib location via Homebrew or fallback to $HOME/htslib
93+
HTS_LIB_DIR=""
94+
if command -v brew >/dev/null 2>&1; then
95+
BREW_PREFIX="$(brew --prefix htslib 2>/dev/null || true)"
96+
if [ -n "$BREW_PREFIX" ] && [ -d "$BREW_PREFIX/lib" ]; then
97+
HTS_LIB_DIR="$BREW_PREFIX/lib"
98+
fi
99+
fi
100+
if [ -z "$HTS_LIB_DIR" ] && [ -d "$HOME/htslib" ]; then
101+
HTS_LIB_DIR="$HOME/htslib"
102+
fi
103+
if [ -z "$HTS_LIB_DIR" ]; then
104+
echo "ERROR: libhts not found via Homebrew or at \$HOME/htslib" >&2
105+
exit 1
106+
fi
107+
echo "Using htslib dir: $HTS_LIB_DIR"
108+
if [ "${RUNNER_OS:-}" = "macOS" ]; then
109+
#echo "DYLD_LIBRARY_PATH=$HTS_LIB_DIR:${DYLD_LIBRARY_PATH:-}" >> "$GITHUB_ENV"
110+
echo "DYLD_LIBRARY_PATH=$HTS_LIB_DIR" >> "$GITHUB_ENV"
111+
else
112+
#echo "LD_LIBRARY_PATH=$HTS_LIB_DIR:${LD_LIBRARY_PATH:-}" >> "$GITHUB_ENV"
113+
echo "LD_LIBRARY_PATH=$HTS_LIB_DIR" >> "$GITHUB_ENV"
114+
fi
115+
116+
- name: Install d4
117+
run: |
118+
#export HTSLIB=system
119+
git clone https://github.com/38/d4-format
120+
echo 'location' >> ~/.curlrc # https://github.com/38/d4-format/pull/77#issuecomment-2044438359
121+
cd d4-format
122+
cargo build --release --all-features --package=d4binding
123+
sudo cp target/release/libd4binding.* $DYLD_LIBRARY_PATH
124+
sudo cp d4binding/include/d4.h $DYLD_INCLUDE_PATH
125+
sudo ldconfig || true
126+
127+
- uses: iffy/install-nim@v5
128+
with:
129+
version: ${{ matrix.version }}
130+
131+
- name: Rust Toolchain
132+
uses: dtolnay/rust-toolchain@nightly
133+
with:
134+
toolchain: stable
135+
136+
# Build and Test
137+
- name: Build test executable
138+
run: nimble build -Y mosdepth.nimble
139+
140+
- name: "Copy binary"
141+
run: chmod +x mosdepth && mkdir bin && cp mosdepth bin/mosdepth_debug_${{ matrix.os }}
142+
143+
- name: "Build and Copy release binary"
144+
run: nim c --mm:refc -d:danger -d:release -o:bin/mosdepth_${{ matrix.os }} mosdepth
145+
146+
- name: Functional Tests
147+
env:
148+
TERM: "xterm"
149+
run: |
150+
bash ./functional-tests.sh
151+
152+
- name: Unit Tests
153+
run: |
154+
nim c -r tests/all.nim
155+
156+
- name: Upload Artifact
157+
if: success()
158+
uses: actions/upload-artifact@v4
159+
with:
160+
name: mosdepth_${{ matrix.os }}_nim${{ matrix.version }}_executable
161+
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)