Skip to content
Merged
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
19 changes: 19 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# SPDX-FileCopyrightText: Copyright (c) 2026, Jared W. Cook
# SPDX-License-Identifier: AGPL-3.0-or-later
# Build context is limited to the files required to install dependencies.
**
!pyproject.toml
!README.md
!LICENSE.md
!hooks/
!hooks/**
hooks/**/__pycache__/
hooks/**/*.pyc
!docker/
!docker/toolchain.Dockerfile
!docker/toolchain-entrypoint.sh
!docker/constraints.txt
!docs/
!docs/jekyll/
!docs/jekyll/Gemfile
!docs/jekyll/Gemfile.lock
78 changes: 78 additions & 0 deletions .github/workflows/container-toolchain.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# SPDX-FileCopyrightText: Copyright (c) 2026, Jared W. Cook
# SPDX-License-Identifier: AGPL-3.0-or-later
---
name: Container Development Toolchain

on: [push, pull_request, workflow_dispatch]

permissions:
contents: read

jobs:
toolchain:
name: Container build and hook acceptance
runs-on: ubuntu-24.04
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v7
with:
fetch-depth: 0
persist-credentials: false

- name: Build the pinned toolchain
run: make TOOLCHAIN=container python-install

- name: Test the project without host Python
run: make TOOLCHAIN=container test

- name: Build documentation and generate the changelog
run: make TOOLCHAIN=container build-docs changelog

- name: Install and exercise the real Git hooks
run: |
make TOOLCHAIN=container pre-commit-init
git hook run pre-commit
message="$(git rev-parse --git-path COMMIT_EDITMSG)"
printf '%s\n' 'feat: add container toolchain' > "$message"
git hook run commit-msg -- "$message"
printf '%s\n' 'not a conventional commit' > "$message"
if git hook run commit-msg -- "$message" > .git/container-invalid-message.log 2>&1; then
echo "Invalid commit message was accepted." >&2
exit 1
fi
cat .git/container-invalid-message.log
grep -E 'Conventional Commit.*Failed' .git/container-invalid-message.log
printf '%s\n' 'feat: add hte toolchain' > "$message"
if git hook run commit-msg -- "$message" > .git/container-invalid-spelling.log 2>&1; then
echo "Misspelled commit message was accepted." >&2
exit 1
fi
cat .git/container-invalid-spelling.log
grep -E 'cspell.*Failed' .git/container-invalid-spelling.log

- name: Reject invalid staged source through the real hook
run: |
fixture=container-hook-invalid-fixture.yaml
test ! -e "$fixture"
printf '%s\n' 'invalid: [' > "$fixture"
git add -- "$fixture"
trap 'git restore --staged -- "$fixture"; rm -- "$fixture"' EXIT
if git hook run pre-commit > .git/container-invalid-hook.log 2>&1; then
echo "Invalid staged YAML was accepted." >&2
exit 1
fi
cat .git/container-invalid-hook.log
grep -E 'check yaml.*Failed' .git/container-invalid-hook.log

- name: Verify failure propagation and file ownership
run: |
if scripts/toolchain.sh run false; then
echo "The toolchain swallowed an error." >&2
exit 1
fi
test -z "$(find . -uid 0 -print -quit)"
project="cc-toolchain-$(printf '%s' "$(pwd -P)" | sha256sum | cut -c1-12)"
test -z "$(docker network ls --filter "name=^${project}_default$" --format '{{.Name}}')"
scripts/toolchain.sh run true
test -z "$(docker network ls --filter "name=^${project}_default$" --format '{{.Name}}')"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ __pycache__/
.pytest_cache/
.ruff_cache/
.venv/
.venv.backup.*/
dist/
# =========================================
## Default Ignores #
Expand Down
2 changes: 2 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
extends: default
ignore:
- .venv
- .venv.backup.*
- .git
- changelogs
- '{{ cookiecutter.project_slug }}'

Check warning on line 25 in .yamllint

View workflow job for this annotation

GitHub Actions / jinja2-lint

25:5 [quoted-strings] string value is not quoted with double quotes

Check warning on line 25 in .yamllint

View workflow job for this annotation

GitHub Actions / jinja2-lint

25:5 [quoted-strings] string value is not quoted with double quotes

rules:
line-length:
Expand Down
28 changes: 25 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
TOOLCHAIN ?= native
ifeq ($(TOOLCHAIN),container)
include docker/toolchain.mk
else
# --------------------------------------------------
# ⚙️ Environment Settings
# --------------------------------------------------
Expand Down Expand Up @@ -130,15 +134,26 @@ DEV_DOCS := .[docs]
# 🐍 Python Commands (venv, activate, pip)
# --------------------------------------------------
PYTHON_CMD := python3.11
ifeq ($(TOOLCHAIN_CONTAINER),1)
VENV_DIR := /opt/venv
CI := 1
RUBY_INSTALL_OVERRIDE := RUBY_INSTALL="bundle check"
else
VENV_DIR := $(PROJECT_ROOT)/.venv
endif
ACTIVATE := source $(VENV_DIR)/bin/activate
PYTHON := $(ACTIVATE) && $(PYTHON_CMD)
# --------------------------------------------------
# 💎 Ruby Settings
# --------------------------------------------------
RUBY_VERSION := 3.3.0
ifeq ($(TOOLCHAIN_CONTAINER),1)
GEMFILE := /opt/jekyll/Gemfile
BUNDLE_PATH := /opt/bundle
else
GEMFILE := $(PROJECT_ROOT)/Gemfile
BUNDLE_PATH := $(PROJECT_ROOT)/vendor/bundle
endif
# --------------------------------------------------
# 💎 Ruby Commands (bundler)
# --------------------------------------------------
Expand Down Expand Up @@ -217,7 +232,10 @@ BUMPVERSION := $(ACTIVATE) && bump-my-version
# Finds files of a given extension or "*" (all files) under a directory,
# skipping VENV_DIR and template markers like {{ }}.
define get_files_by_extension
find $(1) -name "$(2)" \
find "$(1)" \
-type d \( -name ".git" -o -name ".venv" -o -name ".venv.backup.*" \
-o -name "node_modules" -o -name "_site" \) -prune -o \
-type f -name "$(2)" \
! -path "$(VENV_DIR)/*" \
! -path "$(RENDERED_VENV_DIR)/*" \
! -path "*{{*" \
Expand Down Expand Up @@ -307,7 +325,7 @@ nutrimatic-readme: ## Automated documentation assistant for Jinja and Jekyll tem

jekyll-build: ## A Ruby-based static site generator for project documentation.
$(AT)echo "Running 🚀 Building Jekyll site in $(DOCS_DIR)..."
$(AT)$(JEKYLL) -j1 all
$(AT)$(JEKYLL) -j1 all $(RUBY_INSTALL_OVERRIDE)
$(AT)echo "✅ Jekyll build complete!"

jekyll-serve: ## A Ruby-based static site generator for project documentation.
Expand Down Expand Up @@ -642,7 +660,7 @@ pre-release:
# 📚 Documentation (Jekyll + nutrimatic)
# --------------------------------------------------
ruby-install:
$(AT)$(MAKE) -C "$(JEKYLL_DIR)" ruby-install
$(AT)$(MAKE) -C "$(JEKYLL_DIR)" ruby-install $(RUBY_INSTALL_OVERRIDE)
jekyll: jekyll-build
nutrimatic-readme: jekyll-build
run-docs: jekyll-serve
Expand All @@ -663,7 +681,9 @@ clean-build:
$(AT)echo "🧹 Cleaning build artifacts..."
$(AT)rm -rf build dist *.egg-info
$(AT)for dir in "$(SRC_DIR)" "$(TEST_DIR)"; do if [ -d "$$dir" ]; then find "$$dir" -name "__pycache__" -type d -exec rm -rf {} +; fi; done
ifneq ($(TOOLCHAIN_CONTAINER),1)
$(AT)-[ -d "$(VENV_DIR)" ] && rm -r $(VENV_DIR)
endif
$(AT)echo "🧹 Cleaned build artifacts."

clean: clean-docs clean-build
Expand Down Expand Up @@ -707,3 +727,5 @@ help: ## Show this help message.
$(AT)printf "\n\033[1mOptions:\033[0m\n"
$(AT)printf " \033[36m%-30s\033[0m %s\n" "V=1" "Enable verbose output (show all commands)"
$(AT)printf " \033[36m%-30s\033[0m %s\n" "make -s" "Run completely silently (suppress output)"

endif # TOOLCHAIN
3 changes: 2 additions & 1 deletion changelogs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
- Import shared spelling dictionary
- Add containerized documentation preview
- Generate reviewed Python release preparation
- Prepare reviewed Python generator releases
- Add container development toolchain (#33)

### 🐛 Fixed

Expand All @@ -25,6 +25,7 @@
- Standardize generated CLA workflow configuration
- Update shared spelling dictionary
- Update shared spelling dictionary
- Keep generated readme paths portable (#31)

### 🧪 Tests

Expand Down
3 changes: 2 additions & 1 deletion changelogs/releases/v0.1.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
- Import shared spelling dictionary
- Add containerized documentation preview
- Generate reviewed Python release preparation
- Prepare reviewed Python generator releases
- Add container development toolchain (#33)

### 🐛 Fixed

Expand All @@ -25,6 +25,7 @@
- Standardize generated CLA workflow configuration
- Update shared spelling dictionary
- Update shared spelling dictionary
- Keep generated readme paths portable (#31)

### 🧪 Tests

Expand Down
31 changes: 31 additions & 0 deletions compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# SPDX-FileCopyrightText: Copyright (c) 2026, Jared W. Cook
# SPDX-License-Identifier: AGPL-3.0-or-later
---
services:
toolchain:
build:
context: "."
dockerfile: "docker/toolchain.Dockerfile"
init: true
user: "${LOCAL_UID:?Run scripts/toolchain.sh}:${LOCAL_GID:?Run scripts/toolchain.sh}"
working_dir: "${TOOLCHAIN_ROOT:?Run scripts/toolchain.sh}"
read_only: true
cap_drop:
- "ALL"
security_opt:
- "no-new-privileges:true"
tmpfs:
- "/tmp:exec,mode=1777"
volumes:
- type: "bind"
source: "."
target: "${TOOLCHAIN_ROOT:?Run scripts/toolchain.sh}"
environment:
HOME: "/tmp/toolchain-home"
PRE_COMMIT_HOME: "${TOOLCHAIN_ROOT}/.git/container-toolchain-cache"
TOOLCHAIN: "native"
TOOLCHAIN_CONTAINER: "1"
CI: "1"
BUNDLE_FROZEN: "true"
GIT_TERMINAL_PROMPT: "0"
command: ["make", "test"]
Loading
Loading