# SPDX-FileCopyrightText: 2024 Shun Sakai
#
# SPDX-License-Identifier: Apache-2.0 OR MIT

name: CI

on:
  pull_request:
  push:
    branches:
      - "develop"
      - "master"
  schedule:
    - cron: "0 0 * * 0"

jobs:
  test:
    name: Test
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os-alias:
          - ubuntu
          - macos
          - windows
        go-version-alias:
          - minimum
          - stable
        include:
          - os-alias: ubuntu
            os: ubuntu-24.04
          - os-alias: macos
            os: macos-14
          - os-alias: windows
            os: windows-2022
          - go-version-alias: minimum
            go-version: "1.22"
          - go-version-alias: stable
            go-version: "stable"
    steps:
      - name: Set Git to use LF
        if: matrix.os == 'windows-2022'
        run: |
          git config --global core.autocrlf false
          git config --global core.eol lf
      - name: Checkout code
        uses: actions/checkout@v5
      - name: Setup Go environment
        uses: actions/setup-go@v5
        with:
          go-version: ${{ matrix.go-version }}
      - name: Run tests
        run: go test -race -v ./...

  golangci-lint:
    name: golangci-lint
    runs-on: ubuntu-24.04
    steps:
      - name: Checkout code
        uses: actions/checkout@v5
      - name: Setup Go environment
        uses: actions/setup-go@v5
        with:
          go-version: "stable"
      - name: Run golangci-lint
        uses: golangci/golangci-lint-action@v8.0.0
        with:
          version: "latest"
          args: -v
