name: Go

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

jobs:
  build:
    name: Build
    runs-on: ubuntu-latest
    strategy:
      matrix:
        go:
          - "1.12"
          - "1.13"
          - "1.14"
          - "1.15"
        redis-version:
          - 4
          - 5
          - 6

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

      - name: Setup Go
        uses: actions/setup-go@v2
        with:
          go-version: ${{ matrix.go }}

      - name: Setup Redis
        uses: supercharge/redis-github-action@1.1.0
        with:
          redis-version: ${{ matrix.redis-version }}

      - name: Build
        run: go build -v . 

      - name: Test
        run: go test -v . 

  imports:
    name: Imports
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@master
      - name: check
        uses: grandcolline/golang-github-actions@v1.1.0
        with:
          run: imports
          token: ${{ secrets. GITHUB_TOKEN }}

  ## Checks to be enabled in the future:

  # errcheck:
  #   name: Errcheck
  #   runs-on: ubuntu-latest
  #   steps:
  #     - uses: actions/checkout@master
  #     - name: check
  #       uses: grandcolline/golang-github-actions@v1.1.0
  #       with:
  #         run: errcheck
  #         token: ${{ secrets. GITHUB_TOKEN }}
  # lint:
  #   name: Lint
  #   runs-on: ubuntu-latest
  #   steps:
  #     - uses: actions/checkout@master
  #     - name: check
  #       uses: grandcolline/golang-github-actions@v1.1.0
  #       with:
  #         run: lint
  #         token: ${{ secrets. GITHUB_TOKEN }}
  # shadow:
  #   name: Shadow
  #   runs-on: ubuntu-latest
  #   steps:
  #     - uses: actions/checkout@master
  #     - name: check
  #       uses: grandcolline/golang-github-actions@v1.1.0
  #       with:
  #         run: shadow
  #         token: ${{ secrets. GITHUB_TOKEN }}
  # staticcheck:
  #   name: StaticCheck
  #   runs-on: ubuntu-latest
  #   steps:
  #     - uses: actions/checkout@master
  #     - name: check
  #       uses: grandcolline/golang-github-actions@v1.1.0
  #       with:
  #         run: staticcheck
  #         token: ${{ secrets. GITHUB_TOKEN }}
  # sec:
  #   name: Sec
  #   runs-on: ubuntu-latest
  #   steps:
  #     - uses: actions/checkout@master
  #     - name: check
  #       uses: grandcolline/golang-github-actions@v1.1.0
  #       with:
  #         run: sec
  #         token: ${{ secrets. GITHUB_TOKEN }}
  #         # flags: "-exclude=G104"