Skip to content

Commit

Permalink
add .github/workflow
Browse files Browse the repository at this point in the history
from @danielecook

requires changes to functional tests due to zcat differences on osx
  • Loading branch information
brentp committed May 11, 2020
1 parent ada9402 commit 48eae5f
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 6 deletions.
96 changes: 96 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# copied from Daniel Cook's Seq collection
name: Build

on:
- push
- pull_request

jobs:
build:

runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-18.04, macos-10.15]

steps:
- uses: actions/checkout@v2

# Caching
- name: Cache choosenim
id: cache-choosenim
uses: actions/cache@v1
with:
path: ~/.choosenim
key: ${{ runner.os }}-choosenim-stable

- name: Cache nimble
id: cache-nimble
uses: actions/cache@v1
with:
path: ~/.nimble
key: ${{ runner.os }}-nimble-stable

- name: Cache htslib
id: cache-htslib
uses: actions/cache@v1
with:
path: $HOME/htslib
key: ${{ runner.os }}-htslib-1.10

# Setup nim
- uses: jiro4989/[email protected]
with:
nim-version: 1.0.6

# Install Dependencies
- name: Install dependencies (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get -qy install bwa make build-essential cmake libncurses-dev ncurses-dev libbz2-dev lzma-dev liblzma-dev \
curl libssl-dev libtool autoconf automake libcurl4-openssl-dev
# Setup htslib
- name: Install htslib (linux)
if: runner.os == 'Linux'
run: |
cd
git clone --recursive https://github.com/samtools/htslib.git
cd htslib && git checkout 1.10 && autoheader && autoconf && ./configure --enable-libcurl
cd
make -j 4 -C htslib
echo "::set-env name=LD_LIBRARY_PATH::${LD_LIBRARY_PATH}:${HOME}/htslib"
ls -lh $HOME/htslib/*.so
- name: Install hstlib (macos)
if: runner.os == 'macOS'
run: |
brew install htslib
# Build and Test
- name: Build test executable
run: nimble build -Y mosdepth.nimble

- name: "Copy binary"
run: chmod +x mosdepth && mkdir bin && cp mosdepth bin/mosdepth_debug_${{ matrix.os }}

- name: "Build and Copy release binary"
run: nim c -d:danger -d:release -o:bin/mosdepth_${{ matrix.os }} mosdepth

- name: Functional Tests
env:
TERM: "xterm"
run: |
bash ./functional-tests.sh
- name: Unit Tests
run: |
nim c -r tests/all.nim
- name: Upload Artifact
if: success()
uses: actions/[email protected]
with:
name: mosdepth_${{ matrix.os }}_executable
path: bin/
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ fast BAM/CRAM depth calculation for **WGS**, **exome**, or **targeted sequencing

![logo](https://user-images.githubusercontent.com/1739/29678184-da1f384c-88ba-11e7-9d98-df4fe3a59924.png "logo")

[![Build](https://github.com/brentp/mosdepth/workflows/Build/badge.svg?branch=master)](https://github.com/brentp/mosdepth/actions?query=workflow%3ABuild)
[![Build Status](https://travis-ci.com/brentp/mosdepth.svg?branch=master)](https://travis-ci.com/brentp/mosdepth)

[![citation](https://img.shields.io/badge/cite-open%20access-orange.svg)](https://academic.oup.com/bioinformatics/article/doi/10.1093/bioinformatics/btx699/4583630?guestAccessKey=35b55064-4566-4ab3-a769-32916fa1c6e6)
Expand Down
12 changes: 6 additions & 6 deletions functional-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ assert_exit_code 1

run unordered_bed $exe --by tests/unordered.bed t tests/ovl.bam
assert_exit_code 0
assert_equal $(zcat t.regions.bed.gz | wc -l) 2
assert_equal $(zcat < t.regions.bed.gz | wc -l) 2

# theres data left in the bam but the region tree is empty...
run missing_bed_chrom $exe --by tests/missing.bed t tests/ovl.bam
Expand All @@ -74,13 +74,13 @@ assert_exit_code 0

rm -f t.thresholds.bed.gz*
run threshold_test $exe --by 100 -T 0,1,2,3,4,5 -c MT t tests/ovl.bam
assert_equal "$(zcat t.thresholds.bed.gz | tail -n +2 | head -1)" "MT 0 100 unknown 100 80 0 0 0 0"
assert_equal "0" "$(zcat t.thresholds.bed.gz | tail -n+2 | cut -f 7 | uniq)"
assert_equal "$(zcat < t.thresholds.bed.gz | tail -n +2 | head -1)" "MT 0 100 unknown 100 80 0 0 0 0"
assert_equal "0" "$(zcat < t.thresholds.bed.gz | tail -n+2 | cut -f 7 | uniq)"
assert_exit_code 0

rm -f t.thresholds.bed.gz*
run threshold_test_by $exe --by tests/track.bed -T 0,1,2 -c MT t tests/ovl.bam
assert_equal "$(zcat t.thresholds.bed.gz | tail -n +2)" "MT 2 80 aregion 78 78 0"
assert_equal "$(zcat < t.thresholds.bed.gz | tail -n +2)" "MT 2 80 aregion 78 78 0"
assert_exit_code 0

export MOSDEPTH_Q0=AAA
Expand All @@ -97,7 +97,7 @@ assert_equal "$(tail -n 1 t.mosdepth.summary.txt)" "total 16569 80 0.0048283 0 1

run track_header $exe --by tests/track.bed t tests/ovl.bam
assert_exit_code 0
assert_equal "$(zcat t.regions.bed.gz)" "MT 2 80 aregion 1.00"
assert_equal "$(zcat < t.regions.bed.gz)" "MT 2 80 aregion 1.00"

run track_header_by $exe --by tests/bad.bed t tests/ovl.bam
assert_exit_code 1
Expand Down Expand Up @@ -136,7 +136,7 @@ assert_equal $(diff -u t_regions.mosdepth.region.dist.txt t_regions.mosdepth.glo
rm -f t_regions.*

run overlappingPairs $exe t tests/overlapping-pairs.bam
assert_equal "$(zcat t.per-base.bed.gz)" "1 0 565173 0
assert_equal "$(zcat < t.per-base.bed.gz)" "1 0 565173 0
1 565173 565253 1
1 565253 249250621 0"
assert_exit_code 0
Expand Down

3 comments on commit 48eae5f

@danielecook
Copy link
Contributor

@danielecook danielecook commented on 48eae5f May 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@brentp I think you can also use gzip -dc; Easy to remember the flags b/c my initials :-D

@brentp
Copy link
Owner Author

@brentp brentp commented on 48eae5f May 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hah. thanks! using stdin worked for now.

@danielecook
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@brentp - one thing you should be aware of with GitHub actions.

Github actions seems to trick tools into thinking there is always stdin. So if you try to emulate the behavior of bcftools which infers stdin even if you do not specify -, you will run into issues when testing. If you force the user to specify - for stdin it is not an issue.

See nim-lang/Nim#14144 for an example if by chance you run across a similar situation.

Please sign in to comment.