diff --git a/.github/skills/testing/SKILL.md b/.github/skills/testing/SKILL.md index 2916a6dfed71..3ce716abd49c 100644 --- a/.github/skills/testing/SKILL.md +++ b/.github/skills/testing/SKILL.md @@ -30,7 +30,8 @@ Labels include `unit`, `e2e`, `partitions`, `perf`, `benchmark`, `cft_scenario`, `cft_model_test` runs the same scenarios with the [consensus model driver](../../../tests/cft_model/README.md), which binds their commands to the Lean model of the protocol and not to the implementation. CMake registers it only when configured with `-DCFT_MODEL_DRIVER=ON`. -The release workflow sets `CCF_USE_RELEASED_PYTHON_PACKAGE=1` so `tests.sh`, installed-package tests, and sandboxes install the latest released `ccf` package from PyPI with `uv pip install --upgrade --reinstall-package ccf ccf`, replacing any previously installed editable SDK. +The release workflow sets `CCF_USE_RELEASED_PYTHON_PACKAGE=1` and derives `CCF_PYTHON_PACKAGE_MAX_VERSION` from the build's `VERSION_LONG`, normalized to a public Python version. +With this flag, `tests.sh`, installed-package tests, and sandboxes install the latest published `ccf` package from PyPI no newer than that upper bound, including prereleases, replacing any previously installed editable SDK. Without this flag, development and normal CI tests retain their editable local SDK installation. Installed sandboxes still default to the SDK version matching the installed CCF release. An existing caller-supplied `VENV_DIR` is reused without reinstalling packages; `tests.sh` selects the SDK before exporting its environment to child sandboxes. diff --git a/.github/workflows/README.md b/.github/workflows/README.md index 93dd6f971297..768055cfc6d5 100644 --- a/.github/workflows/README.md +++ b/.github/workflows/README.md @@ -258,7 +258,9 @@ The release therefore does not test that the RPM is reproducible, and does not p Python packages are built and published separately by the [OneBranch pipeline](../../.pipelines/README.md), without attestations. -Release-build tests, installed-package tests, and the recovery benchmark use the latest released `ccf` Python package from PyPI. The release job sets `CCF_USE_RELEASED_PYTHON_PACKAGE=1`; normal development and CI tests continue to use the local package. +Release-build tests, installed-package tests, and the recovery benchmark use the latest published `ccf` Python package from PyPI no newer than the CCF version under test, including prereleases. +Older-major SDKs are eligible, but newer SDKs are not. +The release job sets `CCF_USE_RELEASED_PYTHON_PACKAGE=1`; normal development and CI tests continue to use the local package. File: `release.yml` 3rd party dependencies: None diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4bbac1ce7f12..c1696fef98c7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -136,6 +136,13 @@ jobs: cmake -GNinja -DCLIENT_PROTOCOLS_TEST=ON -DCMAKE_BUILD_TYPE=Release .. ninja -v | tee build.log + - name: "Set Python SDK upper bound" + shell: bash + run: | + set -exo pipefail + version=$(uv run --no-project --with packaging python scripts/derive_python_version.py --public "$(> "$GITHUB_ENV" + - name: "Test" run: | set -ex diff --git a/.pipelines/README.md b/.pipelines/README.md index 65968fb575a0..923445c15df3 100644 --- a/.pipelines/README.md +++ b/.pipelines/README.md @@ -28,7 +28,7 @@ The proxy and its package-download destinations must be reachable under OneBranc This pipeline is the only Python package publisher. GitHub Actions no longer builds, attaches, or publishes Python wheels as part of the main CCF release. -Release-build tests use the latest package already released on PyPI; normal development and CI tests continue to use the local package. +Release-build tests use the latest package already published on PyPI no newer than the CCF version under test, including prereleases; normal development and CI tests continue to use the local package. Attestation is disabled for Python packages published to PyPI. A GitHub workflow that downloads an already-built wheel cannot establish OneBranch build provenance. diff --git a/scripts/derive_python_version.py b/scripts/derive_python_version.py index 0d753612ecf4..ffcd281c22c8 100755 --- a/scripts/derive_python_version.py +++ b/scripts/derive_python_version.py @@ -19,6 +19,11 @@ def main() -> None: "tag", help="CCF release tag, optionally prefixed with refs/tags/.", ) + parser.add_argument( + "--public", + action="store_true", + help="Discard local version suffixes, for SDK compatibility bounds.", + ) args = parser.parse_args() tag = args.tag.removeprefix("refs/tags/") @@ -28,6 +33,9 @@ def main() -> None: version = to_python_version(tag) except ValueError as exc: parser.error(str(exc)) + if args.public: + print(version.public) + return if version.local is not None: parser.error(f"PyPI does not accept local versions: {version}") print(version) diff --git a/tests/sandbox/sandbox.sh b/tests/sandbox/sandbox.sh index 56f56f3a65a3..563438397416 100755 --- a/tests/sandbox/sandbox.sh +++ b/tests/sandbox/sandbox.sh @@ -77,8 +77,8 @@ if [ ! -f "${VENV_DIR}/bin/activate" ]; then fi if [[ "${CCF_USE_RELEASED_PYTHON_PACKAGE:-0}" == "1" ]]; then - echo "Installing latest released ccf package..." - uv pip install -q --upgrade --reinstall-package ccf ccf + echo "Installing latest published ccf package no newer than ${CCF_PYTHON_PACKAGE_MAX_VERSION:?Set the CCF version under test}, including prereleases..." + uv pip install -q --upgrade --reinstall-package ccf --prerelease allow "ccf<=${CCF_PYTHON_PACKAGE_MAX_VERSION}" elif [ -f "${VERSION_FILE}" ]; then VERSION=$(<"${VERSION_FILE}") VERSION=${VERSION#"ccf-"} @@ -111,8 +111,8 @@ else # shellcheck disable=SC1090 source "${VENV_DIR}/bin/activate" if [[ "${CCF_USE_RELEASED_PYTHON_PACKAGE:-0}" == "1" && -z "$venv_dir_supplied" ]]; then - echo "Installing latest released ccf package..." - uv pip install -q --upgrade --reinstall-package ccf ccf + echo "Installing latest published ccf package no newer than ${CCF_PYTHON_PACKAGE_MAX_VERSION:?Set the CCF version under test}, including prereleases..." + uv pip install -q --upgrade --reinstall-package ccf --prerelease allow "ccf<=${CCF_PYTHON_PACKAGE_MAX_VERSION}" fi echo "Python environment already setup under ${VENV_DIR}" fi diff --git a/tests/test_install.sh b/tests/test_install.sh index 4087aef0e87a..2ec93b9874af 100755 --- a/tests/test_install.sh +++ b/tests/test_install.sh @@ -57,7 +57,7 @@ bash "$INSTALL_PREFIX"/bin/install_uv.sh "$PWD"/env/bin # shellcheck source=/dev/null source env/bin/activate if [[ "${CCF_USE_RELEASED_PYTHON_PACKAGE:-0}" == "1" ]]; then - uv pip install --upgrade --reinstall-package ccf ccf + uv pip install --upgrade --reinstall-package ccf --prerelease allow "ccf<=${CCF_PYTHON_PACKAGE_MAX_VERSION:?Set the CCF version under test}" else uv pip install -e ../../../python fi diff --git a/tests/tests.sh b/tests/tests.sh index 2730c8223afe..e45c9a677c5b 100755 --- a/tests/tests.sh +++ b/tests/tests.sh @@ -20,7 +20,7 @@ if [ -n "${PIP_INDEX_URL:-}" ] && [ -z "${UV_INDEX_URL:-}" ]; then export UV_INDEX_URL="$PIP_INDEX_URL" fi if [[ "${CCF_USE_RELEASED_PYTHON_PACKAGE:-0}" == "1" ]]; then - uv pip install -q --upgrade --reinstall-package ccf ccf + uv pip install -q --upgrade --reinstall-package ccf --prerelease allow "ccf<=${CCF_PYTHON_PACKAGE_MAX_VERSION:?Set the CCF version under test}" else uv pip install -q -e ../python/ fi