name: Tests

on:
  push:
    branches:
      - '*'
  pull_request:
    branches:
      - 'main'
      - 'release*'

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

permissions:
  contents: read

jobs:
  tests:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
      - name: Setup build env
        uses: ./.github/actions/setup-build-env
        with:
          build-cache-key: pre-checks
      - name: golangci-lint
        uses: golangci/golangci-lint-action@08e2f20817b15149a52b5b3ebe7de50aff2ba8c5 # v3.4.0
        with:
          version: v1.48
          skip-cache: true
      - name: go fmt check
        run: make fmt-check
      - name: goimports check
        run: make imports-check
      - name: Checking unused pkgs using go mod tidy
        run: make unused-package-check
      - name: Go vet
        run: make vet
      - name: Unit test
        run: make test-unit
