Skip to content

Instantly share code, notes, and snippets.

@ScriptAutomate
Created March 6, 2026 09:01
Show Gist options
  • Select an option

  • Save ScriptAutomate/984fbe5239c66aa4010e100668bbf455 to your computer and use it in GitHub Desktop.

Select an option

Save ScriptAutomate/984fbe5239c66aa4010e100668bbf455 to your computer and use it in GitHub Desktop.
Example justfile with support for just-based pre-commit and running in devcontainer
# If USE_LOCAL_DEV_CONTAINER='true', use a local container service
# This env var should always be false when inside of CI, and a CI
# system should be preconfigured to run within a container
use_dev_container := env('USE_LOCAL_DEV_CONTAINER', 'false')
docker_prefix := if use_dev_container == "true" { "podman container run --rm -v $(pwd):/root/taskrpg -w /root/taskrpg localhost/taskrpg:latest" } else { "" }
# Build Python package
[group('uv')]
build: sync sbom-export
{{ docker_prefix }} uv build
# Build local dev container (required if USE_LOCAL_DEV_CONTAINER='true')
[group('container-management')]
build-container:
podman build -t taskrpg -f .devcontainer/Dockerfile .
# Run uv sync
[group('uv')]
sync:
{{ docker_prefix }} uv sync
# Run any uv command
[group('uv')]
uv *args:
{{ docker_prefix }} uv {{ args }}
# Run all linting and formatting (auto-fixes)
[group('uv')]
lint: sync
just --fmt --unstable
{{ docker_prefix }} uv run ruff check . --fix
{{ docker_prefix }} uv run mypy .
# Export Software Bill Of Materials (SBOM) (CycloneDX)
[group('sbom')]
[group('uv')]
sbom-export:
{{ docker_prefix }} mkdir -p dist
{{ docker_prefix }} uv export --format cyclonedx1.5 --preview-features sbom-export > dist/$({{ docker_prefix }} uv version | sed 's: :-:')-dependency-cyclonedx.json
# Run pytest
[group('uv')]
test *args: sync
{{ docker_prefix }} uv run pytest
# Set and enable pre-commit in repo to be 'just lint build'
[group('pre-commit')]
@enable-pre-commit:
echo '#!/bin/sh\n\n# Prevent commit if '\''just lint build'\'' recipe fails.\nif ! just lint build; then\n echo "Pre-commit check failed!"\n exit 1\nfi' > .git/hooks/pre-commit
chmod u+x .git/hooks/pre-commit
@echo "Pre-commit hook enabled."
# Disable pre-commit in repo
[group('pre-commit')]
@disable-pre-commit:
chmod u-x .git/hooks/pre-commit
@echo "Pre-commit hook disabled."
# Scan sbom with Grype
[group('sbom')]
sbom-scan:
{{ docker_prefix }} grype dist/*.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment