Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Pre-Commit

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

permissions:
contents: write
pull-requests: write

jobs:
pre-commit:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v6.0.1

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.14"

- name: Add uv
uses: astral-sh/setup-uv@v7

- name: Install dependencies
run: uv sync --dev

- name: Run pre-commit
uses: pre-commit/action@v3.0.0
73 changes: 73 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: PyTest
on:
workflow_call:
workflow_dispatch:
push:
branches:
- main
pull_request:
paths:
- ".github/workflows/test.yml"
- "render_engine_api/**"
- "tests/**"
- "pyproject.toml"
- "requirements.txt"

jobs:
gen-coverage-badge:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: astral-sh/setup-uv@v7
with:
python-version: "3.14"
enable-cache: true

- name: run coverage and generate cov-report
run: |
uv run --dev pytest --cov-report xml
- name: genbadge coverage
run: |
uvx --with "genbadge[coverage]" genbadge coverage -i coverage.xml
- name: Commit Badge
uses: stefanzweifel/git-auto-commit-action@v7
with:
commit_message: Update coverage badge [skip ci]
file_pattern: coverage.svg

test-against-python-matrix:
# Only test all the supported versions when a pull request is made or the workflow is called
if: ${{github.event_name == 'workflow_call'}} || ${{github.event_name == 'pull_request'}}
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]
fail-fast: true
steps:
- uses: actions/checkout@v6.0.1
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python-version }}
enable-cache: true # caching dependencies
- name: Run tests
run: |
uv run --dev pytest tests

test-against-latest-os:
# Always run against the latest version on both Windows, Linux, MacOS
if: github.event.pull_request.user.login != 'dependabot[bot]'
strategy:
matrix:
os: [windows-latest, macos-latest]
fail-fast: true
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6.0.1
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
python-version: "3.14"
enable-cache: true # caching dependencies
- name: run tests
run: uv run --dev pytest tests
64 changes: 32 additions & 32 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.15.1
hooks:
# Run the linter.
- id: ruff-check
args: [ --fix ]
# Run the formatter.
- id: ruff-format
- repo: https://github.com/allganize/ty-pre-commit
# Ty version.
rev: v0.0.17
hooks:
# Run the type checker.
- id: ty-check
- repo: https://github.com/DavidAnson/markdownlint-cli2
rev: v0.6.0
hooks:
- id: markdownlint-cli2
- repo: local
hooks:
- id: deptry
name: deptry
entry: uv run deptry .
language: system
always_run: true
pass_filenames: false
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.15.4
hooks:
# Run the linter.
- id: ruff-check
args: [--fix]
# Run the formatter.
- id: ruff-format
- repo: https://github.com/allganize/ty-pre-commit
# Ty version.
rev: v0.0.20
hooks:
# Run the type checker.
- id: ty-check
- repo: https://github.com/DavidAnson/markdownlint-cli2
rev: v0.21.0
hooks:
- id: markdownlint-cli2
- repo: local
hooks:
- id: deptry
name: deptry
entry: uv run deptry .
language: system
always_run: true
pass_filenames: false
38 changes: 38 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Contributing to the Render Engine Projects

Render Engine API is a unifying API layer for managing and working with [render-engine][render-engine].
The [CLI][cli], [TUI][tui], and custom tools can use this module as a shared API layer. Please refer to
the main [CONTRIBUTING.md](https://github.com/render-engine/render-engine/blob/main/CONTRIBUTING.md)
for more details on how to contribute.

## Render Engine API Specific Topics

Render Engine API is a `uv` based project. For more information on installing `uv` and using it
please see the [uv documentation](https://docs.astral.sh/uv/#installation). To get started, fork
this repository and check out your fork.

```shell
git clone <url to fork>
```

Once you have checked out the repository, run `uv sync --dev` and then activate the `venv` that was
created:

```shell
uv sync --dev
source .venv/bin/activate
```

Once you have done this you will be in the virtual environment and ready to work. It is recommended
that you do a local, editable install of the API in your virtual environment so that you can easily
work with the changes you have made.

```shell
uv pip install -e .
```

This will allow you to test your changes locally.

[render-engine]: https://github.com/render-engine/render-engine
[cli]: https://github.com/render-engine/render-engine-cli
[tui]: https://github.com/render-engine/render-engine-tui
81 changes: 81 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Render Engine API - Just recipes
# Run tasks with: just <task-name>

DEFAULT_PYTHON_VERSION := "3.14"

# Default recipe to display available commands
default:
@just --list

# Sync dependencies using uv
sync:
uv sync --dev

# Run pytest
test *FLAGS='':
pytest {{ DEFAULT_PYTHON_VERSION }} {{ FLAGS }}

# Install pre-commit hooks
pre-commit-install:
uvx pre-commit install

# Run pre-commit on all files
pre-commit:
uvx pre-commit run --all-files

# Run pre-commit on staged files (default git behavior)
pre-commit-run:
uvx pre-commit run

# Update pre-commit hook versions
pre-commit-update:
uvx pre-commit autoupdate

# Run tests in arbitrary Python version.
pytest VERSION *FLAGS='':
uv run -p {{ VERSION }} --dev pytest {{ FLAGS }}

# Run pytest with coverage report (defaults to XML)
test-cov-report REPORT='xml':
uv run --dev pytest --cov-report={{ REPORT }}

# Run all nox sessions
nox:
uvx nox

# Run ruff linter without fixing
lint DIRECTORY='.':
uvx ruff check {{ DIRECTORY }}

# Run ruff linter with auto-fix
lint-fix DIRECTORY='.':
uvx ruff check --fix {{ DIRECTORY }}

# Run ruff formatter as check
format DIRECTORY='.':
uvx ruff format --check {{ DIRECTORY }}

# Run ruff formatter and fix issues
format-fix DIRECTORY='.':
uvx ruff format --check {{ DIRECTORY }}

ruff: lint format

# Run both linter and formatter, fixing issues.
ruff-fix DIRECTORY='.':
@# Prefacing with `-` to ignore any errors that might be fixed by formatting.
-uvx ruff check --fix {{ DIRECTORY }}
uvx ruff format {{ DIRECTORY }}
uvx ruff check {{ DIRECTORY }}
@echo "\nEverything looks good!"

# Run ty type checker
ty PATH='src':
uv run ty check {{ PATH }} # For the moment we have way too many issues in ty so not having it fail.

# Generate coverage badge
badge: (test-cov-report 'xml')
uvx --with "genbadge[coverage]" genbadge coverage -i coverage.xml

# Run full CI workflow (sync, lint, test, badge)
ci: sync nox ruff ty badge