name: Build and test on Windows

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

jobs:

  build:
    runs-on: windows-latest
    defaults:
      run:
        shell: msys2 {0}

    steps:
    - uses: actions/checkout@v2

    - name: Set up Go
      uses: actions/setup-go@v2
      with:
        go-version: 1.18

    - uses: msys2/setup-msys2@v2
      with:
        msystem: MINGW64
        update: true
        install:
          git
          make
          mingw-w64-x86_64-gtk3
          mingw-w64-x86_64-glib2
          mingw-w64-x86_64-go
          mingw-w64-x86_64-gcc
          mingw-w64-x86_64-pkg-config
          glib2-devel

    - name: Build the binary
      run: |
        # This fixes a bug in pkgconfig: invalid flag in pkg-config --libs: -Wl,-luuid
        sed -i -e 's/-Wl,-luuid/-luuid/g' /mingw64/lib/pkgconfig/gdk-3.0.pc

    - name: Build
      run: go build -v ./...

    - name: Test
      run: go test -v ./...
