name: run units target on Cygwin

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  testing:  
    runs-on: windows-latest

    defaults:
      run:
        shell: C:\tools\cygwin\bin\bash.exe -l -i {0}

    steps:
    # https://www.cygwin.com/faq/faq.html#faq.setup.cli
    - run: Invoke-WebRequest -OutFile setup-x86_64.exe "http://cygwin.com/setup-x86_64.exe"
      shell: pwsh

    - run: .\setup-x86_64.exe --quiet-mode --no-desktop --no-shortcuts --no-startmenu --only-site --site http://mirrors.kernel.org/sourceware/cygwin/ --root C:\tools\cygwin --local-package-dir C:\tools\cygwin\packages --packages gcc-g++,make,automake,autoconf,pkg-config,dos2unix,libiconv-devel,libjansson-devel,libxml2-devel,libyaml-devel | Out-Default
      shell: pwsh

    - run: git config --global core.autocrlf input
      shell: bash

    - uses: actions/checkout@v4
    
    - run: printf 'cd %s' "$(cygpath '${{ github.workspace }}')" >> ~/.bashrc

    - run: ./autogen.sh
    - run: ./configure --prefix=/usr
    - run: make V=1
    - run: make install
    - run: file /usr/bin/ctags
    - run: /usr/bin/ctags --version
    - run: make check V=1
    - run: make roundtrip
