name: nf-core CI
# This workflow is triggered on pushes and PRs to the repository.
# It runs the pipeline with the minimal test dataset to check that it completes without any syntax errors.
on: [push, pull_request]

jobs:
  test:
    env:
      NXF_VER: ${{ matrix.nxf_ver }}
      NXF_ANSI_LOG: false
    runs-on: ubuntu-latest
    strategy:
      matrix:
        # Nextflow versions: check pipeline minimum and current latest
        nxf_ver: ['19.10.0', '']
    steps:
      - uses: actions/checkout@v2
      - name: Install Nextflow
        run: |
          wget -qO- get.nextflow.io | bash
          sudo mv nextflow /usr/local/bin/
      - name: Pull docker image
        run: |
          docker pull nfcore/sarek:dev
          docker tag nfcore/sarek:dev nfcore/sarek:2.6.1
      - name: Run test
        run: nextflow run ${GITHUB_WORKSPACE} -profile test,docker

  annotation:
    env:
      NXF_ANSI_LOG: false
    runs-on: ubuntu-latest
    strategy:
      matrix:
        tools: [snpeff, vep]
        species: [WBcel235]
    steps:
      - uses: actions/checkout@v2
      - name: Install Nextflow
        run: |
          wget -qO- get.nextflow.io | bash
          sudo mv nextflow /usr/local/bin/
        env:
          # Only check Nextflow pipeline minimum version
          NXF_VER: '19.10.0'
      - name: Pull docker image
        run: |
          docker pull nfcore/sarek:2.6.1
          docker pull nfcore/sarek${{ matrix.tools }}:2.6.1.${{ matrix.species }}
      - name: Run annotation test
        run: nextflow run ${GITHUB_WORKSPACE} -profile test_annotation,docker --tools ${{ matrix.tools }}

  germline:
    env:
      NXF_ANSI_LOG: false
    runs-on: ubuntu-latest
    strategy:
      matrix:
        markduplicates: [--skip_markduplicates, '']
    steps:
      - uses: actions/checkout@v2
      - name: Install Nextflow
        run: |
          wget -qO- get.nextflow.io | bash
          sudo mv nextflow /usr/local/bin/
        env:
          # Only check Nextflow pipeline minimum version
          NXF_VER: '19.10.0'
      - name: Pull docker image
        run: docker pull nfcore/sarek:2.6.1
      - 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 ${GITHUB_WORKSPACE} -profile test,docker ${{ matrix.markduplicates }} --input data/testdata/tiny/normal --saved_bam_mapped
          nextflow run ${GITHUB_WORKSPACE} -profile test,docker ${{ matrix.markduplicates }} --input=false --step prepare_recalibration -resume
          nextflow run ${GITHUB_WORKSPACE} -profile test,docker ${{ matrix.markduplicates }} --input=false --step recalibrate -resume
          nextflow run ${GITHUB_WORKSPACE} -profile test,docker ${{ matrix.markduplicates }} --input=false --step variantCalling

  minimal:
    env:
      NXF_ANSI_LOG: false
    runs-on: ubuntu-latest
    strategy:
      matrix:
        genome: [smallerGRCh37, minimalGRCh37]
        intervals: [--no_intervals, '']
    steps:
      - uses: actions/checkout@v2
      - name: Install Nextflow
        run: |
          wget -qO- get.nextflow.io | bash
          sudo mv nextflow /usr/local/bin/
        env:
          # Only check Nextflow pipeline minimum version
          NXF_VER: '19.10.0'
      - name: Pull docker image
        run: docker pull nfcore/sarek:2.6.1
      - name: Run test for minimal genomes
        run: nextflow run ${GITHUB_WORKSPACE} -profile test,docker --skipQC all --genome ${{ matrix.genome }} ${{ matrix.intervals }} --tools Manta,mpileup,Strelka,FreeBayes

  profile:
    env:
      NXF_ANSI_LOG: false
    runs-on: ubuntu-latest
    strategy:
      matrix:
        profile: [test_split_fastq, test_targeted, test_trimming, test_no_gatk_spark]
    steps:
      - uses: actions/checkout@v2
      - name: Install Nextflow
        run: |
          wget -qO- get.nextflow.io | bash
          sudo mv nextflow /usr/local/bin/
        env:
          # Only check Nextflow pipeline minimum version
          NXF_VER: '19.10.0'
      - name: Pull docker image
        run: docker pull nfcore/sarek:2.6.1
      - name: Run ${{ matrix.profile }} test
        run: nextflow run ${GITHUB_WORKSPACE} -profile ${{ matrix.profile }},docker

  tools:
    env:
      NXF_ANSI_LOG: false
    runs-on: ubuntu-latest
    strategy:
      matrix:
        tool: [Haplotypecaller, Freebayes, Manta, mpileup, MSIsensor, Strelka, TIDDIT]
        intervals: [--no_intervals, '']
        exclude:
          - tool: Manta
            intervals: --no_intervals
          - tool: MSIsensor
            intervals: --no_intervals
          - tool: Strelka
            intervals: --no_intervals
          - tool: TIDDIT
            intervals: --no_intervals
    steps:
      - uses: actions/checkout@v2
      - name: Install Nextflow
        run: |
          wget -qO- get.nextflow.io | bash
          sudo mv nextflow /usr/local/bin/
        env:
          # Only check Nextflow pipeline minimum version
          NXF_VER: '19.10.0'
      - name: Pull docker image
        run: docker pull nfcore/sarek:2.6.1
      - name: Run ${{ matrix.tool }} test
        run: nextflow run ${GITHUB_WORKSPACE} -profile test_tool,docker --tools ${{ matrix.tool }} ${{ matrix.intervals }}
