Files
agent-pet-companion/.github/workflows/ci.yml
T
2026-08-10 18:41:19 +08:00

117 lines
4.0 KiB
YAML

name: CI
on:
pull_request:
push:
branches: [main]
permissions:
contents: read
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
quality:
name: Change-scoped quality and packaging
runs-on: macos-15
timeout-minutes: 45
env:
APC_VALIDATE_HOST_UI: "0"
APC_VALIDATE_REAL_AGENT_CONNECTORS: "0"
APC_VALIDATE_REAL_APP_SERVER: "0"
CARGO_TERM_COLOR: always
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Resolve validation base
id: validation_base
env:
EVENT_NAME: ${{ github.event_name }}
PR_BASE: ${{ github.event.pull_request.base.sha }}
PUSH_BASE: ${{ github.event.before }}
run: |
if [[ "$EVENT_NAME" == "pull_request" ]]; then
base="$PR_BASE"
else
base="$PUSH_BASE"
fi
if [[ "$base" == "0000000000000000000000000000000000000000" ]]; then
base="$(git rev-parse HEAD^ 2>/dev/null || git rev-parse HEAD)"
fi
git rev-parse --verify "$base^{commit}" >/dev/null
echo "base=$base" >>"$GITHUB_OUTPUT"
- name: Classify changed paths once
id: validation_scope
run: |
./script/validation_scope.py \
--base-ref "${{ steps.validation_base.outputs.base }}" \
--format github >>"$GITHUB_OUTPUT"
- name: Install common validation tooling
run: |
if ! command -v rg >/dev/null 2>&1; then
brew install ripgrep
fi
rg --version
- name: Verify required toolchains
if: steps.validation_scope.outputs.bundle == '1' || steps.validation_scope.outputs.rust_mode != 'none' || steps.validation_scope.outputs.swift_mode != 'none'
run: |
swift --version
xcrun --show-sdk-path
test "$(swift --version | awk '/Apple Swift version/{split($4, v, "."); print v[1]}')" -ge 6
rustup show
- name: Cache Rust and Swift build products
if: steps.validation_scope.outputs.docs_only != '1'
uses: actions/cache@v6
with:
path: |
~/.cargo/registry
~/.cargo/git
target
apps/macos/.build
key: ${{ runner.os }}-${{ runner.arch }}-apc-${{ hashFiles('rust-toolchain.toml', 'Cargo.lock', 'apps/macos/Package.swift', 'apps/macos/Package.resolved') }}
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-apc-
- name: Run unified change-scoped validation
run: |
./script/validate_pre_push.sh \
--base "${{ steps.validation_base.outputs.base }}" \
--ci
- name: Build and fully validate development App when runtime inputs changed
if: steps.validation_scope.outputs.bundle == '1'
run: ./script/build_app_bundle.sh --configuration debug --validation full
- name: Record live UI validation routing
run: |
if [[ "${{ steps.validation_scope.outputs.computer_use }}" == "recommended" ]]; then
echo 'UI source changed: Computer Use is recommended for a human-owned acceptance session, but is never auto-run in CI.' >>"$GITHUB_STEP_SUMMARY"
else
echo 'No live UI or Computer Use validation is required for this change scope.' >>"$GITHUB_STEP_SUMMARY"
fi
- name: Reject tracked build output and caches
run: |
tracked_generated="$(
git ls-files \
| grep -E '(^|/)(__pycache__/|[^/]+\.py[co]$|DerivedData/|target/|\.build/|[^/]+\.petpack$|generation-jobs/)' \
| grep -Ev '^apps/macos/Sources/AgentPetCompanion/Resources/BuiltInPets/(pet_bytebudcodex|pet_xingwutuanzi)\.petpack$' \
|| true
)"
if [[ -n "$tracked_generated" ]]; then
printf '%s\n' "$tracked_generated"
echo 'Tracked generated output or cache detected' >&2
exit 1
fi
- name: Verify clean generated state
run: git diff --check