name: build

on:
  push:
    branches:
      - '*'

jobs:
  ubuntu-20-04:
    runs-on: ubuntu-20.04
    steps:
    - uses: actions/checkout@master
    - name: Install-prerequisites
      run: sudo ./scripts/InstallPrerequisites-Ubuntu.sh
    - name: Build-ubuntu-20.04
      run: |
        lsb_release -a
        mkdir shasta-build
        cd shasta-build 
        # cmake .. -DBUILD_ID="Shasta unreleased test build newer than release 0.7.0 at commit "$GITHUB_SHA
        cmake .. -DBUILD_ID="Shasta Release 0.7.0" 
        make -j 2 all
        make install/strip
        mv shasta-install shasta-Ubuntu-20.04
        tar -cvf shasta-Ubuntu-20.04.tar shasta-Ubuntu-20.04        
    - name: Test-ubuntu-20.04
      run: |
        sudo apt install gzip
        gunzip tests/TinyTest.fasta.gz
        shasta-build/shasta-Ubuntu-20.04/bin/shasta --Align.alignMethod 3 --input tests/TinyTest.fasta
        ls -l ShastaRun/Assembly.fasta
    - uses: actions/upload-artifact@master
      with:
        name: shasta-Linux
        path: shasta-build/shasta-Ubuntu-20.04/bin/shasta
    - uses: actions/upload-artifact@master
      with:
        name: shasta-Ubuntu-20.04.tar
        path: shasta-build/shasta-Ubuntu-20.04.tar

  ubuntu-20-04-minimal:
    runs-on: ubuntu-20.04
    steps:
    - uses: actions/checkout@master
    - name: Install-prerequisites (minimal)
      run: sudo ./scripts/InstallPrerequisites-Ubuntu.sh --minimal
    - name: Build-ubuntu-20.04 (minimal)
      run: |
        lsb_release -a
        mkdir shasta-build
        cd shasta-build 
        cmake .. -DBUILD_DYNAMIC_EXECUTABLE=OFF -DBUILD_DYNAMIC_LIBRARY=OFF -DBUILD_WITH_HTTP_SERVER=OFF \
          -DBUILD_ID="Shasta unreleased test build newer than release 0.7.0 at commit "$GITHUB_SHA
        # cmake .. -DBUILD_ID="Shasta Release 0.7.0" 
        make -j 2 all
        make install/strip
        mv shasta-install shasta-Ubuntu-20.04
        tar -cvf shasta-Ubuntu-20.04.tar shasta-Ubuntu-20.04        
    - name: Test-ubuntu-20.04
      run: |
        sudo apt install gzip
        gunzip tests/TinyTest.fasta.gz
        shasta-build/shasta-Ubuntu-20.04/bin/shasta --Align.alignMethod 3 --input tests/TinyTest.fasta --Reads.noCache
        ls -l ShastaRun/Assembly.fasta
    
       
  macOS-10-15:
    runs-on: macOS-10.15
    steps:
    - uses: actions/checkout@master
    - name: Install-prerequisites
      run: scripts/InstallPrerequisites-macOS.sh
    - name: Build-macOS-10.15
      run: |
        mkdir shasta-build
        cd shasta-build 
        # cmake .. -DBUILD_ID="Shasta unreleased test build for MacOS-10.15 newer than release 0.7.0 at commit "$GITHUB_SHA
        cmake .. -DBUILD_ID="Shasta Release 0.7.0 for MacOS"
        make VERBOSE=1 -j 2 all
        make install/strip
        # See what libraries the executable depends on.
        otool -L shasta-install/bin/shasta
    - name: Test-macOS-10.15
      run: |
        brew install gzip
        gunzip tests/TinyTest.fasta.gz
        shasta-build/shasta-install/bin/shasta --Align.alignMethod 3 --input tests/TinyTest.fasta
        ls -l ShastaRun/Assembly.fasta
    - uses: actions/upload-artifact@master
      with:
        name: shasta-macOS
        path: shasta-build/shasta-install/bin/shasta
