name: tests

on:
  pull_request:
    paths-ignore:
      - '*.md'
  schedule:
    - cron:  0 23 * * *

jobs:
  build:
    name: building tfsec
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ macos-latest, windows-latest, ubuntu-latest ]

    steps:
    - uses: actions/checkout@v3
    - uses: actions/setup-go@v3
      with:
        go-version: '1.18'
    - run: go version

    - uses: actions/cache@v3
      with:
        path: |
          ~/.cache/go-build
          ~/go/pkg/mod
        key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
        restore-keys: |
          ${{ runner.os }}-go-
      if: runner.os == 'Linux'

    - uses: actions/cache@v3
      with:
        path: |
          ~/Library/Caches/go-build
          ~/go/pkg/mod
        key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
        restore-keys: |
          ${{ runner.os }}-go-
      if: runner.os == 'Darwin'

    - uses: actions/cache@v3
      with:
        path: |
          ~\AppData\Local\go-build
          ~\go\pkg\mod
        key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
        restore-keys: |
          ${{ runner.os }}-go-
      if: runner.os == 'Windows'

    - name: Run tests
      run: make test

