diff --git a/.github/build-targets.json b/.github/build-targets.json new file mode 100644 index 00000000..8e553fd3 --- /dev/null +++ b/.github/build-targets.json @@ -0,0 +1,10 @@ +[ + {"os": "macos-15", "target": "aarch64-apple-darwin"}, + {"os": "macos-15-intel", "target": "x86_64-apple-darwin", "post_merge_only": true}, + {"os": "ubuntu-24.04", "target": "x86_64-unknown-linux-gnu"}, + {"os": "ubuntu-24.04-arm", "target": "aarch64-unknown-linux-gnu"}, + {"os": "ubuntu-24.04", "target": "x86_64-unknown-linux-musl"}, + {"os": "ubuntu-24.04-arm", "target": "aarch64-unknown-linux-musl"}, + {"os": "windows-2025", "target": "x86_64-pc-windows-msvc", "exe": ".exe"}, + {"os": "windows-11-arm", "target": "aarch64-pc-windows-msvc", "exe": ".exe"} +] diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3f8eddbc..7587aa8d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,6 +17,7 @@ jobs: runs-on: ubuntu-latest outputs: code: ${{ steps.diff.outputs.code }} + platforms: ${{ steps.platforms.outputs.platforms }} steps: - uses: actions/checkout@v4 with: @@ -32,6 +33,14 @@ jobs: else echo "code=false" >> "$GITHUB_OUTPUT" fi + # Every release target, from .github/build-targets.json. Pull requests skip the + # `post_merge_only` ones (macOS Intel: its runners queue for hours); pushes to main + # build them all (`installation-upgrade` → Release targets). + - id: platforms + env: + EVENT: ${{ github.event_name }} + run: | + echo "platforms=$(jq -c --arg event "$EVENT" '[.[] | select($event != "pull_request" or (.post_merge_only | not)) | del(.post_merge_only)]' .github/build-targets.json)" >> "$GITHUB_OUTPUT" rust: name: Rust (${{ matrix.os }}) @@ -233,27 +242,7 @@ jobs: strategy: fail-fast: false matrix: - include: - - os: macos-15 - target: aarch64-apple-darwin - - os: macos-15-intel - target: x86_64-apple-darwin - - os: ubuntu-24.04 - target: x86_64-unknown-linux-gnu - - os: ubuntu-24.04-arm - target: aarch64-unknown-linux-gnu - - os: ubuntu-24.04 - target: x86_64-unknown-linux-musl - - os: ubuntu-24.04-arm - target: aarch64-unknown-linux-musl - # Every release target builds on pull requests, so a tag never finds the - # first failure (`installation-upgrade` → Release targets). - - os: windows-2025 - target: x86_64-pc-windows-msvc - exe: .exe - - os: windows-11-arm - target: aarch64-pc-windows-msvc - exe: .exe + include: ${{ fromJSON(needs.changes.outputs.platforms) }} runs-on: ${{ matrix.os }} defaults: run: diff --git a/.github/workflows/non-git-snapshot-proof.yml b/.github/workflows/non-git-snapshot-proof.yml index 665848ac..fd24b0a7 100644 --- a/.github/workflows/non-git-snapshot-proof.yml +++ b/.github/workflows/non-git-snapshot-proof.yml @@ -83,6 +83,91 @@ on: - crates/cyber-core/src/worktrees/** - Cargo.lock - .github/workflows/non-git-snapshot-proof.yml + # Pull requests skip macOS Intel; it runs after merge. + push: + branches: [main] + paths: + - crates/cyber-snapshot/** + - crates/cyber-app/Cargo.toml + - crates/cyber-app/src/** + - crates/cyber-app/tests/support/scripted_model.rs + - crates/cyber-app/tests/support/snapshot*.rs + - crates/cyber-app/tests/support/managed_retirement_cut.rs + - crates/cyber-app/tests/support/managed_recovery_cut.rs + - crates/cyber-app/tests/support/location_retirement.rs + - crates/cyber-server/src/runtime/snapshot*.rs + - crates/cyber-server/src/runtime/snapshot_reclamation/** + - crates/cyber-server/src/runtime/rewind*.rs + - crates/cyber-server/src/runtime/drain.rs + - crates/cyber-server/src/runtime/structured*.rs + - crates/cyber-server/src/runtime/model.rs + - crates/cyber-server/src/runtime/mod.rs + - crates/cyber-server/src/runtime/events.rs + - crates/cyber-server/src/runtime/activity.rs + - crates/cyber-server/src/runtime/jobs.rs + - crates/cyber-server/src/runtime/input_jobs.rs + - crates/cyber-server/src/runtime/input_clients.rs + - crates/cyber-server/src/runtime/input_interrupt.rs + - crates/cyber-server/src/runtime/presence.rs + - crates/cyber-server/src/runtime/interactive.rs + - crates/cyber-server/src/runtime/goals/unattended.rs + - crates/cyber-server/tests/input_clients.rs + - crates/cyber-server/tests/input_interrupt.rs + - crates/cyber-server/tests/interactive_clients.rs + - crates/cyber-server/src/http/interactive.rs + - crates/cyber-server/src/runtime/process_jobs.rs + - crates/cyber-server/src/runtime/requests.rs + - crates/cyber-server/src/runtime/requests/** + - crates/cyber-server/tests/requests.rs + - crates/cyber-server/tests/jobs.rs + - crates/cyber-server/tests/structured_root.rs + - crates/cyber-server/tests/support/structured_terminal_fault.rs + - crates/cyber-server/src/http/sessions.rs + - crates/cyber-server/src/http/events.rs + - crates/cyber-server/src/http/jobs.rs + - crates/cyber-client/src/lib.rs + - crates/cyber-app/tests/snapshot_git_runtime.rs + - crates/cyber-app/tests/snapshot_reclamation.rs + - crates/cyber-app/tests/instructions.rs + - crates/cyber-core/src/config/** + - crates/cyber-core/src/rules.rs + - crates/cyber-core/src/import/snapshot.rs + - crates/cyber-core/src/memory/windows.rs + - crates/cyber-core/tests/import_snapshot.rs + - crates/cyber-core/src/import/mod.rs + - crates/cyber-core/src/lib.rs + - crates/cyber-core/tests/config.rs + - crates/cyber-tools/src/host.rs + - crates/cyber-tools/src/tools/fs.rs + - crates/cyber-tools/src/tools/patch.rs + - crates/cyber-tools/src/tools/agent.rs + - crates/cyber-tools/src/tools/background.rs + - crates/cyber-tools/tests/background_bash.rs + - crates/cyber-tools/tests/background_subagents.rs + - crates/cyber-server/src/runtime/auto_override.rs + - crates/cyber-tools/tests/instruction_config.rs + - crates/cyber-tools/tests/path_skills.rs + - crates/cyber-tools/tests/shell_patch.rs + - crates/cyber-server/src/runtime/context*.rs + - crates/cyber-server/src/runtime/instructions.rs + - crates/cyber-server/src/runtime/instructions/** + - crates/cyber-server/src/runtime/host.rs + - crates/cyber-server/tests/context_compaction.rs + - crates/cyber-server/tests/http.rs + - crates/cyber-tui/src/context_inspection.rs + - crates/cyber-server/tests/support/mod.rs + - crates/cyber-cli/Cargo.toml + - crates/cyber-cli/src/** + - crates/cyber-cli/tests/branches_cli.rs + - crates/cyber-cli/tests/exec_stream_input.rs + - crates/cyber-cli/tests/exec_output_schema.rs + - crates/cyber-cli/tests/support/** + - crates/cyber-server/src/workspace.rs + - crates/cyber-core/src/binary/native/** + - crates/cyber-core/src/binary/native.rs + - crates/cyber-core/src/worktrees/** + - Cargo.lock + - .github/workflows/non-git-snapshot-proof.yml workflow_dispatch: permissions: contents: read @@ -103,6 +188,10 @@ jobs: fail-fast: false matrix: os: [ubuntu-24.04, ubuntu-24.04-arm, macos-15, macos-15-intel] + # macOS Intel runners queue for hours: pull requests skip them, main and + # workflow_dispatch still run them. + exclude: + - os: ${{ github.event_name == 'pull_request' && 'macos-15-intel' || 'none' }} env: CARGO_INCREMENTAL: '0' CARGO_PROFILE_DEV_DEBUG: line-tables-only diff --git a/.github/workflows/plugin-admission-proof.yml b/.github/workflows/plugin-admission-proof.yml index 4f14886f..b3416613 100644 --- a/.github/workflows/plugin-admission-proof.yml +++ b/.github/workflows/plugin-admission-proof.yml @@ -30,6 +30,10 @@ jobs: fail-fast: false matrix: os: [macos-15, macos-15-intel] + # macOS Intel runners queue for hours: pull requests skip them, main and + # workflow_dispatch still run them. + exclude: + - os: ${{ github.event_name == 'pull_request' && 'macos-15-intel' || 'none' }} steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 diff --git a/.github/workflows/plugin-bootstrap-environment.yml b/.github/workflows/plugin-bootstrap-environment.yml index 4be1f1fe..f919a20d 100644 --- a/.github/workflows/plugin-bootstrap-environment.yml +++ b/.github/workflows/plugin-bootstrap-environment.yml @@ -34,6 +34,10 @@ jobs: fail-fast: false matrix: os: [ubuntu-24.04, ubuntu-24.04-arm, macos-15, macos-15-intel, windows-latest] + # macOS Intel runners queue for hours: pull requests skip them, main and + # workflow_dispatch still run them. + exclude: + - os: ${{ github.event_name == 'pull_request' && 'macos-15-intel' || 'none' }} env: CARGO_INCREMENTAL: 0 steps: diff --git a/.github/workflows/plugin-confinement-proof.yml b/.github/workflows/plugin-confinement-proof.yml index 9f7a5ed1..721cf403 100644 --- a/.github/workflows/plugin-confinement-proof.yml +++ b/.github/workflows/plugin-confinement-proof.yml @@ -34,6 +34,10 @@ jobs: matrix: os: [macos-15, macos-15-intel, ubuntu-24.04, ubuntu-24.04-arm] runtime: [node, python, bun, deno, native] + # macOS Intel runners queue for hours: pull requests skip them, main and + # workflow_dispatch still run them. + exclude: + - os: ${{ github.event_name == 'pull_request' && 'macos-15-intel' || 'none' }} steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 @@ -133,6 +137,10 @@ jobs: fail-fast: false matrix: os: [macos-15, macos-15-intel] + # macOS Intel runners queue for hours: pull requests skip them, main and + # workflow_dispatch still run them. + exclude: + - os: ${{ github.event_name == 'pull_request' && 'macos-15-intel' || 'none' }} steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 @@ -381,6 +389,10 @@ jobs: matrix: os: [macos-15, macos-15-intel] runtime: [node, python, python-system, bun, deno] + # macOS Intel runners queue for hours: pull requests skip them, main and + # workflow_dispatch still run them. + exclude: + - os: ${{ github.event_name == 'pull_request' && 'macos-15-intel' || 'none' }} steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 diff --git a/.github/workflows/plugin-native-launcher.yml b/.github/workflows/plugin-native-launcher.yml index 29693cd3..90366e13 100644 --- a/.github/workflows/plugin-native-launcher.yml +++ b/.github/workflows/plugin-native-launcher.yml @@ -34,6 +34,10 @@ jobs: fail-fast: false matrix: os: [macos-15, macos-15-intel, ubuntu-24.04, ubuntu-24.04-arm, windows-latest] + # macOS Intel runners queue for hours: pull requests skip them, main and + # workflow_dispatch still run them. + exclude: + - os: ${{ github.event_name == 'pull_request' && 'macos-15-intel' || 'none' }} env: CARGO_INCREMENTAL: 0 steps: diff --git a/.github/workflows/plugin-package-copy.yml b/.github/workflows/plugin-package-copy.yml index 3e1b8633..bbd70e07 100644 --- a/.github/workflows/plugin-package-copy.yml +++ b/.github/workflows/plugin-package-copy.yml @@ -34,6 +34,10 @@ jobs: fail-fast: false matrix: os: [ubuntu-24.04, ubuntu-24.04-arm, macos-15, macos-15-intel, windows-latest] + # macOS Intel runners queue for hours: pull requests skip them, main and + # workflow_dispatch still run them. + exclude: + - os: ${{ github.event_name == 'pull_request' && 'macos-15-intel' || 'none' }} env: CARGO_INCREMENTAL: 0 steps: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 21c88ac3..fdcc82ce 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -54,6 +54,7 @@ A pull request must pass: - The requirement inventory in `ROADMAP.md`: `python3 scripts/spec_inventory.py` after changing specs. - `openspec validate --all --strict` and `python3 scripts/spec_lint.py`. - The web dashboard and SDK builds and tests. +- A release build of every target in `.github/build-targets.json` except `x86_64-apple-darwin`. GitHub's macOS Intel runners queue for hours, so the Intel build and the Intel legs of the native proof workflows run after merge, on each push to `main`, and on manual (`workflow_dispatch`) runs. ## Pull requests diff --git a/openspec/changes/release-without-windows/proposal.md b/openspec/changes/archive/2026-11-17-release-without-windows/proposal.md similarity index 100% rename from openspec/changes/release-without-windows/proposal.md rename to openspec/changes/archive/2026-11-17-release-without-windows/proposal.md diff --git a/openspec/changes/release-without-windows/specs/installation-upgrade/spec.md b/openspec/changes/archive/2026-11-17-release-without-windows/specs/installation-upgrade/spec.md similarity index 100% rename from openspec/changes/release-without-windows/specs/installation-upgrade/spec.md rename to openspec/changes/archive/2026-11-17-release-without-windows/specs/installation-upgrade/spec.md diff --git a/openspec/changes/release-without-windows/tasks.md b/openspec/changes/archive/2026-11-17-release-without-windows/tasks.md similarity index 100% rename from openspec/changes/release-without-windows/tasks.md rename to openspec/changes/archive/2026-11-17-release-without-windows/tasks.md diff --git a/openspec/changes/build-intel-mac-after-merge/proposal.md b/openspec/changes/build-intel-mac-after-merge/proposal.md new file mode 100644 index 00000000..b4625eaa --- /dev/null +++ b/openspec/changes/build-intel-mac-after-merge/proposal.md @@ -0,0 +1,19 @@ +## Why + +GitHub's macOS Intel runners (`macos-15-intel`) queue for one to two hours, so the `x86_64-apple-darwin` build and the Intel legs of the native proof workflows dominate the time every pull request waits for CI. The other targets finish in minutes. An Intel-only build failure is rare, and finding it right after merge, still before any tag is pushed, keeps the guarantee the requirement exists for. + +## What Changes + +- `ci.yml` reads the CI build matrix from one checked-in list, `.github/build-targets.json` (the same 8 targets as `scripts/release_assets.py` `ALL_TARGETS`). The `changes` job emits it as an output; on pull requests it drops the entries marked `post_merge_only` (only `x86_64-apple-darwin`). Pushes to `main` build all 8. +- The native proof workflows exclude `macos-15-intel` from their matrices on `pull_request` and keep it on `push` to `main` and `workflow_dispatch`: + - `plugin-bootstrap-environment.yml`, `plugin-native-launcher.yml`, `plugin-package-copy.yml`, `plugin-admission-proof.yml` (still runs `macos-15` on pull requests); + - `plugin-confinement-proof.yml` (`native`, `macos-signing-candidate`, `macos-signing-runtime`; `macos-native-gap` already runs only on `workflow_dispatch`); + - `non-git-snapshot-proof.yml`, which ran only on pull requests and `workflow_dispatch`, gains a `push` to `main` trigger with the same paths, so its Intel leg still runs after merge. +- `release.yml` is unchanged: a release builds every released target, Intel included. +- `scripts/tests/test_release_workflow.py` checks the list matches `ALL_TARGETS`, that only `x86_64-apple-darwin` is post-merge-only, and runs the workflow's own `jq` filter for both events. + +## Impact + +- Spec: `installation-upgrade` → Release targets (modified: Intel macOS builds on each push to `main` instead of each pull request). +- CI: `.github/build-targets.json`, `.github/workflows/ci.yml` and the six proof workflows above. +- Docs: `CONTRIBUTING.md` (What CI checks). diff --git a/openspec/changes/build-intel-mac-after-merge/specs/installation-upgrade/spec.md b/openspec/changes/build-intel-mac-after-merge/specs/installation-upgrade/spec.md new file mode 100644 index 00000000..d751ded1 --- /dev/null +++ b/openspec/changes/build-intel-mac-after-merge/specs/installation-upgrade/spec.md @@ -0,0 +1,31 @@ +## MODIFIED Requirements + +### Requirement: Release targets +(P0) Each release SHALL publish static binaries for the following targets: +- `x86_64-unknown-linux-gnu`, `aarch64-unknown-linux-gnu` +- `x86_64-unknown-linux-musl`, `aarch64-unknown-linux-musl` +- `x86_64-apple-darwin`, `aarch64-apple-darwin` + +The Windows targets `x86_64-pc-windows-msvc` and `aarch64-pc-windows-msvc` SHALL NOT be published until Windows sandbox enforcement passes its release gate; CI SHALL still build and test them on each pull request, and one switch in `scripts/release_assets.py` (`WINDOWS_RELEASED`) SHALL add their archives, npm packages and Scoop/WinGet manifests back, labeled preview. Each binary SHALL be packaged as `cyber--.tar.gz` (`.zip` on Windows), with a SHA-256 checksum file and a Sigstore (cosign keyless) signature bundle. The release SHALL be produced by `.github/workflows/release.yml`, which SHALL run only when a `v` tag is pushed and SHALL fail when the tag differs from the workspace version. It SHALL upload the assets to the GitHub Release `v` (a prerelease unless the channel is `stable`) and replace `.json` on the rolling release `channel-` of the release source (→ Version and channel constants) only when the version is newer by semver than the one that manifest names; an older or equal tag SHALL be released without becoming the channel's (or GitHub's) latest. Releases SHALL run one at a time across tags. CI SHALL build every release target except `x86_64-apple-darwin`, Windows included, on each pull request, and every release target, `x86_64-apple-darwin` included, on each push to `main`, so a target that does not build is found before a tag is pushed. Signing SHALL not fail when a release has no `.zip` archive. + +Reason for change: Windows confinement is still partial (sandboxed Git Bash and PowerShell cannot start in the AppContainer), so 0.1.0 ships macOS and Linux only. The release is built by the repository's GitHub workflow and published to GitHub Releases, because the project's own host does not exist yet; building every target before a tag keeps a failing (preview) target from blocking a tag that is already pushed. GitHub's macOS Intel runners queue for one to two hours, so `x86_64-apple-darwin` builds after merge instead of on each pull request. + +#### Scenario: Release assets +- **WHEN** version 1.4.0 is released +- **THEN** the release contains 6 archives (macOS and Linux), `SHA256SUMS`, `SHA256SUMS.sigstore.json`, one `.sigstore.json` bundle per archive and `install.sh`, and `channel-stable` holds `stable.json` with version `1.4.0` + +#### Scenario: Backport release +- **WHEN** `stable.json` names 1.4.0 and the tag `v1.3.5` is pushed +- **THEN** the release `v1.3.5` is published, not marked latest, and `stable.json` still names 1.4.0 + +#### Scenario: Not on pull requests +- **WHEN** a pull request is opened or `main` is pushed +- **THEN** the release workflow does not run + +#### Scenario: Windows is built but not released +- **WHEN** a pull request changes Windows-only code and later version 0.1.0 is tagged +- **THEN** CI builds both Windows targets for the pull request, and the 0.1.0 release has no `.zip` archive, no `win32` npm package and no Scoop or WinGet manifest + +#### Scenario: Intel macOS builds after merge +- **WHEN** a pull request is opened and later merged to `main` +- **THEN** CI builds every release target except `x86_64-apple-darwin` for the pull request, and every release target, `x86_64-apple-darwin` included, for the push to `main` diff --git a/openspec/changes/build-intel-mac-after-merge/tasks.md b/openspec/changes/build-intel-mac-after-merge/tasks.md new file mode 100644 index 00000000..a38594a8 --- /dev/null +++ b/openspec/changes/build-intel-mac-after-merge/tasks.md @@ -0,0 +1,10 @@ +## 1. CI + +- [x] 1.1 `.github/build-targets.json` as the single CI build list; `ci.yml` `changes` job filters it on pull requests and `platforms` uses it via `fromJSON` +- [x] 1.2 Exclude `macos-15-intel` on pull requests in the proof workflows; add a `push` to `main` trigger to `non-git-snapshot-proof.yml` +- [x] 1.3 `scripts/tests/test_release_workflow.py`: list equals `ALL_TARGETS`, pull requests drop only `x86_64-apple-darwin` + +## 2. Specs and docs + +- [x] 2.1 Sync the spec delta into `openspec/specs/installation-upgrade` +- [x] 2.2 `CONTRIBUTING.md` What CI checks diff --git a/openspec/specs/installation-upgrade/spec.md b/openspec/specs/installation-upgrade/spec.md index eb1633e8..b781630d 100644 --- a/openspec/specs/installation-upgrade/spec.md +++ b/openspec/specs/installation-upgrade/spec.md @@ -11,9 +11,9 @@ Covers how `cyber` is distributed, installed, verified, kept up to date and remo - `x86_64-unknown-linux-musl`, `aarch64-unknown-linux-musl` - `x86_64-apple-darwin`, `aarch64-apple-darwin` -The Windows targets `x86_64-pc-windows-msvc` and `aarch64-pc-windows-msvc` SHALL NOT be published until Windows sandbox enforcement passes its release gate; CI SHALL still build and test them on each pull request, and one switch in `scripts/release_assets.py` (`WINDOWS_RELEASED`) SHALL add their archives, npm packages and Scoop/WinGet manifests back, labeled preview. Each binary SHALL be packaged as `cyber--.tar.gz` (`.zip` on Windows), with a SHA-256 checksum file and a Sigstore (cosign keyless) signature bundle. The release SHALL be produced by `.github/workflows/release.yml`, which SHALL run only when a `v` tag is pushed and SHALL fail when the tag differs from the workspace version. It SHALL upload the assets to the GitHub Release `v` (a prerelease unless the channel is `stable`) and replace `.json` on the rolling release `channel-` of the release source (→ Version and channel constants) only when the version is newer by semver than the one that manifest names; an older or equal tag SHALL be released without becoming the channel's (or GitHub's) latest. Releases SHALL run one at a time across tags. CI SHALL build every release target, Windows included, on each pull request, so a target that does not build is found before a tag is pushed. Signing SHALL not fail when a release has no `.zip` archive. +The Windows targets `x86_64-pc-windows-msvc` and `aarch64-pc-windows-msvc` SHALL NOT be published until Windows sandbox enforcement passes its release gate; CI SHALL still build and test them on each pull request, and one switch in `scripts/release_assets.py` (`WINDOWS_RELEASED`) SHALL add their archives, npm packages and Scoop/WinGet manifests back, labeled preview. Each binary SHALL be packaged as `cyber--.tar.gz` (`.zip` on Windows), with a SHA-256 checksum file and a Sigstore (cosign keyless) signature bundle. The release SHALL be produced by `.github/workflows/release.yml`, which SHALL run only when a `v` tag is pushed and SHALL fail when the tag differs from the workspace version. It SHALL upload the assets to the GitHub Release `v` (a prerelease unless the channel is `stable`) and replace `.json` on the rolling release `channel-` of the release source (→ Version and channel constants) only when the version is newer by semver than the one that manifest names; an older or equal tag SHALL be released without becoming the channel's (or GitHub's) latest. Releases SHALL run one at a time across tags. CI SHALL build every release target except `x86_64-apple-darwin`, Windows included, on each pull request, and every release target, `x86_64-apple-darwin` included, on each push to `main`, so a target that does not build is found before a tag is pushed. Signing SHALL not fail when a release has no `.zip` archive. -Reason for change: Windows confinement is still partial (sandboxed Git Bash and PowerShell cannot start in the AppContainer), so 0.1.0 ships macOS and Linux only. The release is built by the repository's GitHub workflow and published to GitHub Releases, because the project's own host does not exist yet; building every target on pull requests keeps a failing (preview) target from blocking a tag that is already pushed. +Reason for change: Windows confinement is still partial (sandboxed Git Bash and PowerShell cannot start in the AppContainer), so 0.1.0 ships macOS and Linux only. The release is built by the repository's GitHub workflow and published to GitHub Releases, because the project's own host does not exist yet; building every target before a tag keeps a failing (preview) target from blocking a tag that is already pushed. GitHub's macOS Intel runners queue for one to two hours, so `x86_64-apple-darwin` builds after merge instead of on each pull request. #### Scenario: Release assets - **WHEN** version 1.4.0 is released @@ -31,6 +31,10 @@ Reason for change: Windows confinement is still partial (sandboxed Git Bash and - **WHEN** a pull request changes Windows-only code and later version 0.1.0 is tagged - **THEN** CI builds both Windows targets for the pull request, and the 0.1.0 release has no `.zip` archive, no `win32` npm package and no Scoop or WinGet manifest +#### Scenario: Intel macOS builds after merge +- **WHEN** a pull request is opened and later merged to `main` +- **THEN** CI builds every release target except `x86_64-apple-darwin` for the pull request, and every release target, `x86_64-apple-darwin` included, for the push to `main` + ### Requirement: Install script (P0) The install script SHALL be published as the release asset `install.sh`, reachable for the default release source at `https://github.com/CyberdyneCorp/cybercode-cli/releases/latest/download/install.sh`, and SHALL be a POSIX `sh` script that: 1. detects OS, CPU and libc (musl on Alpine) diff --git a/scripts/release_assets.py b/scripts/release_assets.py index 5fe02e4f..19e6b349 100644 --- a/scripts/release_assets.py +++ b/scripts/release_assets.py @@ -35,7 +35,7 @@ ROOT = Path(__file__).resolve().parent.parent DEFAULT_BASE_URL = "https://github.com/CyberdyneCorp/cybercode-cli/releases/download" -# Every target CI builds, in `ci.yml` order, then Windows. +# Every target CI builds, in `.github/build-targets.json` order, then Windows. ALL_TARGETS = [ "aarch64-apple-darwin", "x86_64-apple-darwin", diff --git a/scripts/tests/test_release_workflow.py b/scripts/tests/test_release_workflow.py index 92aee397..c15cd762 100644 --- a/scripts/tests/test_release_workflow.py +++ b/scripts/tests/test_release_workflow.py @@ -1,7 +1,10 @@ """`.github/workflows/release.yml` (`installation-upgrade` → Release targets "Not on pull requests"), checked as text: YAML 1.1 parsers read the `on` key as a boolean.""" +import json import re +import shutil +import subprocess import sys import unittest from pathlib import Path @@ -10,6 +13,13 @@ import release_assets as ra # noqa: E402 WORKFLOW = ra.ROOT / ".github" / "workflows" / "release.yml" +CI = ra.ROOT / ".github" / "workflows" / "ci.yml" +BUILD_TARGETS = ra.ROOT / ".github" / "build-targets.json" + + +def build_targets() -> list[dict]: + """The CI build matrix (`ci.yml` → platforms), before the pull-request filter.""" + return json.loads(BUILD_TARGETS.read_text()) def top_level_block(text: str, key: str) -> str: @@ -55,13 +65,34 @@ def test_signing_tolerates_a_release_without_zip_archives(self): sign = publish[publish.index("name: Sign") :] self.assertLess(sign.index("shopt -s nullglob"), sign.index("dist/*.zip")) - def test_ci_builds_every_release_target_on_pull_requests(self): + def test_ci_builds_every_release_target(self): """Regression: a target only the release builds fails after the tag is pushed.""" - ci = (ra.ROOT / ".github" / "workflows" / "ci.yml").read_text() - platforms = jobs(ci)["platforms"] - targets = re.findall(r"^\s+target: ([a-z0-9_-]+)$", platforms, re.M) - self.assertEqual(targets, ra.ALL_TARGETS) + platforms = jobs(CI.read_text())["platforms"] + self.assertIn("include: ${{ fromJSON(needs.changes.outputs.platforms) }}", platforms) self.assertIn("--release --workspace --bins", platforms) + self.assertEqual([e["target"] for e in build_targets()], ra.ALL_TARGETS) + + def test_pull_requests_skip_only_intel_mac(self): + """macOS Intel runners queue for hours, so only that target waits for main.""" + later = [e["target"] for e in build_targets() if e.get("post_merge_only")] + self.assertEqual(later, ["x86_64-apple-darwin"]) + + @unittest.skipUnless(shutil.which("jq"), "jq not installed") + def test_ci_filter_drops_intel_mac_on_pull_requests_only(self): + changes = jobs(CI.read_text())["changes"] + program = re.search(r"jq -c --arg event \"\$EVENT\" '([^']+)' \.github/build-targets\.json", changes) + self.assertTrue(program, "the changes job does not filter .github/build-targets.json") + + def matrix(event: str) -> list[dict]: + out = subprocess.run(["jq", "-c", "--arg", "event", event, program[1], str(BUILD_TARGETS)], + capture_output=True, text=True, check=True).stdout + return json.loads(out) + + on_main = matrix("push") + self.assertEqual([e["target"] for e in on_main], ra.ALL_TARGETS) + self.assertTrue(all("post_merge_only" not in e for e in on_main)) + self.assertEqual([e["target"] for e in matrix("pull_request")], + [t for t in ra.ALL_TARGETS if t != "x86_64-apple-darwin"]) def test_actions_are_pinned_by_commit(self): uses = re.findall(r"uses: (\S+)", self.text)