name: nf-core CI
# This workflow runs the pipeline with the minimal test dataset to check that it completes without any syntax errors
on:
  push:
    branches:
      - dev
  pull_request:
  release:
    types: [published]

env:
  NXF_ANSI_LOG: false
  CAPSULE_LOG: none

jobs:
  test:
    name: Run workflow tests
    # Only run on push if this is the nf-core dev branch (merged PRs)
    if: ${{ github.event_name != 'push' || (github.event_name == 'push' && github.repository == 'nf-core/viralrecon') }}
    runs-on: ubuntu-latest
    strategy:
      matrix:
        # Nextflow versions
        include:
          # Test pipeline minimum Nextflow version
          - NXF_VER: '21.10.3'
            NXF_EDGE: ''
          # Test latest edge release of Nextflow
          - NXF_VER: ''
            NXF_EDGE: '1'
    steps:
      - name: Check out pipeline code
        uses: actions/checkout@v2

      - name: Install Nextflow
        env:
          NXF_VER: ${{ matrix.NXF_VER }}
          # Uncomment only if the edge release is more recent than the latest stable release
          # See https://github.com/nextflow-io/nextflow/issues/2467
          # NXF_EDGE: ${{ matrix.NXF_EDGE }}
        run: |
          wget -qO- get.nextflow.io | bash
          sudo mv nextflow /usr/local/bin/

      - name: Run pipeline with test data
        run: |
          nextflow run ${GITHUB_WORKSPACE} -profile test,docker --outdir ./results

  parameters:
    name: Test workflow parameters
    if: ${{ github.event_name != 'push' || (github.event_name == 'push' && github.repository == 'nf-core/viralrecon') }}
    runs-on: ubuntu-latest
    strategy:
      matrix:
        parameters:
          - "--consensus_caller ivar"
          - "--variant_caller bcftools --consensus_caller ivar"
          - "--skip_fastp --skip_pangolin"
          - "--skip_variants"
          - "--skip_cutadapt --skip_snpeff"
          - "--skip_kraken2"
          - "--skip_assembly"
          - "--spades_mode corona"
          - "--spades_mode metaviral"
          - "--skip_plasmidid false --skip_asciigenome"
    steps:
      - name: Check out pipeline code
        uses: actions/checkout@v2

      - name: Install Nextflow
        run: |
          wget -qO- get.nextflow.io | bash
          sudo mv nextflow /usr/local/bin/

      - name: Run pipeline with various parameters
        run: |
          nextflow run ${GITHUB_WORKSPACE} -profile test,docker ${{ matrix.parameters }} --outdir ./results

  test_sispa:
    name: Test SISPA workflow
    if: ${{ github.event_name != 'push' || (github.event_name == 'push' && github.repository == 'nf-core/viralrecon') }}
    runs-on: ubuntu-latest
    strategy:
      matrix:
        parameters:
          - "--gff false"
          - "--genome 'NC_045512.2'"
    steps:
      - name: Check out pipeline code
        uses: actions/checkout@v2

      - name: Install Nextflow
        run: |
          wget -qO- get.nextflow.io | bash
          sudo mv nextflow /usr/local/bin/

      - name: Run pipeline with minimal SISPA data and various options
        run: |
          nextflow run ${GITHUB_WORKSPACE} -profile test_sispa,docker ${{ matrix.parameters }} --outdir ./results

  test_nanopore:
    name: Test Nanopore workflow
    if: ${{ github.event_name != 'push' || (github.event_name == 'push' && github.repository == 'nf-core/viralrecon') }}
    runs-on: ubuntu-latest
    strategy:
      matrix:
        parameters:
          - "--gff false"
          - "--input false"
          - "--min_barcode_reads 10000"
          - "--min_guppyplex_reads 10000"
          - "--artic_minion_caller medaka --sequencing_summary false --fast5_dir false"
          - "--artic_minion_caller medaka --sequencing_summary false --fast5_dir false --artic_minion_medaka_model r941_min_high_g360"
    steps:
      - name: Check out pipeline code
        uses: actions/checkout@v2

      - name: Install Nextflow
        run: |
          wget -qO- get.nextflow.io | bash
          sudo mv nextflow /usr/local/bin/

      - name: Run pipeline with minimal Nanopore data and various options
        run: |
          nextflow run ${GITHUB_WORKSPACE} -profile test_nanopore,docker ${{ matrix.parameters }} --outdir ./results
