name: CI

on:
  push:
    tags-ignore:
    - 'v*'
    branches:
    - 'master'
  pull_request:
  workflow_call:

permissions:
  contents: read

jobs:
  ci:
    permissions:
      actions: read
      contents: read
      security-events: write
    uses: smallstep/workflows/.github/workflows/goCI.yml@main
    with:
      only-latest-golang: false
      run-codeql: true
      run-test: false
    secrets: inherit

  test:
    runs-on: ubuntu-latest
    services:
      postgres:
        image: postgres:17
        env:
          POSTGRES_USER: user
          POSTGRES_PASSWORD: password
        ports:
          - 5432:5432
        options: >-
          --health-cmd pg_isready
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5
      mysql:
        image: mysql:5.7
        env:
          MYSQL_USER: user
          MYSQL_PASSWORD: password
          MYSQL_DATABASE: test
          MYSQL_ROOT_PASSWORD: password
        ports:
          - 3306:3306
        options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
    strategy:
      matrix:
        go: [ 'stable', 'oldstable' ]
    steps:
      - name: Checkout
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
      - name: Set up Go
        uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
        with:
          go-version: ${{ matrix.go }}
          check-latest: true
      - name: Test
        run: V=1 make ci-test
