name: CI

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  test:
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
    runs-on: ${{ '{{' }} matrix.os {{ '}}' }}
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
{% if language == "rust" %}      - uses: dtolnay/rust-toolchain@1.88.0
        with:
          components: clippy, rustfmt
      - run: cargo build --all-targets
      - run: cargo test --all
      - run: cargo clippy --all-targets -- -D warnings
      - run: cargo fmt --all -- --check
{% elif language == "python" %}      - uses: actions/setup-python@v5
        with:
          python-version-file: .python-version
      - run: pip install -e .[dev]
      - run: pytest
      - run: ruff check .
      - run: ruff format --check .
{% elif language == "node" %}      - uses: actions/setup-node@v4
        with:
          node-version-file: .nvmrc
      - run: npm ci
      - run: npm run build
      - run: npm test
      - run: npm run lint
{% elif language == "go" %}      - uses: actions/setup-go@v5
        with:
          go-version-file: go.mod
      - run: go build ./...
      - run: go test ./...
      - run: go vet ./...
      - run: test -z "$(gofmt -l .)"
{% else %}      - run: make build
      - run: make test
      - run: make lint
      - run: make fmt-check
{% endif %}

  # Lint workflow YAML with actionlint and shell scripts with
  # shellcheck (OSS_SPEC §16.1). shellcheck is preinstalled on
  # ubuntu-latest; actionlint is fetched via its official installer.
  shell-lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Install actionlint
        run: |
          bash <(curl -sSfL https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
          echo "${PWD}" >> "$GITHUB_PATH"
      - name: make actionlint
        run: make actionlint
      - name: make shellcheck
        run: make shellcheck

