ci: scope native acceptance and bind release candidate artifacts (#6378)

* ci: scope native acceptance and bind release candidate artifacts

* ci: isolate Windows installers and use portable Git tree fixtures

* test: preserve installer subprocess diagnostics on timeout
This commit is contained in:
chengyongru authored and GitHub committed 2026-10-21 23:50:58 +08:00
1 parent 4dc695ca76
commit 67fc220c8a
15 files changed
+1222 -288

No files matched your search

+62 -162
View File
@@ -4,30 +4,8 @@ on:
workflow_dispatch:
push:
branches: [main]
paths-ignore:
- docs/**
- .agent/**
- .github/ISSUE_TEMPLATE/**
- AGENTS.md
- CLAUDE.md
- COMMUNICATION.md
- CONTRIBUTING.md
- README.md
- SECURITY.md
- webui/README.md
pull_request:
branches: [main]
paths-ignore:
- docs/**
- .agent/**
- .github/ISSUE_TEMPLATE/**
- AGENTS.md
- CLAUDE.md
- COMMUNICATION.md
- CONTRIBUTING.md
- README.md
- SECURITY.md
- webui/README.md
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
@@ -45,96 +23,23 @@ jobs:
webui_required: ${{ steps.paths.outputs.webui_required }}
tui_required: ${{ steps.paths.outputs.tui_required }}
docker_required: ${{ steps.paths.outputs.docker_required }}
native_required: ${{ steps.paths.outputs.native_required }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Detect Python-relevant changes
- name: Select checks by affected contracts
id: paths
shell: bash
env:
EVENT_NAME: ${{ github.event_name }}
BASE_SHA: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
HEAD_SHA: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
run: |
python_required=true
webui_required=true
tui_required=true
docker_required=true
if [[ "$EVENT_NAME" == "pull_request" ]]; then
diff_range="${BASE_SHA}...${HEAD_SHA}"
else
diff_range="${BASE_SHA}..${HEAD_SHA}"
fi
if git cat-file -e "${BASE_SHA}^{commit}" 2>/dev/null &&
changed_files="$(git diff --name-only --no-renames "$diff_range")" &&
[[ -n "$changed_files" ]]; then
python_required=false
webui_required=false
tui_required=false
docker_required=false
while IFS= read -r file; do
case "$file" in
.github/workflows/*)
# A workflow change must exercise every affected execution path.
python_required=true
webui_required=true
tui_required=true
docker_required=true
;;
webui/*|nanobot/channels/*/webui/*|nanobot/channels/*/tests/webui/*)
webui_required=true
# The Docker image builds and bundles both WebUI trees.
docker_required=true
;;
nanobot/*)
# Channel WebUI files were handled by the previous case.
python_required=true
docker_required=true
;;
tests/test_docker.sh)
docker_required=true
;;
pyproject.toml|hatch_build.py|scripts/install_channel_dependencies.py)
python_required=true
docker_required=true
;;
scripts/check_client_import_boundaries.*)
webui_required=true
tui_required=true
;;
tests/*|conftest.py|uv.lock|scripts/*)
python_required=true
;;
Dockerfile|Dockerfile.*|.dockerignore|docker-compose*.yml|entrypoint.sh|render-config.json|README.md|LICENSE|THIRD_PARTY_NOTICES.md)
docker_required=true
;;
tui/*)
tui_required=true
;;
docs/*|.agent/*|.github/ISSUE_TEMPLATE/*|AGENTS.md|CLAUDE.md|COMMUNICATION.md|CONTRIBUTING.md|README.md|SECURITY.md|webui/README.md|render.yaml)
# Documentation-only changes are already filtered at the event level.
;;
*)
# Keep new or unclassified paths covered until they are categorized.
python_required=true
webui_required=true
tui_required=true
docker_required=true
;;
esac
done <<< "$changed_files"
fi
echo "python_required=$python_required" >> "$GITHUB_OUTPUT"
echo "webui_required=$webui_required" >> "$GITHUB_OUTPUT"
echo "tui_required=$tui_required" >> "$GITHUB_OUTPUT"
echo "docker_required=$docker_required" >> "$GITHUB_OUTPUT"
run: >-
python scripts/ci_scope.py --event "$EVENT_NAME"
--base "$BASE_SHA" --head "$HEAD_SHA"
test:
name: Python (${{ matrix.name }})
@@ -213,7 +118,7 @@ jobs:
# later uv run sync pruning the packages installed by the previous step.
- name: Lint with ruff
if: matrix.coverage
run: uv run --no-sync ruff check nanobot tests conftest.py scripts/check_import_boundaries.py scripts/pytest_timing.py
run: uv run --no-sync ruff check nanobot tests conftest.py scripts/check_import_boundaries.py scripts/pytest_timing.py scripts/ci_scope.py scripts/ci_gate.py scripts/native_acceptance_input.py scripts/verify_packaged_update.py
- name: Type check with BasedPyright (strict)
if: matrix.coverage
@@ -234,7 +139,7 @@ jobs:
# the real installation/restore checks, but avoid a loadfile straggler and
# disk contention with timing-sensitive runtime-registration checks.
- name: Run Windows isolated update jobs
if: runner.os == 'Windows'
if: runner.os == 'Windows' && github.event_name != 'push' && needs.changes.outputs.native_required == 'true'
run: >-
uv run --no-sync python -m pytest tests/test_update_jobs.py
-n 3 --dist load -vv --durations=25 --durations-min=1.0
@@ -325,16 +230,43 @@ jobs:
--junitxml=test-results/process.xml --timing-report=test-results/process.json
--durations=25 --durations-min=1.0
- name: Upload Windows process test timings
if: always()
uses: actions/upload-artifact@v4
with:
name: python-timings-windows-process
path: test-results/
retention-days: 7
windows_installers:
name: Python (Windows installer compatibility)
needs: changes
if: github.event_name != 'push' && needs.changes.outputs.python_required == 'true' && needs.changes.outputs.native_required == 'true'
runs-on: windows-latest
# The real installer matrix took 18m06s alone; process checks and teardown
# previously pushed the combined job beyond its 20-minute bound.
timeout-minutes: 25
env:
PYTEST_ADDOPTS: "-o tmp_path_retention_policy=failed -p scripts.pytest_timing"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.14'
- uses: astral-sh/setup-uv@v4
with:
enable-cache: true
cache-dependency-glob: pyproject.toml
- name: Install dependencies
run: uv sync --all-extras --dev
- name: Install pipx for offline installer checks
shell: bash
run: |
uv tool install pipx==1.17.12
uv tool dir --bin >> "$GITHUB_PATH"
# Installer subprocesses run here, parallel to the broad Windows suite.
# Each case owns an isolated manager/config root, so individual cases can
# run concurrently without sharing a console or package installation.
# Keep four workers: three exceed this job's budget on native Windows.
# Each case owns an isolated manager/config root. Keep the existing
# four-worker budget, independent of process-identity compatibility checks.
- name: Run Windows installer checks
run: >-
uv run --no-sync python -m pytest tests/test_install_scripts.py
@@ -345,7 +277,7 @@ jobs:
if: always()
uses: actions/upload-artifact@v4
with:
name: python-timings-windows-process
name: python-timings-windows-installers
path: test-results/
retention-days: 7
@@ -439,12 +371,10 @@ jobs:
tui:
needs: changes
if: needs.changes.outputs.tui_required == 'true' || needs.changes.outputs.python_required == 'true' || needs.changes.outputs.webui_required == 'true'
if: needs.changes.outputs.tui_required == 'true'
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
# Native build + clean install + recovery/next-update journeys on Windows.
# Each subprocess is separately bounded by the acceptance harness.
timeout-minutes: 60
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
@@ -521,57 +451,11 @@ jobs:
bun scripts/release-notices.ts win32-x64
python scripts/package-release.py win32-x64
- name: Build and install the native application package
shell: bash
env:
NATIVE_TARGET: ${{ runner.os == 'Windows' && 'win32-x64' || 'linux-x64' }}
run: |
python -m pip install --disable-pip-version-check build
python -m build --outdir "$RUNNER_TEMP/python-dist"
# Archive verification shares the installed launcher's dependencies.
# Install the intermediate in this build environment, not the separate
# clean-home environment used by the public-installer acceptance probe.
python -m pip install --disable-pip-version-check "$(find "$RUNNER_TEMP/python-dist" -name '*.whl' -print -quit)"
python -m scripts.build_tui_wheels \
--wheel "$(find "$RUNNER_TEMP/python-dist" -name '*.whl' -print -quit)" \
--tui-dir tui/dist --target "$NATIVE_TARGET" --out-dir "$RUNNER_TEMP/native-wheel"
version="$(python -c 'import tomllib; print(tomllib.load(open("pyproject.toml", "rb"))["project"]["version"])')"
python -I scripts/verify_installed_release.py \
--install-wheel "$(find "$RUNNER_TEMP/native-wheel" -name '*.whl' -print -quit)" \
--version "$version" --commit "$(git rev-parse HEAD)" --gateway \
--report "$RUNNER_TEMP/native-install-report.json"
- name: Exercise updates with the default Windows path policy
if: runner.os == 'Windows'
shell: pwsh
run: |
# Only this disposable runner changes. Do not require users to enable
# machine-wide long paths for an ordinary update's atomic temp files.
$key = 'HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem'
Set-ItemProperty -Path $key -Name LongPathsEnabled -Value 0
if ((Get-ItemPropertyValue -Path $key -Name LongPathsEnabled) -ne 0) {
throw 'Native update acceptance requires LongPathsEnabled=0'
}
Write-Output 'Packaged update/recovery acceptance: LongPathsEnabled=0'
- name: Verify packaged upgrades and automatic service recovery
shell: bash
run: |
python -I scripts/verify_packaged_update.py \
--wheel "$(find "$RUNNER_TEMP/native-wheel" -name '*.whl' -print -quit)" \
--commit "$(git rev-parse HEAD)" --output "$RUNNER_TEMP/packaged-update"
- name: Retain the native package acceptance report
if: always()
uses: actions/upload-artifact@v4
with:
name: native-install-${{ runner.os }}-${{ github.run_id }}-${{ github.run_attempt }}
path: |
${{ runner.temp }}/native-install-report.json
${{ runner.temp }}/packaged-update/packaged-update-report.json
${{ runner.temp }}/packaged-update/*/result.json
if-no-files-found: error
retention-days: 3
native:
name: Native package acceptance
needs: changes
if: github.event_name != 'push' && needs.changes.outputs.native_required == 'true'
uses: ./.github/workflows/native-acceptance.yml
docker:
needs: changes
@@ -634,3 +518,19 @@ jobs:
docker run --rm --user 1000:1000 --entrypoint sh nanobot:test -c
'test -w /app/.venv && test ! -w /app && test ! -w /app/nanobot &&
python -m scripts.install_channel_dependencies discord && python -c "import discord"'
required:
name: CI required
needs: [changes, test, windows_process, windows_installers, webui_checks, webui_browser, webui, tui, docker, native]
if: always()
runs-on: ubuntu-latest
timeout-minutes: 2
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Require every selected check
env:
CHECK_RESULTS: ${{ toJSON(needs) }}
EVENT_NAME: ${{ github.event_name }}
run: python scripts/ci_gate.py
+135
View File
@@ -0,0 +1,135 @@
name: Native package acceptance
on:
workflow_call:
inputs:
candidate:
description: Download exact candidate wheels instead of building PR test packages
type: boolean
default: false
candidate_commit:
type: string
default: ''
manifest_sha256:
type: string
default: ''
linux_artifact_id:
type: string
default: ''
windows_artifact_id:
type: string
default: ''
permissions:
contents: read
jobs:
native:
name: Native acceptance (${{ matrix.target }})
runs-on: ${{ matrix.os }}
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: linux-x64
wheel_tag: manylinux_2_17_x86_64
- os: windows-latest
target: win32-x64
wheel_tag: win_amd64
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- uses: oven-sh/setup-bun@v2
if: ${{ !inputs.candidate }}
with:
bun-version: 1.3.13
bun-download-url: ${{ runner.os == 'Windows' && 'https://github.com/oven-sh/bun/releases/download/bun-v1.3.13/bun-windows-x64-baseline.zip' || '' }}
- name: Build native test bundle
if: ${{ !inputs.candidate }}
working-directory: tui
run: |
bun install --frozen-lockfile
bun run build
bun scripts/release-notices.ts "${{ matrix.target }}"
python scripts/package-release.py "${{ matrix.target }}"
- name: Build native test wheel
if: ${{ !inputs.candidate }}
run: |
python -m pip install --disable-pip-version-check build
python -m build --outdir "$RUNNER_TEMP/python-dist"
# The archive verifier imports the installed launcher's dependency stack.
python -m pip install --disable-pip-version-check "$(find "$RUNNER_TEMP/python-dist" -name '*.whl' -print -quit)"
python -m scripts.build_tui_wheels \
--wheel "$(find "$RUNNER_TEMP/python-dist" -name '*.whl' -print -quit)" \
--tui-dir tui/dist --target "${{ matrix.target }}" --out-dir "$RUNNER_TEMP/native-wheel"
- name: Download exact candidate wheel and manifest
if: inputs.candidate
uses: actions/download-artifact@v4
with:
# Producer IDs survive a failed-jobs-only retry without rebuilding bytes.
artifact-ids: ${{ matrix.target == 'linux-x64' && inputs.linux_artifact_id || inputs.windows_artifact_id }}
merge-multiple: true
path: ${{ runner.temp }}/native-wheel
- name: Verify acceptance input identity
env:
CANDIDATE: ${{ inputs.candidate }}
EXPECTED_COMMIT: ${{ inputs.candidate_commit }}
EXPECTED_MANIFEST: ${{ inputs.manifest_sha256 }}
WHEEL_TAG: ${{ matrix.wheel_tag }}
run: python scripts/native_acceptance_input.py
- name: Install acceptance controller dependencies
run: python -m pip install --disable-pip-version-check "$ACCEPTANCE_WHEEL"
- name: Exercise default Windows path policy
if: runner.os == 'Windows'
shell: pwsh
run: |
$key = 'HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem'
Set-ItemProperty -Path $key -Name LongPathsEnabled -Value 0
if ((Get-ItemPropertyValue -Path $key -Name LongPathsEnabled) -ne 0) {
throw 'Native update acceptance requires LongPathsEnabled=0'
}
- name: Verify clean public installation and startup
run: |
python -I scripts/verify_installed_release.py \
--install-wheel "$ACCEPTANCE_WHEEL" --version "$ACCEPTANCE_VERSION" \
--commit "$ACCEPTANCE_COMMIT" --gateway \
--report "$RUNNER_TEMP/native-install-report.json"
- name: Verify packaged upgrades and automatic service recovery
run: |
python -I scripts/verify_packaged_update.py \
--wheel "$ACCEPTANCE_WHEEL" --commit "$ACCEPTANCE_COMMIT" \
--output "$RUNNER_TEMP/packaged-update"
# Raw acceptance logs contain disposable credentials. Export only structured evidence.
- name: Retain native acceptance evidence
if: always()
uses: actions/upload-artifact@v4
with:
name: native-acceptance-${{ matrix.target }}-${{ github.run_id }}-${{ github.run_attempt }}
path: |
${{ runner.temp }}/native-input.json
${{ runner.temp }}/native-install-report.json
${{ runner.temp }}/packaged-update/packaged-update-report.json
${{ runner.temp }}/packaged-update/packaged-update-timings.json
${{ runner.temp }}/packaged-update/*/result.json
if-no-files-found: error
retention-days: 3
+98 -27
View File
@@ -25,6 +25,12 @@ jobs:
candidate:
runs-on: ubuntu-latest
timeout-minutes: 45
outputs:
candidate_commit: ${{ steps.identity.outputs.candidate_commit }}
manifest_sha256: ${{ steps.identity.outputs.manifest_sha256 }}
linux_artifact_id: ${{ steps.linux_input.outputs.artifact-id }}
windows_artifact_id: ${{ steps.windows_input.outputs.artifact-id }}
prepared_artifact_id: ${{ steps.prepared.outputs.artifact-id }}
env:
SOURCE_COMMIT: ${{ github.sha }}
NEXT_STABLE: ${{ inputs.next_stable }}
@@ -122,20 +128,45 @@ jobs:
python -m twine check "$RUNNER_TEMP/release-artifacts/"*.whl \
"$RUNNER_TEMP/release-artifacts/"*.tar.gz
- name: Install and probe the Linux wheel without frontend build tools
working-directory: ${{ env.CANDIDATE_DIR }}
- name: Record exact acceptance identity
id: identity
env:
MANIFEST: ${{ runner.temp }}/release-artifacts/release-manifest.json
run: |
version="${NEXT_STABLE}.dev${PREVIEW_SEQUENCE}"
uv_bin="$(command -v uv)"
uv venv --python 3.11 "$RUNNER_TEMP/installed-candidate"
mkdir "$RUNNER_TEMP/empty-install-path"
env PATH="$RUNNER_TEMP/empty-install-path" "$uv_bin" pip install \
--python "$RUNNER_TEMP/installed-candidate/bin/python" --only-binary :all: \
"$RUNNER_TEMP/release-artifacts/nanobot_ai-${version}-py3-none-manylinux_2_17_x86_64.whl"
uv pip check --python "$RUNNER_TEMP/installed-candidate/bin/python"
"$RUNNER_TEMP/installed-candidate/bin/python" -I scripts/verify_installed_release.py \
--version "$version" --commit "$(git rev-parse HEAD)" --gateway \
--report "$RUNNER_TEMP/installed-candidate-report.json"
python - <<'PY'
import hashlib, json, os
from pathlib import Path
payload = Path(os.environ['MANIFEST']).read_bytes()
manifest = json.loads(payload)
with open(os.environ['GITHUB_OUTPUT'], 'a') as output:
output.write(f"candidate_commit={manifest['candidate_commit']}\n")
output.write(f"manifest_sha256={hashlib.sha256(payload).hexdigest()}\n")
PY
# Temporary same-run inputs, not approved release handoffs. Do not rebuild on consumers.
- name: Transfer exact Linux acceptance input
id: linux_input
uses: actions/upload-artifact@v4
with:
name: candidate-native-linux-x64-${{ github.run_number }}-${{ github.run_attempt }}
path: |
${{ runner.temp }}/release-artifacts/*-manylinux_2_17_x86_64.whl
${{ runner.temp }}/release-artifacts/release-manifest.json
if-no-files-found: error
retention-days: 1
compression-level: 0
- name: Transfer exact Windows acceptance input
id: windows_input
uses: actions/upload-artifact@v4
with:
name: candidate-native-win32-x64-${{ github.run_number }}-${{ github.run_attempt }}
path: |
${{ runner.temp }}/release-artifacts/*-win_amd64.whl
${{ runner.temp }}/release-artifacts/release-manifest.json
if-no-files-found: error
retention-days: 1
compression-level: 0
- name: Generate the exact candidate installation handoff
working-directory: ${{ env.CANDIDATE_DIR }}
@@ -144,25 +175,14 @@ jobs:
--artifacts "$RUNNER_TEMP/release-artifacts" \
--output "$RUNNER_TEMP/install-candidate.md"
- name: Verify packaged Linux upgrades and service recovery
working-directory: ${{ env.CANDIDATE_DIR }}
run: |
version="${NEXT_STABLE}.dev${PREVIEW_SEQUENCE}"
python -I scripts/verify_packaged_update.py \
--wheel "$RUNNER_TEMP/release-artifacts/nanobot_ai-${version}-py3-none-manylinux_2_17_x86_64.whl" \
--commit "$(git rev-parse HEAD)" --output "$RUNNER_TEMP/packaged-update"
# Keep the default preflight cheap: no ~400 MB archive upload per manual run.
# These reports are not installable releases or publication approvals.
- name: Retain identity, structural and native Linux probe reports
# These reports are neither native acceptance nor publication approval.
- name: Retain candidate identity and structural reports
uses: actions/upload-artifact@v4
with:
name: candidate-report-${{ github.run_number }}-${{ github.run_attempt }}
path: |
${{ runner.temp }}/candidate.json
${{ runner.temp }}/release-artifacts/release-manifest.json
${{ runner.temp }}/installed-candidate-report.json
${{ runner.temp }}/packaged-update/packaged-update-report.json
${{ runner.temp }}/install-candidate.md
if-no-files-found: error
retention-days: 3
@@ -177,12 +197,63 @@ jobs:
--artifacts "$RUNNER_TEMP/release-artifacts" \
--output "$RUNNER_TEMP/retained-candidate"
- name: Retain installable candidate for approved release handoff
- name: Transfer prepared candidate pending native acceptance
id: prepared
if: ${{ inputs.retain_installable }}
uses: actions/upload-artifact@v4
with:
name: prepared-candidate-${{ github.run_number }}-${{ github.run_attempt }}
path: ${{ runner.temp }}/retained-candidate
if-no-files-found: error
compression-level: 0
retention-days: 1
native:
name: Candidate native acceptance
needs: candidate
uses: ./.github/workflows/native-acceptance.yml
with:
candidate: true
candidate_commit: ${{ needs.candidate.outputs.candidate_commit }}
manifest_sha256: ${{ needs.candidate.outputs.manifest_sha256 }}
linux_artifact_id: ${{ needs.candidate.outputs.linux_artifact_id }}
windows_artifact_id: ${{ needs.candidate.outputs.windows_artifact_id }}
verified:
name: Candidate required
needs: [candidate, native]
if: always()
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Require build and both native acceptance jobs
env:
BUILD_RESULT: ${{ needs.candidate.result }}
NATIVE_RESULT: ${{ needs.native.result }}
run: test "$BUILD_RESULT" = success && test "$NATIVE_RESULT" = success
- name: Restore the exact retained candidate after acceptance
if: inputs.retain_installable
uses: actions/download-artifact@v4
with:
artifact-ids: ${{ needs.candidate.outputs.prepared_artifact_id }}
merge-multiple: true
path: ${{ runner.temp }}/retained-candidate
- name: Retain accepted installable candidate for separate approval
if: inputs.retain_installable
uses: actions/upload-artifact@v4
with:
name: installable-candidate-${{ github.run_number }}-${{ github.run_attempt }}
path: ${{ runner.temp }}/retained-candidate
if-no-files-found: error
compression-level: 0
retention-days: 1
- name: Record accepted identity
env:
CANDIDATE_COMMIT: ${{ needs.candidate.outputs.candidate_commit }}
MANIFEST_SHA256: ${{ needs.candidate.outputs.manifest_sha256 }}
run: |
printf 'Candidate: `%s`\n\nManifest SHA-256: `%s`\n\nLinux and Windows native acceptance passed. Publication requires separate approval.\n' \
"$CANDIDATE_COMMIT" "$MANIFEST_SHA256" >> "$GITHUB_STEP_SUMMARY"