name: Code check

on:
  pull_request:
    branches: [main]
    paths-ignore:
      - "data/**"
      - "*.md"
      - "dev-scripts/**"
  push:
    branches: [main]
    paths-ignore:
      - "data/**"
      - "*.md"
      - "dev-scripts/**"
  workflow_dispatch:

jobs:
  pre-commit:
    name: Check code
    runs-on: ubuntu-latest
    steps:
      - uses: https://gitea.com/actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6

      - name: Set up Node.js
        uses: https://gitea.com/actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6
        with:
          node-version: 20

      - name: Install uv manually
        run: |
          curl -LsSf https://astral.sh/uv/install.sh | sh
          source $HOME/.local/bin/env
          uv --version

      - name: Sync dependencies into venv
        run: uv sync --all-extras --dev

      - name: Activate .venv & run pre-commit
        shell: bash
        run: |
          source .venv/bin/activate
          pre-commit run --show-diff-on-failure --color=always --all-files
