name: windows mingw64 with gfortran

on: [push, pull_request]

env:
  CTEST_TIME_TIMEOUT: "50"  # some failures hang forever

jobs:
  build:
    runs-on: windows-latest
    strategy:
      fail-fast: false
      matrix:
        include: [
          { msystem: MINGW64, arch: x86_64 },
        ]
    env:
      FC: gfortran
      TZ: UTC+04:00
    defaults:
      run:
        shell: msys2 {0}
    steps:
    - uses: actions/checkout@v2

    - name: Setup MinGW native environment
      uses: msys2/setup-msys2@v2
      if: contains(matrix.msystem, 'MINGW')
      with:
        msystem: ${{ matrix.msystem }}
        update: false
        install: >-
          git
          wget
          mingw-w64-${{ matrix.arch }}-gcc
          mingw-w64-${{ matrix.arch }}-gcc-fortran

    - name: Install fpm
      run: |
           echo $PATH
           pwd
           uname -a
           wget https://raw.githubusercontent.com/urbanjost/index/main/bootstrap/fpm.F90
           gfortran fpm.F90 -o fpm
           ls -l

    - name: tests (release)
      run: |
        gfortran --version
        PATH=$PATH:.
        ./fpm test --compiler gfortran --profile release -flag "-D _WIN32"
      env:
        FPM_COMPILER: gfortran
        CC: gcc
        CXX: g++
        FC: gfortran
        TZ: UTC+04:00

    - name: tests (debug)
      run: |
        PATH=$PATH:.
        gfortran --version
        ./fpm test --compiler gfortran --profile debug   -flag "-D _WIN32"
      env:
        FPM_COMPILER: gfortran
        CC: gcc
        CXX: g++
        FC: gfortran
        TZ: UTC+04:00

    - name: cleanup 
      run: ls -ltras
