diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1b26bd5..fa77f81 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,3 +35,34 @@ jobs: - name: Test with pytest run: pytest tests/ -v + + - name: Build wheel and sdist + run: | + pip install build + python -m build + + - name: Verify wheel contents + run: | + python - <<'PY' + import glob, zipfile + wheel = glob.glob("dist/*.whl")[0] + names = zipfile.ZipFile(wheel).namelist() + expected = ["hotspot_merge", "ownership_diff", "parse_semgrep", "parse_trivy", "risk_update", "scan_drift"] + missing = [m for m in expected if f"{m}.py" not in names] + assert not missing, f"wheel missing modules: {missing}; contents: {names}" + PY + + - name: Smoke test built wheel in clean environment + run: | + python -m venv "$RUNNER_TEMP/smoke" + "$RUNNER_TEMP/smoke/bin/pip" install dist/*.whl + cd "$RUNNER_TEMP" + "$RUNNER_TEMP/smoke/bin/python" -c "import hotspot_merge, ownership_diff, parse_semgrep, parse_trivy, risk_update, scan_drift" + "$RUNNER_TEMP/smoke/bin/python" -m hotspot_merge --help + + - name: Upload dist artifacts + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 + with: + name: dist + path: dist/ + if-no-files-found: error diff --git a/Makefile b/Makefile index c8c582d..0c16799 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ # Makefile for Architecture Governance Toolkit -.PHONY: help build-analysis-image run-analysis adr-new artifacts-dir +.PHONY: help build build-analysis-image run-analysis adr-new artifacts-dir sbom hotspots ownership drift risk full-analysis clean ANALYSIS_IMAGE=analysis:local ARTIFACTS_DIR=artifacts @@ -8,6 +8,7 @@ ARTIFACTS_DIR=artifacts help: @echo "Architecture Governance Toolkit - Available Commands:" @echo "" + @echo " make build - Build Python wheel and sdist package artifacts" @echo " make artifacts-dir - Create artifacts directory" @echo " make build-analysis-image - Build Docker analysis image" @echo " make run-analysis - Run analysis in Docker" @@ -15,6 +16,9 @@ help: @echo " make clean - Remove artifacts directory" @echo "" +build: + python3 -m build + artifacts-dir: mkdir -p $(ARTIFACTS_DIR)/sbom $(ARTIFACTS_DIR)/timeseries diff --git a/README.md b/README.md index f60c16b..2d0fdcb 100644 --- a/README.md +++ b/README.md @@ -356,6 +356,22 @@ Optional for extended features: - Trivy and/or Semgrep for security scanning - Syft for SBOM generation +### Local Build and Validation + +Run the unit tests and the full governance analysis pipeline: + +```bash +python3 -m pytest && make full-analysis +``` + +Build the wheel and sdist locally (written to `dist/`; requires `pip install build`): + +```bash +make build +``` + +CI builds these artifacts, inspects the wheel contents, smoke-tests it in a clean environment and uploads `dist/` as a CI artifact only. No release or publication has occurred. + ### Option 1: Run Directly ```bash diff --git a/pyproject.toml b/pyproject.toml index 3829da8..62d5e3f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,9 +19,16 @@ dev = [ "ruff>=0.4.0", ] -[tool.setuptools.packages.find] -where = ["scripts"] -include = [] +[tool.setuptools] +package-dir = {"" = "scripts"} +py-modules = [ + "hotspot_merge", + "ownership_diff", + "parse_semgrep", + "parse_trivy", + "risk_update", + "scan_drift", +] [tool.pytest.ini_options] testpaths = ["tests"]