python-project-generator 3.2.2

Generates a Python project structure.
name: Testing

on:
  push:
    branches:
      - main
  pull_request:
env:
  CARGO_TERM_COLOR: always
  RUST_BACKTRACE: 1
  RUSTFLAGS: "-D warnings"
  WORKING_DIR: "my-project"
  MIN_PYTHON_VERSION: "3.10"
  CI: true # For insta
jobs:
  clippy:
    name: Clippy
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - name: install Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          components: clippy
      - name: Cache dependencies
        uses: Swatinem/rust-cache@v2.9.1
      - name: Run cargo clippy
        run: cargo clippy --all-targets -- --deny warnings
  clippy-fastapi:
    name: clippy-fastapi
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - name: install Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          components: clippy
      - name: Cache dependencies
        uses: Swatinem/rust-cache@v2.9.1
      - name: Run cargo clippy
        run: cargo clippy --all-targets -F fastapi -- --deny warnings
  fmt:
    name: Rustfmt
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - name: install Rust
        with:
          components: rustfmt
        uses: dtolnay/rust-toolchain@stable
      - name: Cache dependencies
        uses: Swatinem/rust-cache@v2.9.1
      - name: Run cargo fmt
        run: cargo fmt --all -- --check
  test:
    name: Tests
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, windows-latest]
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v6
      - name: install Rust
        uses: dtolnay/rust-toolchain@stable
      - name: Cache dependencies
        uses: Swatinem/rust-cache@v2.9.1
      - name: Run cargo test
        run: cargo test --locked
  test-fastapi:
    name: test-fastapi
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, windows-latest]
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v6
      - name: install Rust
        uses: dtolnay/rust-toolchain@stable
      - name: Cache dependencies
        uses: Swatinem/rust-cache@v2.9.1
      - name: Run cargo test
        run: cargo test --locked -F fastapi
  uv-linting:
    strategy:
      fail-fast: false
      matrix:
        project_type: ["application", "lib"]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - name: install Rust
        uses: dtolnay/rust-toolchain@stable
      - name: Cache Rust dependencies
        uses: Swatinem/rust-cache@v2.9.1
      - name: Install uv on Linux
        if: runner.os != 'Windows'
        run: curl -LsSf https://astral.sh/uv/install.sh | sh
      - name: Install uv on Windows
        if: runner.os == 'Windows'
        run: powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
      - name: Set up Python
        uses: actions/setup-python@v6
        with:
          python-version: "${{ env.MIN_PYTHON_VERSION }}"
      - name: Build package
        run: cargo build --release
      - name: Run creation
        run: ./scripts/ci_run.sh ${{ matrix.project_type }} 1
      - name: MyPy
        working-directory: ${{ env.WORKING_DIR }}
        run: uv run mypy .
      - name: ruff check
        working-directory: ${{ env.WORKING_DIR }}
        run: uv run ruff check .
      - name: ruff format
        working-directory: ${{ env.WORKING_DIR }}
        run: uv run ruff format --check .
  uv-test:
    strategy:
      fail-fast: false
      matrix:
        project_type: ["application", "lib"]
        os: [ubuntu-latest, windows-latest]
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v6
      - name: install Rust
        uses: dtolnay/rust-toolchain@stable
      - name: Cache Rust dependencies
        uses: Swatinem/rust-cache@v2.9.1
      - name: Install uv on Linux
        if: runner.os != 'Windows'
        run: curl -LsSf https://astral.sh/uv/install.sh | sh
      - name: Install uv on Windows
        if: runner.os == 'Windows'
        run: powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
      - name: Set up Python
        uses: actions/setup-python@v6
        with:
          python-version: "3.11"
      - name: Build package
        run: cargo build --release
      - name: Run creation
        run: ./scripts/ci_run.sh ${{ matrix.project_type }} 1
        shell: bash
      - name: Prek check
        working-directory: ${{ env.WORKING_DIR }}
        run: |
          git add .
          uv run prek run --all-files
      - name: Test with pytest
        working-directory: ${{ env.WORKING_DIR }}
        if: matrix.project_type == 'application'
        run: uv run pytest
  poetry-linting:
    strategy:
      fail-fast: false
      matrix:
        project_type: ["application", "lib"]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - name: install Rust
        uses: dtolnay/rust-toolchain@stable
      - name: Cache Rust dependencies
        uses: Swatinem/rust-cache@v2.9.1
      - name: Install Poetry
        run: pipx install poetry
      - name: Configure poetry
        run: |
          poetry config virtualenvs.create true
          poetry config virtualenvs.in-project true
      - name: Set up Python
        uses: actions/setup-python@v6
        with:
          python-version: "${{ env.MIN_PYTHON_VERSION }}"
      - name: Build package
        run: cargo build --release
      - name: Run creation
        run: ./scripts/ci_run.sh ${{ matrix.project_type }} 2
      - name: MyPy
        working-directory: ${{ env.WORKING_DIR }}
        run: poetry run mypy .
      - name: ruff check
        working-directory: ${{ env.WORKING_DIR }}
        run: poetry run ruff check .
      - name: ruff format
        working-directory: ${{ env.WORKING_DIR }}
        run: poetry run ruff format --check .
  poetry-test:
    strategy:
      fail-fast: false
      matrix:
        project_type: ["application", "lib"]
        os: [ubuntu-latest, windows-latest]
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v6
      - name: install Rust
        uses: dtolnay/rust-toolchain@stable
      - name: Cache Rust dependencies
        uses: Swatinem/rust-cache@v2.9.1
      - name: Install Poetry
        run: pipx install poetry
      - name: Configure poetry
        run: |
          poetry config virtualenvs.create true
          poetry config virtualenvs.in-project true
      - name: Set up Python
        uses: actions/setup-python@v6
        with:
          python-version: "3.11"
      - name: Build package
        run: cargo build --release
      - name: Run creation
        run: ./scripts/ci_run.sh ${{ matrix.project_type }} 2
        shell: bash
      - name: prek check
        working-directory: ${{ env.WORKING_DIR }}
        run: |
          git add .
          poetry run prek run --all-files
      - name: Test with pytest
        working-directory: ${{ env.WORKING_DIR }}
        run: poetry run pytest
  pyo3-linting:
    strategy:
      fail-fast: false
      matrix:
        project_type: ["application", "lib"]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - name: Install Just
        uses: taiki-e/install-action@just
      - name: install Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          components: clippy, rustfmt
      - name: Cache Rust dependencies
        uses: Swatinem/rust-cache@v2.9.1
      - name: Install uv on Linux
        if: runner.os != 'Windows'
        run: curl -LsSf https://astral.sh/uv/install.sh | sh
      - name: Install uv on Windows
        if: runner.os == 'Windows'
        run: powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
      - name: Set up Python
        uses: actions/setup-python@v6
        with:
          python-version: "${{ env.MIN_PYTHON_VERSION }}"
      - name: Build package
        run: cargo build --release
      - name: Run creation
        run: ./scripts/ci_run.sh ${{ matrix.project_type }} 3
      - name: MyPy
        working-directory: ${{ env.WORKING_DIR }}
        run: just mypy
      - name: ruff check
        working-directory: ${{ env.WORKING_DIR }}
        run: just ruff-check
      - name: ruff format
        working-directory: ${{ env.WORKING_DIR }}
        run: uv run ruff format --check .
      - name: Generated Project Clippy
        working-directory: ${{ env.WORKING_DIR }}
        run: just clippy
      - name: Generated Project Fmt
        working-directory: ${{ env.WORKING_DIR }}
        run: just fmt
  pyo3-python-test:
    strategy:
      fail-fast: false
      matrix:
        project_type: ["application", "lib"]
        os: [ubuntu-latest, windows-latest]
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v6
      - name: install Rust
        uses: dtolnay/rust-toolchain@stable
      - name: Cache Rust dependencies
        uses: Swatinem/rust-cache@v2.9.1
      - name: Install uv on Linux
        if: runner.os != 'Windows'
        run: curl -LsSf https://astral.sh/uv/install.sh | sh
      - name: Install uv on Windows
        if: runner.os == 'Windows'
        run: powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
      - name: Set up Python
        uses: actions/setup-python@v6
        with:
          python-version: "3.11"
      - name: Build package
        run: cargo build --release
      - name: Run creation
        run: ./scripts/ci_run.sh ${{ matrix.project_type }} 3
        shell: bash
      - name: Compile Rust
        working-directory: ${{ env.WORKING_DIR }}
        run: |
          uv run maturin build
      - name: prek check
        working-directory: ${{ env.WORKING_DIR }}
        run: |
          git add .
          uv run prek run --all-files
      - name: Test with pytest
        working-directory: ${{ env.WORKING_DIR }}
        run: uv run pytest
  setuptools-linting:
    strategy:
      fail-fast: false
      matrix:
        project_type: ["application", "lib"]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - name: install Rust
        uses: dtolnay/rust-toolchain@stable
      - name: Cache Rust dependencies
        uses: Swatinem/rust-cache@v2.9.1
      - name: Set up Python
        uses: actions/setup-python@v6
        with:
          python-version: "${{ env.MIN_PYTHON_VERSION }}"
      - name: Build package
        run: cargo build --release
      - name: Run creation
        run: |
          ./scripts/ci_run.sh ${{ matrix.project_type }} 4
      - name: MyPy
        working-directory: ${{ env.WORKING_DIR }}
        run: $PYTHON -m mypy .
        shell: bash
        env:
          PYTHON: ${{ runner.os == 'Windows' && '.venv/Scripts/python.exe' || '.venv/bin/python' }}
      - name: ruff check
        working-directory: ${{ env.WORKING_DIR }}
        run: $PYTHON -m ruff check .
        shell: bash
        env:
          PYTHON: ${{ runner.os == 'Windows' && '.venv/Scripts/python.exe' || '.venv/bin/python' }}
      - name: ruff format
        working-directory: ${{ env.WORKING_DIR }}
        run: $PYTHON -m ruff format --check .
        shell: bash
        env:
          PYTHON: ${{ runner.os == 'Windows' && '.venv/Scripts/python.exe' || '.venv/bin/python' }}
  setuptools-test:
    strategy:
      fail-fast: false
      matrix:
        project_type: ["application", "lib"]
        os: [ubuntu-latest, windows-latest]
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v6
      - name: install Rust
        uses: dtolnay/rust-toolchain@stable
      - name: Cache Rust dependencies
        uses: Swatinem/rust-cache@v2.9.1
      - name: Set up Python
        uses: actions/setup-python@v6
        with:
          python-version: "${{ env.MIN_PYTHON_VERSION }}"
      - name: Build package
        run: cargo build --release
      - name: Run creation
        run: ./scripts/ci_run.sh ${{ matrix.project_type }} 4
        shell: bash
      - name: prek check
        working-directory: ${{ env.WORKING_DIR }}
        run: |
          git add .
          $PREK run --all-files
        shell: bash
        env:
          PREK: ${{ runner.os == 'Windows' && '.venv/Scripts/prek.exe' || '.venv/bin/prek' }}
      - name: Test with pytest
        working-directory: ${{ env.WORKING_DIR }}
        if: matrix.project_type == 'application'
        run: $PYTHON -m pytest
        shell: bash
        env:
          PYTHON: ${{ runner.os == 'Windows' && '.venv/Scripts/python.exe' || '.venv/bin/python' }}