{% set runtime = runtime | default('python') %}
{% set python_version = python_version | default('3.10') %}
{% set node_version = node_version | default('20.19.6') %}
{% set package_manager = package_manager | default('npm') %}
{% set package_manager_command = package_manager_command | default(package_manager) %}
name: CI

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

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4
{% if runtime == 'python' %}
      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: "{{ python_version }}"
      - name: Install Poetry
        uses: snok/install-poetry@v1
        with:
          version: latest
          virtualenvs-create: true
          virtualenvs-in-project: true
      - name: Install dependencies
        run: |
          poetry install --no-interaction --sync
      - name: Lint
        run: |
          poetry run ruff check src
          poetry run black --check src
      - name: Type check
        run: |
          poetry run mypy src
      - name: Tests
        run: |
          poetry run pytest --cov=src --cov-report=term-missing
{% else %}
      - name: Set up Node.js
        uses: actions/setup-node@v4
        with:
          node-version: "{{ node_version }}"
      - name: Install dependencies
        run: |
          {{ package_manager_command }} install
      - name: Lint
        run: |
{% if package_manager == 'yarn' %}          {{ package_manager_command }} lint
{% else %}          {{ package_manager_command }} run lint
{% endif %}
      - name: Tests
        run: |
{% if package_manager == 'yarn' %}          {{ package_manager_command }} test --ci
{% else %}          {{ package_manager_command }} test -- --ci --watch=false
{% endif %}
{% endif %}
