Skip to content

ci(trustplane): cover request binding in installed package checks #2

ci(trustplane): cover request binding in installed package checks

ci(trustplane): cover request binding in installed package checks #2

name: Python package
on:
push:
branches: [main, "codex/**", "ship/**"]
paths:
- "live/trustplane/**"
- ".github/workflows/python-package.yml"
workflow_dispatch:
permissions:
contents: read
jobs:
distributions:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python: ["3.9", "3.12"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: Build and validate distribution metadata
working-directory: live/trustplane
run: |
python -m pip install build twine
python -m build
python -m twine check --strict dist/*
- name: Extract standalone regression tests from the source distribution
env:
CHECK_DIR: ${{ runner.temp }}/agentguild-package-check
run: |
python - <<'PY'
import os
import tarfile
from pathlib import Path, PurePosixPath
destination = Path(os.environ["CHECK_DIR"])
source, = Path("live/trustplane/dist").glob("*.tar.gz")
copied = 0
with tarfile.open(source) as archive:
for member in archive.getmembers():
path = PurePosixPath(member.name)
if not member.isfile() or ".." in path.parts or path.is_absolute():
continue
relative = PurePosixPath(*path.parts[1:])
if len(relative.parts) < 2 or relative.parts[0] != "tests":
continue
standalone = relative.name in {
"test_client_transport_offline.py", "test_verifier_profile_offline.py",
"test_import_side_effects.py", "test_root_review_regressions.py",
"test_request_binding_offline.py",
}
fixture = len(relative.parts) == 3 and relative.parts[1] == "fixtures"
if not (standalone or fixture):
continue
target = destination.joinpath(*relative.parts)
target.parent.mkdir(parents=True, exist_ok=True)
target.write_bytes(archive.extractfile(member).read())
copied += 1
assert copied >= 9, "source distribution is missing standalone tests or fixtures"
PY
- name: Test wheel and source installs outside the checkout
env:
CHECK_DIR: ${{ runner.temp }}/agentguild-package-check
run: |
set -euo pipefail
for archive in "$GITHUB_WORKSPACE"/live/trustplane/dist/*; do
environment="$RUNNER_TEMP/agentguild-install-$(basename "$archive")"
python -m venv "$environment"
"$environment/bin/python" -m pip install "$archive" pytest
cd "$CHECK_DIR"
"$environment/bin/python" -I - <<'PY'
import sys
from pathlib import Path
import agentguild_trustplane
assert Path(agentguild_trustplane.__file__).resolve().is_relative_to(
Path(sys.prefix).resolve()), "test imported the checkout instead of the installed package"
PY
"$environment/bin/python" -I -m pytest -q -p no:cacheprovider tests
done
- uses: actions/upload-artifact@v4
with:
name: agentguild-python-${{ matrix.python }}
path: live/trustplane/dist/*
if-no-files-found: error
retention-days: 7