set export

# Configure shell for Windows.
set windows-shell := ["pwsh", "-NoLogo", "-Command"]

# Lists all targets
[private]
default:
  @just --list

# Run static analysis on all code.
[group('Static Analysis')]
check-all: check-python

# Fix static analysis issues for all code.
[group('Static Analysis')]
fix-all: fix-python

# Test dotslash feature with automated test located at devcontainer-features/test/dotslash/test.sh.
[group('Development Container Feature')]
test-feature-autogenerated:
  #!/usr/bin/env bash
  set -euo pipefail

  base_images=(
    debian:latest
    mcr.microsoft.com/devcontainers/base:ubuntu
    ubuntu:latest
  )

  for base_image in ${base_images[@]}; do
    devcontainer features test \
      --base-image debian:latest \
      --features dotslash \
      --project-folder devcontainer-features \
      --skip-scenarios
  done

# Test dotslash feature with scenarios defined in devcontainer-features/test/dotslash/scenarios.json.
[group('Development Container Feature')]
test-feature-scenarios:
  #!/usr/bin/env bash
  set -euo pipefail

  devcontainer features test \
    --features dotslash \
    --project-folder devcontainer-features \
    --skip-autogenerated \
    --skip-duplicated

# Run static analysis on the Python package.
[group('Downstream')]
[working-directory: 'python']
check-python:
  uv run --no-project --with-requirements requirements-fmt.txt -- ufmt diff src tests
  uv run --no-project --with-requirements requirements-fmt.txt -- ufmt check src tests

# Fix static analysis issues for the Python package.
[group('Downstream')]
[working-directory: 'python']
fix-python:
  uv run --no-project --with-requirements requirements-fmt.txt -- ufmt format src tests

# Test the Python package.
[group('Downstream')]
[working-directory: 'python']
test-python DOTSLASH_VERSION="latest":
  uv run --reinstall --isolated --no-editable --with pytest pytest

# Build the Python distributions.
[group('Downstream')]
[working-directory: 'python']
build-python DOTSLASH_VERSION="latest":
  uv build
