name: build

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

jobs:

  build:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os:
          - ubuntu-18.04
          - ubuntu-20.04
          - ubuntu-22.04
          - windows-2019
          - windows-2022
          - macos-10.15
          - macos-11
          - macos-12
        go:
          - '1.17'
          - '1.18'
          - '1.19'
    steps:
      - uses: actions/checkout@v3

      - name: Set up Go
        uses: actions/setup-go@v3
        with:
          go-version: ${{ matrix.go }}

      - name: Lint
        run: |
          go install golang.org/x/lint/golint@latest
          golint -set_exit_status code/...
          go install github.com/gordonklaus/ineffassign@latest
          ineffassign ./...

      - name: Build Server
        run: go build -v code/server/main.go

      - name: Build Client
        run: |
          go run contrib/bindata/main.go -pkg shell -o code/client/rule/shell/assets.go -prefix html/shell html/shell/...
          go run contrib/bindata/main.go -pkg vnc -o code/client/rule/vnc/assets.go -prefix html/vnc html/vnc/...
          go run contrib/bindata/main.go -pkg code -o code/client/rule/code/assets.go -prefix html/code html/code/...
          go run contrib/bindata/main.go -pkg dashboard -o code/client/dashboard/assets.go -prefix html/dashboard html/dashboard/...
          go build -v code/client/main.go
