-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
55 lines (40 loc) · 2.75 KB
/
Makefile
File metadata and controls
55 lines (40 loc) · 2.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
PYTHON_VERSION_FILE := .python-version
PYTHON_VERSION := $(strip $(shell head -n 1 $(PYTHON_VERSION_FILE) 2>/dev/null))
PYTHON_MAJOR_MINOR := $(strip $(shell printf '%s' "$(PYTHON_VERSION)" | awk -F. 'NF >= 2 { print $$1 "." $$2 }'))
PYTHON ?= $(if $(PYTHON_MAJOR_MINOR),python$(PYTHON_MAJOR_MINOR),python3)
SHELL_SCRIPTS := $(wildcard .github/scripts/*.sh)
PYTHON_PATHS := .github/scripts/*.py .github/scripts/lib tests .github/skills
SCRIPTS_RUNNER := ./.github/scripts/run.sh
SCRIPTS_VENV := .github/scripts/.venv
.PHONY: help python-version-check lint catalog-lint github-catalog-validation test scripts-bootstrap catalog-check catalog-audit inventory-build token-risks skill-lint docs-lint all
help:
@printf '%s\n' 'Targets: lint catalog-lint github-catalog-validation test scripts-bootstrap catalog-check catalog-audit inventory-build token-risks skill-lint docs-lint all'
python-version-check:
@test -s "$(PYTHON_VERSION_FILE)" || { printf '%s\n' 'Missing or empty .python-version.' >&2; exit 1; }
@$(PYTHON) -c 'import pathlib, sys; required = pathlib.Path("$(PYTHON_VERSION_FILE)").read_text().strip(); expected = ".".join(required.split(".")[:2]); actual = f"{sys.version_info.major}.{sys.version_info.minor}"; raise SystemExit(0 if actual == expected else f"Expected $(PYTHON) to resolve to Python {expected} from $(PYTHON_VERSION_FILE) ({required}), got {actual}.")'
scripts-bootstrap: python-version-check
@$(SCRIPTS_RUNNER) build_inventory --help >/dev/null
lint: python-version-check
@if [ -n "$(SHELL_SCRIPTS)" ]; then bash -n $(SHELL_SCRIPTS); else printf '%s\n' 'No Bash scripts to lint.'; fi
@if command -v shellcheck >/dev/null 2>&1; then shellcheck -s bash $(SHELL_SCRIPTS); else printf '%s\n' 'shellcheck not installed; skipping.'; fi
$(PYTHON) -m compileall $(PYTHON_PATHS)
catalog-lint: python-version-check
@if [ -n "$(SHELL_SCRIPTS)" ]; then bash -n $(SHELL_SCRIPTS); else printf '%s\n' 'No Bash scripts to lint.'; fi
$(PYTHON) -m compileall $(PYTHON_PATHS)
github-catalog-validation: python-version-check
@bash ./github_catalog_validation.sh
test: scripts-bootstrap
@$(SCRIPTS_VENV)/bin/python -m pytest tests -q
catalog-check: scripts-bootstrap
@$(SCRIPTS_RUNNER) check_catalog_consistency --root . --include-token-risks
catalog-audit: scripts-bootstrap
@$(SCRIPTS_RUNNER) audit_copilot_catalog --root .
inventory-build: scripts-bootstrap
@$(SCRIPTS_RUNNER) build_inventory --root .
token-risks: scripts-bootstrap
@$(SCRIPTS_RUNNER) detect_token_risks --root .
skill-lint: scripts-bootstrap
@$(SCRIPTS_RUNNER) validate_internal_skills --root . --strict
docs-lint:
@if command -v npx >/dev/null 2>&1; then npx --yes markdownlint-cli2@0.18.1 "**/*.md" "#tmp/**"; else printf '%s\n' 'npx not installed; skipping markdown lint.'; fi
all: lint test catalog-check