name: build

on: [push, pull_request]

jobs:
  build:
    name: Build
    runs-on: ${{ matrix.os }}
    env:
      CGO_CFLAGS_ALLOW: -Xpreprocessor
    strategy:
      matrix:
        os: [ubuntu-18.04, ubuntu-20.04, macOS-10.15]

    steps:
      - name: Set up Go 1.x
        uses: actions/setup-go@v2
        with:
          go-version: ^1.16

      - name: Check out code into the Go module directory
        uses: actions/checkout@v2

      - name: Install linux deps
        if: matrix.os == 'ubuntu-18.04' || matrix.os == 'ubuntu-20.04'
        run: |
          sudo add-apt-repository -y ppa:tonimelisma/ppa
          sudo apt-get -y install libvips-dev ffmpeg
      - name: Install macos deps
        if: matrix.os == 'macos-10.15'
        run: |
          brew install vips ffmpeg
      - name: Get dependencies
        run: |
          go get -v -t -d ./...
      - name: Build
        run: go build -v ./cmd/fastgallery

      - name: Test
        run: go test -v -coverprofile=profile.cov ./...

      - name: Coveralls
        if: matrix.os == 'ubuntu-20.04'
        uses: shogo82148/actions-goveralls@v1
        with:
          path-to-profile: profile.cov
