ReMe/.github/workflows/_build-python-packages.yml
jinliyl d019f784d7
Some checks are pending
CI / Python packages / Build and verify distributions (push) Waiting to run
CI / Python quality / GitHub Actions (push) Waiting to run
CI / Python quality / Pre-commit (push) Waiting to run
CI / Python tests / Hermes embedded - ubuntu-latest (push) Waiting to run
CI / Python tests / Hermes embedded - windows-latest (push) Waiting to run
CI / Python tests / Unit Tests - py3.11 (push) Waiting to run
CI / Python tests / Unit Tests - py3.12 (push) Waiting to run
CI / Python tests / Unit Tests - py3.13 (push) Waiting to run
CI / Python tests / Unit Tests - py3.14 (push) Waiting to run
CI / ReMe Studio / Studio checks (push) Waiting to run
CI / Windows / CLI smoke - py3.11 (push) Waiting to run
Deploy / Documentation / Build documentation (push) Waiting to run
Deploy / Documentation / deploy (push) Blocked by required conditions
Security / CodeQL / Analyze javascript-typescript (push) Waiting to run
Security / CodeQL / Analyze python (push) Waiting to run
refactor(docker): move deployment assets and keep benchmarks in HoMe (#777)
* refactor(docker): move deployment assets to their owners

* fix(home): build benchmark image with local Studio package

* fix(home): ship Docker assets and verify coordinated upgrades
2026-11-24 16:39:47 +08:00

230 lines
10 KiB
YAML

name: _Build Python packages
on:
workflow_call:
inputs:
expected_version:
description: Expected release version; omit for a consistency-only check
required: false
default: ''
type: string
source_ref:
description: Release commit to build
type: string
default: ''
upload_artifacts:
description: Upload distributions for later publish jobs
required: false
default: false
type: boolean
permissions:
contents: read
jobs:
distributions:
name: Build Python distributions
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ inputs.source_ref }}
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: '3.11'
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
python -m pip install build packaging pytest twine
- name: Validate package versions
env:
EXPECTED_VERSION: ${{ inputs.expected_version }}
run: python scripts/bump_version.py --check --expected-version "${EXPECTED_VERSION}"
- name: Run package tests
run: PYTHONPATH=. python -m pytest tests/unit/test_package_versions.py -q
- name: Build and check distributions
run: |
mkdir -p dist/reme
python -m build --outdir dist/reme
python -m twine check dist/reme/*
- name: Verify distributions and isolated installation
run: |
REME_WHEEL="$(pwd)/$(ls dist/reme/reme_ai-[0-9]*.whl)"
python -m zipfile -l "${REME_WHEEL}" | (! grep 'reme/web/')
python -m zipfile -l "${REME_WHEEL}" | (! grep 'reme_studio/')
python -m venv "${RUNNER_TEMP}/reme-package-smoke"
"${RUNNER_TEMP}/reme-package-smoke/bin/python" -m pip install "${REME_WHEEL}[as]"
"${RUNNER_TEMP}/reme-package-smoke/bin/python" -m pip check
cd "${RUNNER_TEMP}"
"${RUNNER_TEMP}/reme-package-smoke/bin/python" -c "import reme"
- name: Build and verify Home plugin distribution
run: |
python -m build --outdir dist/home plugins/home
python -m twine check dist/home/*
REME_WHEEL="$(pwd)/$(ls dist/reme/reme_ai-[0-9]*.whl)"
HOME_WHEEL="$(pwd)/$(ls dist/home/reme_home-[0-9]*.whl)"
HOME_TESTS="$(pwd)/plugins/home/tests"
LEGACY_HOME="${RUNNER_TEMP}/legacy-home"
# Use the last HoMe 0.1.0 source layout before the Docker runner moved.
LEGACY_HOME_REF=b3a5eac4a8d56e9681312d608f241c7177eed359
mkdir -p "${LEGACY_HOME}"
git fetch --no-tags --depth=1 origin "${LEGACY_HOME_REF}"
git archive "${LEGACY_HOME_REF}" plugins/home | tar -x -C "${LEGACY_HOME}"
verify_home_wheel() (
local smoke_env="${RUNNER_TEMP}/reme-home-package-smoke-$1"
python -m venv "${smoke_env}"
if [[ "$1" == "upgrade" ]]; then
"${smoke_env}/bin/python" -m pip install --no-deps "${REME_WHEEL}" "${LEGACY_HOME}/plugins/home"
fi
# The minimum release may be built here before it is published to PyPI.
"${smoke_env}/bin/python" -m pip install --find-links "$(dirname "${REME_WHEEL}")" \
"$2" "${HOME_WHEEL}" pytest pytest-asyncio
"${smoke_env}/bin/python" -m pip check
cd "${RUNNER_TEMP}"
"${smoke_env}/bin/python" -I - <<'PY'
from pathlib import Path
import sys
import reme
import reme_home
from reme.enumeration import ComponentEnum
from reme.plugin import resolve_plugin_runtime
from reme_home import AutoBashStep
from reme_home.evaluation.docker import direct_docker_workspace, worker
for module in (reme, reme_home, direct_docker_workspace, worker):
assert Path(module.__file__).is_relative_to(sys.prefix), module.__file__
docker_dir = Path(direct_docker_workspace.__file__).parent
for name in ("Dockerfile.base", "Dockerfile.candidate", "Dockerfile.candidate.dockerignore", "README.md"):
assert (docker_dir / name).is_file(), name
runtime = resolve_plugin_runtime({"plugins": ["home"]})
assert runtime.registry.get(ComponentEnum.STEP, "auto_bash_step") is AutoBashStep
assert runtime.config["jobs"]["auto_bash"]["steps"] == [{"backend": "auto_bash_step"}]
PY
"${smoke_env}/bin/python" -I -m pytest -q -o pythonpath= \
"${HOME_TESTS}/test_evaluation.py::test_all_cases_and_artifacts_via_real_job"
)
verify_home_wheel upgrade "${REME_WHEEL}"
HOME_MINIMUM="$(python - <<'PY'
import tomllib
from packaging.requirements import Requirement
from packaging.version import Version
with open('plugins/home/pyproject.toml', 'rb') as stream:
dependencies = tomllib.load(stream)['project']['dependencies']
requirement = next(Requirement(value) for value in dependencies if Requirement(value).name == 'reme-ai')
minimum, = (item.version for item in requirement.specifier if item.operator == '>=')
assert Version(minimum) in requirement.specifier
print(f'reme-ai=={minimum}')
PY
)"
verify_home_wheel minimum "${HOME_MINIMUM}"
- name: Build and verify benchmark plugin distributions
run: |
REPOSITORY="$(pwd)"
REME_WHEEL="${REPOSITORY}/$(ls dist/reme/reme_ai-[0-9]*.whl)"
for BENCHMARK in memlens mobilemem; do
python -m build --outdir "dist/${BENCHMARK}" "plugins/${BENCHMARK}"
python -m twine check "dist/${BENCHMARK}/"*
PLUGIN_WHEEL="${REPOSITORY}/$(ls dist/${BENCHMARK}/reme_${BENCHMARK}-[0-9]*.whl)"
PLUGIN_ENV="${RUNNER_TEMP}/reme-${BENCHMARK}-package-smoke"
python -m venv "${PLUGIN_ENV}"
"${PLUGIN_ENV}/bin/python" -m pip install "${REME_WHEEL}[as]" "${PLUGIN_WHEEL}"
"${PLUGIN_ENV}/bin/python" -m pip check
(
cd "${RUNNER_TEMP}"
"${PLUGIN_ENV}/bin/python" -I - "${BENCHMARK}" <<'PY'
from importlib import import_module, metadata
from pathlib import Path
import sys
import reme
from reme.components.agent_wrapper.as_agent_wrapper import AsAgentWrapper
from reme.config.config_parser import _load_config
from reme.enumeration import ComponentEnum
from reme.plugin import resolve_plugin_runtime
name = sys.argv[1]
plugin = import_module(f"reme_{name}")
wrapper = import_module(f"reme_{name}.benchmark_agent").BenchmarkAsAgentWrapper
for module in (reme, plugin, sys.modules[wrapper.__module__]):
assert Path(module.__file__).resolve().is_relative_to(Path(sys.prefix).resolve()), module.__file__
entries = tuple(metadata.entry_points(group="reme.plugins", name=name))
assert len(entries) == 1 and entries[0].load() is plugin
presets = tuple(metadata.entry_points(group="reme.configs", name=f"{name}-benchmark"))
assert len(presets) == 1 and presets[0].load() == plugin.BENCHMARK_CONFIG
assert plugin.BENCHMARK_CONFIG.is_file()
assert Path(plugin.__file__).with_name("plugin.yaml").is_file()
runtime = resolve_plugin_runtime(_load_config(f"{name}-benchmark"))
backend = f"{name}_benchmark_agent"
assert issubclass(wrapper, AsAgentWrapper)
assert callable(AsAgentWrapper._finish_reply)
assert runtime.registry.get(ComponentEnum.AGENT_WRAPPER, backend) is wrapper
for variant in ("default", "bench"):
assert runtime.config["components"]["agent_wrapper"][variant]["backend"] == backend
print(f"{name}: installed wheel entry points and backends verified")
PY
)
done
- name: Set up Node for Studio
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1
with:
node-version: '22.22.3'
cache: npm
cache-dependency-path: reme_studio/package-lock.json
- name: Build Studio distributions
run: |
npm ci --prefix reme_studio --ignore-scripts
npm run build:static --prefix reme_studio
mkdir -p dist/studio-npm
npm pack ./reme_studio/web --pack-destination dist/studio-npm
python scripts/package_studio.py
python -m build reme_studio/web/python --outdir dist/studio
python -m twine check dist/studio/*
tar -tzf dist/studio-npm/*.tgz | grep '^package/dist-static/index.html$'
- name: Verify released core dependencies
if: inputs.upload_artifacts
run: |
REME_WHEEL="$(pwd)/$(ls dist/reme/reme_ai-[0-9]*.whl)"
STUDIO_WHEEL="$(pwd)/$(ls dist/studio/reme_studio-[0-9]*.whl)"
python -m venv "${RUNNER_TEMP}/reme-core-package-smoke"
"${RUNNER_TEMP}/reme-core-package-smoke/bin/python" -m pip install "${REME_WHEEL}[core]" "${STUDIO_WHEEL}"
cd "${RUNNER_TEMP}"
"${RUNNER_TEMP}/reme-core-package-smoke/bin/python" -I - <<'PYCODE'
from importlib.metadata import version
from reme_studio import static_dir
assert version("reme-ai") == version("reme-studio")
assert (static_dir() / "index.html").is_file()
PYCODE
- name: Upload Studio distributions
if: inputs.upload_artifacts
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9
with:
name: studio-distributions
path: |
dist/studio/
dist/studio-npm/
if-no-files-found: error
- name: Upload ReMe distributions
if: inputs.upload_artifacts
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: reme-distributions
path: dist/reme/
if-no-files-found: error