name: "Cygwin build"

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]
  schedule:
    - cron: '0 7 * * 2'

jobs:
  build:
    runs-on: windows-latest
    name: Build on ${{ matrix.platform }}

    strategy:
      matrix:
        platform: [x86, x86_64]

    steps:
    - name: Git - auto-converting CRLF line endings into LF
      run: git config --global core.autocrlf input

    - name: Repository checkout
      uses: actions/checkout@v3

    - name: Install Cygwin
      uses: cygwin/cygwin-install-action@v3
      with:
        platform: ${{ matrix.platform }}
        install-dir: C:\cygwin
        packages: git grep make libncurses-devel gcc-core gcc-g++ automake autoconf autoconf-archive libtool pkgconf cppunit

    - name: Test on Cygwin environment
      run: |
        uname -a
        whoami
        pwd
        cygcheck -c -d  # Show installed Cygwin packages
        g++ --version
        cd "$(cygpath -u $WORKSPACE_PATH)"
        autoreconf --force --install --verbose --warnings=all
        automake --add-missing --copy
        ./configure --prefix=/usr
        make -j10
      shell: C:\cygwin\bin\bash.exe --login '{0}'
      env:
        WORKSPACE_PATH: "${{ github.workspace }}"
        SHELLOPTS: igncr

