name: sarek CI
# This workflow is triggered on pushes and PRs to the repository.
on: [push, pull_request]  

jobs:
  test:
    runs-on: ubuntu-18.04
    strategy:
      matrix:
        nxf_ver: ['19.10.0', '']
    steps:
      - uses: actions/checkout@v1
      - name: Install Nextflow
        run: |
          export NXF_VER=${{ matrix.nxf_ver }}
          wget -qO- get.nextflow.io | bash
          sudo mv nextflow /usr/local/bin/
      - name: Download and tag image
        run: |
          docker pull nfcore/sarek:dev
          docker tag nfcore/sarek:dev nfcore/sarek:2.5.2
      - name: Run test
        run: |
          nextflow run ${GITHUB_WORKSPACE} -profile test,docker
  annotation:
    runs-on: ubuntu-18.04
    strategy:
      matrix:
        annotator: [snpeff]
        specie: [GRCh37]
    steps:
      - uses: actions/checkout@v1
      - name: Install Nextflow
        run: |
          wget -qO- get.nextflow.io | bash
          sudo mv nextflow /usr/local/bin/
        env:
          NXF_VER: '19.10.0'
      - name: Download and tag images
        run: |
          docker pull nfcore/sarek:dev
          docker tag nfcore/sarek:dev nfcore/sarek:2.5.2
          docker pull nfcore/sarek${{ matrix.annotator }}:dev.${{ matrix.specie }}
          docker tag nfcore/sarek${{ matrix.annotator }}:dev.${{ matrix.specie }} nfcore/sarek${{ matrix.annotator }}:2.5.2.${{ matrix.specie }}
      - name: Run annotation test
        run: |
          nextflow run . -profile test_annotation,docker --verbose --tools ${{ matrix.annotator }}
  germline:
    runs-on: ubuntu-18.04
    steps:
      - uses: actions/checkout@v1
      - name: Install Nextflow
        run: |
          wget -qO- get.nextflow.io | bash
          sudo mv nextflow /usr/local/bin/
        env:
          NXF_VER: '19.10.0'
      - name: Download and tag image
        run: |
          docker pull nfcore/sarek:dev
          docker tag nfcore/sarek:dev nfcore/sarek:2.5.2
      - name: Get test data
        run: |
          git clone --single-branch --branch sarek https://github.com/nf-core/test-datasets.git data
      - name: Run germline test
        run: |
          nextflow run . -profile test,docker --input data/testdata/tiny/normal
          nextflow run . -profile test,docker --input=false --step recalibrate -resume
          nextflow run . -profile test,docker --input=false --step variantCalling
  minimal:
    runs-on: ubuntu-18.04
    strategy:
      matrix:
        genome: [smallerGRCh37, minimalGRCh37]
        intervals: [--no_intervals, '']
    steps:
      - uses: actions/checkout@v1
      - name: Install Nextflow
        run: |
          wget -qO- get.nextflow.io | bash
          sudo mv nextflow /usr/local/bin/
        env:
          NXF_VER: '19.10.0'
      - name: Download and tag image
        run: |
          docker pull nfcore/sarek:dev
          docker tag nfcore/sarek:dev nfcore/sarek:2.5.2
      - name: Run test for minimal genomes
        run: |
          nextflow run . -profile test,docker --skipQC all --verbose --genome ${{ matrix.genome }} ${{ matrix.intervals }} --tools Manta,mpileup,Strelka
  profile:
    runs-on: ubuntu-18.04
    strategy:
      matrix:
        profile: [test_splitfastq, test_targeted]
    steps:
      - uses: actions/checkout@v1
      - name: Install Nextflow
        run: |
          wget -qO- get.nextflow.io | bash
          sudo mv nextflow /usr/local/bin/
        env:
          NXF_VER: '19.10.0'
      - name: Download and tag image
        run: |
          docker pull nfcore/sarek:dev
          docker tag nfcore/sarek:dev nfcore/sarek:2.5.2
      - name: Run targeted and splitfastq tests
        run: |
          nextflow run . -profile ${{ matrix.profile }},docker --verbose
  tools:
    runs-on: ubuntu-18.04
    strategy:
      matrix:
        tool: [Haplotypecaller, Freebayes, Manta, mpileup, Mutect2, Strelka, TIDDIT]
    steps:
      - uses: actions/checkout@v1
      - name: Install Nextflow
        run: |
          wget -qO- get.nextflow.io | bash
          sudo mv nextflow /usr/local/bin/
        env:
          NXF_VER: '19.10.0'
      - name: Download and tag image
        run: |
          docker pull nfcore/sarek:dev
          docker tag nfcore/sarek:dev nfcore/sarek:2.5.2
      - name: Run variant calling test on specific tools
        run: |
          nextflow run . -profile test_tool,docker --verbose --tools ${{ matrix.tool }}
