Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .apm/instructions/cicd.instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ integration suite runs only at merge time via GitHub Merge Queue
6. **`main-architecture-ratchets.yml`** - `push` to main only
- Re-runs ci.yml's `test-architecture-contracts` job (check `Architecture Ratchet Contracts (main)`), so a change that reaches main without a `merge_group` run cannot leave main silently red on the ratchet contracts.
- Never opts into provisional baselines. `tests/quality/test_ci_topology.py` pins the job to ci.yml's, so the two cannot drift.
7. **`owner-surface.yml`** - `pull_request` and `merge_group`
- `Owner Surface Check` runs the integration slice an owner or install-path change can reach (`scripts/owner_surface.py`: owner-rule mutation cases and `test_architecture_*.py` files naming a changed file or affected owner, guard or rule, plus `test_install_*.py` for install changes), in 3 shards. No `paths:` filter: it always reports, and passes when the slice is skipped and on merge_group.
- Advisory: it is not in `EXPECTED_CHECKS`. Making it required is a maintainer gate.

## Platform Testing Strategy
- **PR time**: Linux-only combined build-and-test in `ci.yml`. Catches logic bugs and dependency issues before merge. Windows is tested on every push to main; macOS and full integration run nightly, on dispatch and on release tags.
Expand Down
3 changes: 3 additions & 0 deletions .github/instructions/cicd.instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ integration suite runs only at merge time via GitHub Merge Queue
6. **`main-architecture-ratchets.yml`** - `push` to main only
- Re-runs ci.yml's `test-architecture-contracts` job (check `Architecture Ratchet Contracts (main)`), so a change that reaches main without a `merge_group` run cannot leave main silently red on the ratchet contracts.
- Never opts into provisional baselines. `tests/quality/test_ci_topology.py` pins the job to ci.yml's, so the two cannot drift.
7. **`owner-surface.yml`** - `pull_request` and `merge_group`
- `Owner Surface Check` runs the integration slice an owner or install-path change can reach (`scripts/owner_surface.py`: owner-rule mutation cases and `test_architecture_*.py` files naming a changed file or affected owner, guard or rule, plus `test_install_*.py` for install changes), in 3 shards. No `paths:` filter: it always reports, and passes when the slice is skipped and on merge_group.
- Advisory: it is not in `EXPECTED_CHECKS`. Making it required is a maintainer gate.

## Platform Testing Strategy
- **PR time**: Linux-only combined build-and-test in `ci.yml`. Catches logic bugs and dependency issues before merge. Windows is tested on every push to main; macOS and full integration run nightly, on dispatch and on release tags.
Expand Down
140 changes: 140 additions & 0 deletions .github/workflows/owner-surface.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
# Owner Surface -- a cheap PR check for owner and install-path changes.
#
# Today's main reds (the lockfile-read owner test after #4067, the codex
# bundle e2e after #4007) lived in integration shards that run only on
# merge_group or dispatch. This workflow runs, on every pull request, only the
# slice of those shards a change can reach (scripts/owner_surface.py):
# - owner surfaces: src/apm_cli/install/*, src/apm_cli/deps/lockfile*,
# .apm/architecture/*, scripts/architecture_linter/*,
# tests/integration/test_architecture_*.py, tests/integration/test_install_*.py,
# and every file an owner registry selector names;
# - slice: owner-rule mutation cases and architecture tests that name a
# changed file or an affected owner, guard or rule, plus every
# tests/integration/test_install_*.py file for install-path changes.
# The full integration suite still runs once per train head (merge_group,
# merge-train refs), never per pull request. scripts/owner_surface.py splits
# the slice into the 3 shards itself: scripts.ci_sharding refuses empty
# shards, so a slice too small to split runs whole on shard 1.
#
# `Owner Surface Check` always reports, so it can be required: it passes when
# no owner surface changed (the slice is skipped) and on merge_group, where
# ci-integration.yml runs the whole suite. It is NOT required yet; making it
# required (merge-gate.yml EXPECTED_CHECKS) is a maintainer gate.
name: Owner Surface

# No paths: filter: a filtered-out run would never report the check.
on:
pull_request:
branches: [ main ]
merge_group:
branches: [ main ]
types: [ checks_requested ]

# Superseded pushes to a PR cancel their run; merge_group runs never cancel.
concurrency:
group: owner-surface-${{ github.event.pull_request.number || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

permissions:
contents: read

env:
PYTHON_VERSION: '3.12'
HERMETIC_MARK_EXPR: "not live and not requires_github_token and not requires_network_integration"

jobs:
select:
name: Owner Surface Select
runs-on: ubuntu-24.04
timeout-minutes: 5
outputs:
run: ${{ steps.plan.outputs.run }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false

- name: Plan the owner-surface slice
id: plan
env:
EVENT: ${{ github.event_name }}
BASE_SHA: ${{ github.event.pull_request.base.sha }}
run: |
if [ "$EVENT" != pull_request ]; then
echo "run=false" >> "$GITHUB_OUTPUT"
echo "$EVENT: ci-integration.yml runs the whole integration suite here."
exit 0
fi
python3 -m scripts.owner_surface plan --base "$BASE_SHA" --out owner-surface-changed.txt

slice:
name: Owner Surface Slice (${{ matrix.shard }}/3)
needs: [select]
if: needs.select.outputs.run == 'true'
runs-on: ubuntu-24.04
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
shard: [1, 2, 3]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false

- name: Set up Python
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Install uv
uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
with:
enable-cache: true
save-cache: false

- name: Install dependencies
run: uv sync --frozen --extra dev

- name: Run the owner-surface slice
env:
APM_E2E_TESTS: "1"
BASE_SHA: ${{ github.event.pull_request.base.sha }}
SHARD: ${{ matrix.shard }}
run: |
python3 -m scripts.owner_surface plan --base "$BASE_SHA" --out owner-surface-changed.txt
uv run --frozen --extra dev python -m scripts.owner_surface run \
--base "$BASE_SHA" --changed owner-surface-changed.txt \
--shard "$SHARD/3" --durations .github/ci-durations/linux-x86_64.json -- \
-p no:cacheprovider -m "$HERMETIC_MARK_EXPR" -n 4 --dist loadgroup --durations=15

owner-surface:
name: Owner Surface Check
needs: [select, slice]
if: always()
runs-on: ubuntu-24.04
timeout-minutes: 2
permissions: {}
steps:
- name: Require the selected slice
env:
SELECT_RESULT: ${{ needs.select.result }}
RUN: ${{ needs.select.outputs.run }}
SLICE_RESULT: ${{ needs.slice.result }}
run: |
if [ "$SELECT_RESULT" != success ]; then
echo "::error::Owner-surface selection did not succeed: $SELECT_RESULT."
exit 1
fi
if [ "$RUN" = true ]; then
expected=success
else
expected=skipped
fi
if [ "$SLICE_RESULT" != "$expected" ]; then
echo "::error::Owner-surface slice is $SLICE_RESULT (expected $expected, run=$RUN)."
exit 1
fi
echo "Owner Surface Check passed (run=$RUN, slice=$SLICE_RESULT)."
4 changes: 2 additions & 2 deletions apm.lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions docs/src/content/docs/contributing/integration-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,19 @@ APM uses a tiered approach to integration testing:
-m 'lifecycle_smoke and not lifecycle_merge_group' tests/integration
```

### 3b. **Owner Surface Check** (PR-time, advisory until required)
- **Location**: `.github/workflows/owner-surface.yml`, selection in `scripts/owner_surface.py`.
- **Purpose**: run, on every pull request, the slice of the merge-time integration suite that an owner or install-path change can break. Owner-guard and install regressions then show on the PR, not on `main`.
- **Trigger**: a change to `src/apm_cli/install/*`, `src/apm_cli/deps/lockfile*`, `.apm/architecture/*`, `scripts/architecture_linter/*`, `tests/integration/test_architecture_*.py`, `tests/integration/test_install_*.py`, or any file an owner registry selector names.
- **Slice**: owner-rule mutation cases and `test_architecture_*.py` files that name a changed file or an affected owner, guard or rule; plus every `test_install_*.py` file for install-path changes. It runs hermetic tests in 3 duration-balanced shards (target under 10 min).
- **Result**: `Owner Surface Check` always reports. It passes when no owner surface changed (the slice is skipped) and on merge_group, where the full suite runs.
- **Run it locally**:
```bash
python3 -m scripts.owner_surface plan --base origin/main --out /tmp/changed.txt
APM_E2E_TESTS=1 uv run --extra dev python -m scripts.owner_surface run \
--base origin/main --changed /tmp/changed.txt -- -n 4 --dist loadgroup
```

### 4. **Live Guardrailing Hero** (scheduled/manual)
- **Location**: `tests/integration/test_guardrailing_hero_e2e.py`
- **Purpose**: Preserve the real remote, token-gated packaged CLI hero without multiplying it across the default packaged platform matrix
Expand Down
Loading