- Add runner_name variable to default, binary, and lifecycle verify playbooks - Update molecule target to test all 7 scenarios sequentially - Add molecule-docker and molecule-binary platform matrix targets - Disable checkmake maxbodylength rule to accommodate longer recipes
115 lines
6.5 KiB
Makefile
115 lines
6.5 KiB
Makefile
.PHONY: all setup install update lint ansible-lint makefile-lint lint-all test test-unit pytest-cov molecule molecule-docker molecule-binary molecule-all test-all clean
|
|
|
|
PYTHON := python3
|
|
VENV := .venv
|
|
BIN := $(VENV)/bin
|
|
CHECKMAKE := $(shell command -v checkmake 2>/dev/null || echo $(HOME)/go/bin/checkmake)
|
|
|
|
all: setup
|
|
|
|
setup: $(VENV)/bin/activate .env activate-scripts checkmake
|
|
$(BIN)/pip install -e ".[dev]"
|
|
$(BIN)/ansible-galaxy collection install -r ansible/requirements.yml
|
|
$(BIN)/pre-commit install
|
|
$(BIN)/pre-commit install --hook-type commit-msg
|
|
@echo "Setup complete. Activate the virtual environment with: source .venv/bin/activate"
|
|
|
|
.env:
|
|
@if [ ! -f .env ]; then \
|
|
cp .env.example .env; \
|
|
echo "Created .env from .env.example — please edit it with your credentials."; \
|
|
fi
|
|
|
|
$(VENV)/bin/activate:
|
|
$(PYTHON) -m venv $(VENV)
|
|
$(BIN)/pip install --upgrade pip setuptools wheel
|
|
|
|
activate-scripts: $(VENV)/bin/activate
|
|
@test -f activate.sh || (echo '#!/usr/bin/env bash' > activate.sh && echo 'source "$$(cd "$$(dirname "$${BASH_SOURCE[0]}")" && pwd)/.venv/bin/activate"' >> activate.sh && chmod +x activate.sh)
|
|
@test -f activate.fish || (echo '#!/usr/bin/env fish' > activate.fish && echo 'set -l script_dir (dirname (status --current-filename))' >> activate.fish && echo 'source "$$script_dir/.venv/bin/activate.fish"' >> activate.fish && chmod +x activate.fish)
|
|
@test -f activate.zsh || (echo '#!/usr/bin/env zsh' > activate.zsh && echo '0="$${ZERO:-$${0:#$$ZSH_ARGZERO}}"' >> activate.zsh && echo '0="$${$${(M)0:#/*}:-$$PWD/$$0}"' >> activate.zsh && echo 'source "$${0:A:h}/.venv/bin/activate"' >> activate.zsh && chmod +x activate.zsh)
|
|
|
|
checkmake:
|
|
@which checkmake >/dev/null 2>&1 || (which go >/dev/null 2>&1 && go install github.com/mrtazz/checkmake/cmd/checkmake@latest) || (echo "Warning: checkmake not installed. Install Go and run: go install github.com/mrtazz/checkmake/cmd/checkmake@latest" && exit 0)
|
|
|
|
install:
|
|
@if [ -z "$(HOST)" ]; then echo "HOST is required. Example: make install HOST=192.168.1.10"; exit 1; fi
|
|
$(BIN)/grm install $(HOST) $(if $(USER),--user $(USER),) $(if $(KEY),--key $(KEY),) $(if $(NAME),--name $(NAME),) $(if $(TOKEN),--token $(TOKEN),) $(if $(MODE),--mode $(MODE),) $(if $(ASK_BECOME_PASS),--ask-become-pass,)
|
|
|
|
update:
|
|
@if [ -z "$(HOST)" ]; then echo "HOST is required. Example: make update HOST=192.168.1.10"; exit 1; fi
|
|
$(BIN)/grm update $(HOST) $(if $(USER),--user $(USER),) $(if $(KEY),--key $(KEY),) $(if $(VERSION),--version $(VERSION),) $(if $(MODE),--mode $(MODE),) $(if $(ASK_BECOME_PASS),--ask-become-pass,)
|
|
|
|
start:
|
|
@if [ -z "$(HOST)" ]; then echo "HOST is required. Example: make start HOST=192.168.1.10"; exit 1; fi
|
|
$(BIN)/grm start $(HOST) $(if $(USER),--user $(USER),) $(if $(NAME),--name $(NAME),) $(if $(MODE),--mode $(MODE),) $(if $(ASK_BECOME_PASS),--ask-become-pass,)
|
|
|
|
stop:
|
|
@if [ -z "$(HOST)" ]; then echo "HOST is required. Example: make stop HOST=192.168.1.10"; exit 1; fi
|
|
$(BIN)/grm stop $(HOST) $(if $(USER),--user $(USER),) $(if $(NAME),--name $(NAME),) $(if $(ASK_BECOME_PASS),--ask-become-pass,)
|
|
|
|
enable:
|
|
@if [ -z "$(HOST)" ]; then echo "HOST is required. Example: make enable HOST=192.168.1.10"; exit 1; fi
|
|
$(BIN)/grm enable $(HOST) $(if $(USER),--user $(USER),) $(if $(NAME),--name $(NAME),) $(if $(ASK_BECOME_PASS),--ask-become-pass,)
|
|
|
|
disable:
|
|
@if [ -z "$(HOST)" ]; then echo "HOST is required. Example: make disable HOST=192.168.1.10"; exit 1; fi
|
|
$(BIN)/grm disable $(HOST) $(if $(USER),--user $(USER),) $(if $(NAME),--name $(NAME),) $(if $(TOKEN),--token $(TOKEN),) $(if $(MODE),--mode $(MODE),) $(if $(ASK_BECOME_PASS),--ask-become-pass,)
|
|
|
|
status:
|
|
@if [ -z "$(HOST)" ]; then echo "HOST is required. Example: make status HOST=192.168.1.10"; exit 1; fi
|
|
$(BIN)/grm status $(HOST) $(if $(USER),--user $(USER),) $(if $(NAME),--name $(NAME),) $(if $(MODE),--mode $(MODE),) $(if $(ASK_BECOME_PASS),--ask-become-pass,)
|
|
|
|
remove:
|
|
@if [ -z "$(HOST)" ]; then echo "HOST is required. Example: make remove HOST=192.168.1.10"; exit 1; fi
|
|
$(BIN)/grm remove $(HOST) $(if $(USER),--user $(USER),) $(if $(NAME),--name $(NAME),) $(if $(TOKEN),--token $(TOKEN),) $(if $(MODE),--mode $(MODE),) $(if $(ASK_BECOME_PASS),--ask-become-pass,)
|
|
|
|
lint:
|
|
$(BIN)/ruff check src/ tests/
|
|
$(BIN)/ruff format --check src/ tests/
|
|
$(BIN)/pyright
|
|
|
|
ansible-lint:
|
|
$(BIN)/ansible-lint ansible/
|
|
|
|
makefile-lint:
|
|
@$(CHECKMAKE) Makefile
|
|
|
|
lint-all: lint ansible-lint makefile-lint
|
|
|
|
test-unit:
|
|
$(BIN)/pytest tests/unit/ -v
|
|
|
|
test-integration:
|
|
$(BIN)/pytest tests/integration/ -v --no-cov
|
|
|
|
pytest-cov:
|
|
$(BIN)/pytest tests/unit/ -v --cov=src/gitea_runner_manager --cov-report=term-missing --cov-fail-under=100
|
|
|
|
MOLECULE := $(realpath $(BIN))/molecule
|
|
MOLECULE_BASE := cd ansible/roles/gitea-runner && ANSIBLE_ALLOW_BROKEN_CONDITIONALS=true $(MOLECULE)
|
|
|
|
# Quick local test: Ubuntu 22.04 only
|
|
molecule:
|
|
@set -e; for s in default binary multi-instance lifecycle template-content deregister update; do if [ "$$s" = "default" ]; then $(MOLECULE_BASE) test; else $(MOLECULE_BASE) test -s $$s; fi; done
|
|
|
|
# Docker mode tests for all platforms (sequential; override env vars for CI matrix parallelisation)
|
|
molecule-docker:
|
|
@set -e; for p in ubuntu-2204:geerlingguy/docker-ubuntu2204-ansible:latest:'' ubuntu-2404:geerlingguy/docker-ubuntu2404-ansible:latest:'' ubuntu-2604:geerlingguy/docker-ubuntu2604-ansible:latest:'' debian-12:geerlingguy/docker-debian12-ansible:latest:'' debian-13:geerlingguy/docker-debian13-ansible:latest:'' archlinux:marcstraube/archlinux-ansible:latest:/usr/lib/systemd/systemd; do IFS=":"; set -- $$p; MOLECULE_PLATFORM_NAME=$$1 MOLECULE_PLATFORM_IMAGE=$$2 MOLECULE_PLATFORM_COMMAND=$$3 $(MOLECULE_BASE) test; done
|
|
|
|
# Binary mode tests for all platforms (sequential; override env vars for CI matrix parallelisation)
|
|
molecule-binary:
|
|
@set -e; for p in ubuntu-2204:geerlingguy/docker-ubuntu2204-ansible:latest:'' ubuntu-2404:geerlingguy/docker-ubuntu2404-ansible:latest:'' ubuntu-2604:geerlingguy/docker-ubuntu2604-ansible:latest:'' debian-12:geerlingguy/docker-debian12-ansible:latest:'' debian-13:geerlingguy/docker-debian13-ansible:latest:'' archlinux:marcstraube/archlinux-ansible:latest:/usr/lib/systemd/systemd; do IFS=":"; set -- $$p; MOLECULE_PLATFORM_NAME=$$1 MOLECULE_PLATFORM_IMAGE=$$2 MOLECULE_PLATFORM_COMMAND=$$3 $(MOLECULE_BASE) test -s binary; done
|
|
|
|
# All platform tests (sequential; use CI matrix for parallel execution)
|
|
molecule-all: molecule-docker molecule-binary
|
|
|
|
test: test-all
|
|
|
|
test-all: pytest-cov molecule
|
|
|
|
clean:
|
|
find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
|
|
find . -type f -name "*.pyc" -delete 2>/dev/null || true
|
|
rm -rf .coverage htmlcov/ .molecule/
|