sudo: required
language: python
jdk: openjdk8
services: docker
python: '3.6'
cache: pip
matrix:
  fast_finish: true

before_install:
  # PRs made to 'master' branch should always orginate from another repo or the 'dev' branch
  - '[ $TRAVIS_PULL_REQUEST = "false" ] || [ $TRAVIS_BRANCH != "master" ] || ([ $TRAVIS_PULL_REQUEST_SLUG = $TRAVIS_REPO_SLUG ] && ([ $TRAVIS_PULL_REQUEST_BRANCH = "dev" ] || [ $TRAVIS_PULL_REQUEST_BRANCH = "patch" ]))'
  # Pull the docker image first so the test doesn't wait for this
  - docker pull nfcore/neutronstar:dev
  - docker pull nfcore/supernova:2.1.1
  # Fake the tag locally so that the pipeline runs properly
  - docker tag nfcore/neutronstar:dev nfcore/neutronstar:1.0.0

install:
  # Install Nextflow
  - mkdir /tmp/nextflow && cd /tmp/nextflow
  - wget -qO- get.nextflow.io | bash
  - sudo ln -s /tmp/nextflow/nextflow /usr/local/bin/nextflow
  # Install nf-core/tools
  - pip install --upgrade pip
  - pip install nf-core
  # Reset
  - cd ${TRAVIS_BUILD_DIR}
  # Install markdownlint-cli
  - sudo apt-get install npm && npm install -g markdownlint-cli

env:
  - NXF_VER='19.04.0' # Specify a minimum NF version that should be tested and work
  - NXF_VER='' # Plus: get the latest NF version and check, that it works

script:
  # Lint the pipeline code
  - nf-core lint ${TRAVIS_BUILD_DIR}
  # Run the busco_downloader script
  - cd ${TRAVIS_BUILD_DIR}/data/
  - python busco_data.py --help
  # Run the pipeline with the test profile faked fastq files
  - cd ${TRAVIS_BUILD_DIR}
  - mkdir -p fakeq; touch fakeq/1.fq.gz; touch fakeq/2.fq.gz; touch fakeq/3.fq.gz
  # Lint the documentation
  - markdownlint ${TRAVIS_BUILD_DIR} -c ${TRAVIS_BUILD_DIR}/.github/markdownlint.yml
  # Run the pipeline with the test profile
  - nextflow run ${TRAVIS_BUILD_DIR} -profile test,docker --id testrun --maxreads all --fastqs fakeq/ --genomesize 1000 --max_cpus 2 --max_memory 4
