commit d7800f4d822d25a6464bed2c36399cb043cf4df6 Author: Waylon S. Walker Date: Sat Nov 22 21:48:11 2025 -0600 wip diff --git a/README.md b/README.md new file mode 100644 index 0000000..a15c47d --- /dev/null +++ b/README.md @@ -0,0 +1,155 @@ +# Just Build System + +A modular build system using Just that supports container builds, Python tooling, and more. + +## Installation + +There are several ways to use this build system: + +### Method 1: Global Installation with Symlinks + +1. Clone this repository to a permanent location: + ```bash + git clone https://github.com/yourusername/wjust ~/.wjust + ``` + +2. In your project, create the module directories and symlink the justfiles: + ```bash + # Create module directories + mkdir -p container python + + # Create symlinks to the global justfiles + ln -s ~/.wjust/container/justfile container/justfile + ln -s ~/.wjust/python/justfile python/justfile + ``` + +3. Create your project's `justfile`: + ```makefile + # Import modules + mod container + mod python + + # Override or add project-specific recipes here + default: + @just --list + ``` + +4. Create required files: + ```bash + # For container module + echo "registry.example.com/myproject" > container/name + + # Optional: Set version + echo "0.1.0" > version + # Or use __about__.py with __version__ = "0.1.0" + ``` + +### Method 2: Local Copy (Traditional) + +Copy the entire module directories to your project: +```bash +cp -r ~/.wjust/container ~/.wjust/python . +``` + +Then create your `justfile` as shown above. + +### Method 3: Remote Import (Advanced) + +For advanced users who want to pull updates directly from the repository: + +```bash +# Create a script to update modules +cat > update-just-modules.sh << 'EOF' +#!/bin/bash +REPO="https://raw.githubusercontent.com/yourusername/wjust/main" +mkdir -p {container,python} +curl -o container/justfile "$REPO/container/justfile" +curl -o python/justfile "$REPO/python/justfile" +EOF + +chmod +x update-just-modules.sh +``` + +Then run `./update-just-modules.sh` whenever you want to update the modules. + +## Quick Start + +1. Choose an installation method from above +2. Run `just` to see available commands: + ```bash + just + + Available recipes: + container ... # Container management + python ... # Python tools + ``` + +## Container Module + +The container module provides standardized container building and deployment. + +### Setup + +1. Create a `container/name` file with your container registry path: + ``` + registry.example.com/myproject + ``` + +2. Version will be detected from (in order): + - Any `__about__.py` file containing `__version__ = "x.y.z"` + - A `version` file in the project root + - Defaults to "0.0.0" if neither exists + +3. Create your `container/Containerfile`: + ```dockerfile + FROM python:3.11 + # Add your container configuration + ``` + +### Usage + +```bash +# Show available commands +just + +# Build container +just container build + +# Push container to registry +just container deploy +``` + +### Customization + +The container module provides these recipes: +- `build`: Builds the container with version tag +- `deploy`: Pushes the container to the registry + +## Python Module + +The Python module provides linting with Ruff. + +### Usage + +```bash +# Run linter +just python lint + +# Run linter with auto-fix +just python lint-fix +``` + +## Adding New Modules + +1. Create a new directory for your module +2. Add a `justfile` in the module directory +3. Import it in your root `justfile` with `mod mymodule` + +## Environment Variables + +- `VERSION`: Automatically set from `__about__.py` or `version` file +- `CONTAINER_NAME`: Set from `container/name` file + +## Contributing + +Feel free to submit issues and pull requests for additional modules or improvements. diff --git a/container/Containerfile b/container/Containerfile new file mode 100644 index 0000000..a130e9c --- /dev/null +++ b/container/Containerfile @@ -0,0 +1,13 @@ +FROM ubuntu:noble + +ENV PATH="/root/.local/bin:$PATH" +ENV VIRTUAL_ENV="/opt/venv" +ENV PATH="$VIRTUAL_ENV/bin:$PATH" + +RUN apt-get update && apt-get install -y git curl +RUN curl -LsSf https://astral.sh/uv/install.sh | sh +RUN uv python install 3.13 +RUN uv venv $VIRTUAL_ENV +RUN uv pip install hatch +RUN curl https://i.wayl.one/casey/just | bash && mv just /usr/local/bin + diff --git a/container/justfile b/container/justfile new file mode 100644 index 0000000..808e469 --- /dev/null +++ b/container/justfile @@ -0,0 +1,68 @@ +# container management +set working-directory := '.' +set shell := ["bash", "-c"] +set quiet + +# Read container name and version +container_name := ` +cd $JUST_WORKING_DIRECTORY +if [[ -f container/name ]]; then cat container/name; else echo "NONAME"; fi +` + +version := ` +cd $JUST_WORKING_DIRECTORY +ABOUT_FILE=$(rg -l "__version__" --glob "**/__about__.py" 2>/dev/null | head -n 1) || true +if [[ -n "$ABOUT_FILE" ]] && [[ -f "$ABOUT_FILE" ]]; then + rg -oP "(?<=__version__ = ['\"])[^'\"]+" "$ABOUT_FILE" +elif [[ -f "version" ]]; then + cat version +else + echo "0.0.0" +fi +` + + + +[group('container')] +[private] +@default: check + #!/usr/bin/env bash + cd $JUST_WORKING_DIRECTORY + echo $PWD + echo + echo {{BOLD}}just container{{NORMAL}} + echo {{MAGENTA}}{{container_name}}{{WHITE}}:{{GREEN}}{{version}}{{NORMAL}} + +[group('container')] +[private] +check: + #!/usr/bin/env bash + cd $JUST_WORKING_DIRECTORY + [[ -f container/Containerfile ]] || echo "{{RED}}WARNING: {{NORMAL}}Containerfile not found" + + +# build the container +[group('container')] +build: + @echo "Building {{container_name}}:{{version}}" + @# @podman build \ + @# -t {{container_name}}:{{version}} \ + @# -f container/Containerfile . + +# push the container +[group('container')] +@deploy: + @podman push {{container_name}} + @podman push {{container_name}}:{{version}} + +# init container workflow +[no-cd] +[group('container')] +init: + #!/usr/bin/env bash + [[ -d container ]] || mkdir container + export project_name=$(basename $(pwd)) + [[ -f version ]] || echo "version = '0.0.0'" > version + [[ -f container/name ]] || echo $project_name > container/name + [[ -f container/Containerfile ]] || echo "FROM ubuntu" > container/Containerfile + diff --git a/container/name b/container/name new file mode 100644 index 0000000..662e708 --- /dev/null +++ b/container/name @@ -0,0 +1 @@ +registry.wayl.one/wjust diff --git a/container/repository b/container/repository new file mode 100644 index 0000000..e5bf7ed --- /dev/null +++ b/container/repository @@ -0,0 +1 @@ +registry.wayl.one diff --git a/justfile b/justfile new file mode 100644 index 0000000..f20d198 --- /dev/null +++ b/justfile @@ -0,0 +1,62 @@ +# Main justfile +set shell := ["bash", "-uc"] +set quiet +set allow-duplicate-recipes := true + + +# wjust-dir := "~/.wjust" +wjust-dir := "~/git/wjust" + +# container management commands, run `just container` to see all subcommands +mod container + +# mod python + +# mod container "{{wjust-dir}}/container/justfile" +# mod container "~/git/wjust/container/justfile" +# include "https://raw.githubusercontent.com/casey/just/refs/heads/master/justfile" +# include {{wjust-dir}}/container/justfile + + +[group('just')] +[private] +@default: + echo $PWD + @echo + @echo {{BOLD}}just{{NORMAL}} + @just --list + # @just container + +# fuzzy picker +[group('just')] +f: + just --list | fzf | xargs just + +pwd: + pwd + +get-version: + #!/usr/bin/env bash + if [[ -f "version" ]]; then \ + export PROJECT_VERSION=$(cat version); \ + elif ABOUT_FILE=$(rg -l "__version__" --glob "**/__about__.py" | head -n 1); then \ + export PROJECT_VERSION=$(rg -oP "(?<=__version__ = ['\"])[^'\"]+" "$ABOUT_FILE"); \ + else \ + echo "Version information not found!" >&2; \ + exit 1; \ + fi; \ + export VERSION=$PROJECT_VERSION + +version: get-version + #!/usr/bin/env bash + echo version is passed as $PROJECT_VERSION + +# Run Ruff linter on Python files +[group('python')] +lint: + uv run ruff check . + +# Run Ruff with auto-fix +[group('python')] +lint-fix: + uv run ruff check --fix . diff --git a/py_project/.__about__.py b/py_project/.__about__.py new file mode 100644 index 0000000..9b3a5af --- /dev/null +++ b/py_project/.__about__.py @@ -0,0 +1,4 @@ +# SPDX-FileCopyrightText: 2023-present Waylon S. Walker +# +# SPDX-License-Identifier: MIT +__version__ = "0.2.1" diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..45be3f2 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,42 @@ +[tool.ruff] +# Enable pycodestyle (`E`), Pyflakes (`F`), and import sorting (`I`) +select = ["E", "F", "I"] +ignore = [] + +# Allow autofix for all enabled rules (when `--fix`) is provided. +fixable = ["A", "B", "C", "D", "E", "F", "I"] +unfixable = [] + +# Exclude a variety of commonly ignored directories. +exclude = [ + ".bzr", + ".direnv", + ".eggs", + ".git", + ".git-rewrite", + ".hg", + ".mypy_cache", + ".nox", + ".pants.d", + ".pytype", + ".ruff_cache", + ".svn", + ".tox", + ".venv", + "__pypackages__", + "_build", + "buck-out", + "build", + "dist", + "node_modules", + "venv", +] + +# Same as Black. +line-length = 88 + +# Allow unused variables when underscore-prefixed. +dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" + +# Assume Python 3.11 +target-version = "py311" diff --git a/python/justfile b/python/justfile new file mode 100644 index 0000000..c43115b --- /dev/null +++ b/python/justfile @@ -0,0 +1,30 @@ +set working-directory := '..' +set export +set shell := ["bash", "-uc"] + + +venv: + #!/usr/bin/env bash + [ -d .venv ] || uv venv + [ -f requirements.txt ] && uv pip install -r requirements.txt + source .venv/bin/activate + +clean: + rm -rf .venv + rm -rf **/*/__pycache__ + rm -rf **/*/*.pyc + rm -rf **/*/*.pyo + +install: venv + #!/usr/bin/env bash + uv pip install . + +check: venv + #!/usr/bin/env bash + which python + +ipython: venv + uv run ipython + +install-uv: + curl -LsSf https://astral.sh/uv/install.sh | sh diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..fb6c7ed --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +pandas diff --git a/vars/justfile b/vars/justfile new file mode 100644 index 0000000..e69de29 diff --git a/version b/version new file mode 100644 index 0000000..8acdd82 --- /dev/null +++ b/version @@ -0,0 +1 @@ +0.0.1