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
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ permissions:
contents: read

# The newest push on a pull request wins. Every commit on main keeps its own run, for the badge and
# for the release: publishing a release relies on main's CI having passed on the commit the release
# PR merged onto (scripts/release-ci-gate.ts). In one group, a push landing while another commit's
# run was in progress replaced the pending run of the commit before it, and that commit never got a
# result.
# for the release: publishing a release relies on main's CI having passed on a commit whose tree
# differs from the release's only in what it runs again (scripts/release-ci-gate.ts). In one group,
# a push landing while another commit's run was in progress replaced the pending run of the commit
# before it, and that commit never got a result.
#
# `github.workflow` keeps the release's own call of these checks out of main's group. A called
# workflow sees its caller's context, so without it Publish release's checks shared
Expand Down
105 changes: 83 additions & 22 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -253,40 +253,53 @@ jobs:
echo "becomes_latest=$becomes_latest" >> "$GITHUB_OUTPUT"
echo "$VERSION becomes the latest release: $becomes_latest."

# Whether the full CI suite runs again on the release commit (scripts/release-ci-gate.ts). A release
# PR that changes only the release files (the versions, CHANGELOG.md and release-policy.json),
# merged onto a commit main's CI passed, has a tree that has already been through every check, so
# `checks` below is skipped and that run stands in for it. Anything else in the diff, or a parent
# whose CI did not pass, runs the full suite as before. When the suite is skipped, the checks CI
# makes that read the release files run here instead, so a changelog or policy edited in the
# release PR is still held to them.
# What runs on the release commit (scripts/release-ci-gate.ts): no test runs again on a tree that
# already passed it. The gate looks for a commit whose CI passed (the release commit itself, its
# first parents, or main's) and whose tree differs from the release commit's in nothing a run
# would check differently, and runs only the difference:
#
# - `reuse`, the same tree, a revert back to a tree that passed included: nothing runs again, but
# the support window, which counts from the day of the release.
# - `release-files`, only the versions, CHANGELOG.md and release-policy.json differ: the checks
# that read them run here.
# - `tests`, only those and the suite's test files differ: the release-file checks and types run
# here, and the changed tests, in each engine they run in, in `release tests`.
# - `full`, anything else, or anything it cannot read: `checks` below runs the full suite.
gate:
name: checks needed
needs: [metadata, verify]
if: needs.metadata.outputs.is_release == 'true'
runs-on: ubuntu-latest
# The decision waits up to 10 minutes for main's CI on the parent while it is still running
# The decision waits up to 10 minutes for CI still running on a commit that would stand in
# (MAX_WAIT_SECONDS in the script), then the release-file checks below run.
timeout-minutes: 20
permissions:
contents: read
# To read main's CI runs.
# To read the CI runs that stand in.
actions: read
outputs:
full_checks: ${{ steps.decide.outputs.full_checks }}
mode: ${{ steps.decide.outputs.mode }}
tests: ${{ steps.decide.outputs.tests }}
browser_tests: ${{ steps.decide.outputs.browser_tests }}
webkit_tests: ${{ steps.decide.outputs.webkit_tests }}
desktop_browser_tests: ${{ steps.decide.outputs.desktop_browser_tests }}
steps:
# The release commit and its parent, which the decision compares.
# The release commit and the history it is compared with: its own first parents, and main's
# for a release branch. Without file contents, which the decision fetches for the few files it
# reads; the release commit's own tree is checked out whole.
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.sha }}
fetch-depth: 2
fetch-depth: 0
filter: blob:none
persist-credentials: false
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
with:
bun-version: 1.4.3
no-cache: true
- id: decide
name: Decide whether the full checks run again
name: Decide what runs again
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: bun scripts/release-ci-gate.ts "$GITHUB_SHA"
Expand All @@ -295,18 +308,22 @@ jobs:
# CI's `format, lint, types` job formats and lints package.json and the policy, and checks the
# versions the release moved still agree with each other.
- name: Format and lint
if: steps.decide.outputs.full_checks == 'false'
if: steps.decide.outputs.mode == 'release-files' || steps.decide.outputs.mode == 'tests'
run: |
set -euo pipefail
bun run format:check
bun run lint
# The changed tests are type checked, as CI's `format, lint, types` would.
- name: Types
if: steps.decide.outputs.mode == 'tests'
run: bun run typecheck
- name: Desktop version tracks the release version
if: steps.decide.outputs.full_checks == 'false'
if: steps.decide.outputs.mode == 'release-files' || steps.decide.outputs.mode == 'tests'
run: bun desktop/scripts/desktop-version.ts check
# Every test that reads the changelog or the policy, found by name so a new one is included
# without anybody adding it here.
- name: The tests that read CHANGELOG.md and release-policy.json
if: steps.decide.outputs.full_checks == 'false'
if: steps.decide.outputs.mode == 'release-files' || steps.decide.outputs.mode == 'tests'
run: |
set -euo pipefail
tests=()
Expand All @@ -329,9 +346,50 @@ jobs:
if: steps.decide.outputs.full_checks == 'false'
run: bun scripts/support-window.ts check --releases "$RUNNER_TEMP/releases.json"

# The same checks CI runs, against the commit being published, unless `gate` found the release
# commit is the release files on a commit main's CI passed. This or that run is the gate: nothing is
# built or tagged unless one of them passed on this tree.
# The test files the release commit changed from the tree whose CI passed, with every test that
# names one, when `gate` found nothing else changed: each in the engines CI runs it in, as CI's
# `tests (changed files)` runs them (scripts/ci-run-tests.ts). A browser test runs in Chromium, and
# in WebKit too when it asks for it; the desktop setup window's from desktop/.
release-tests:
name: release tests
needs: [metadata, verify, gate]
if: needs.metadata.outputs.is_release == 'true' && needs.gate.outputs.mode == 'tests'
runs-on: ubuntu-latest
timeout-minutes: 25 # installs the browsers it needs, then runs a few files
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.sha }}
persist-credentials: false
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
with:
bun-version: 1.4.3
no-cache: true
# The same installs as CI's, since a changed file can be anywhere the suite looks.
- run: bun install --frozen-lockfile
- run: bun install --frozen-lockfile
working-directory: agent-mastra
- run: bun install --frozen-lockfile
working-directory: desktop
- name: Install Chromium
if: needs.gate.outputs.browser_tests != '[]' || needs.gate.outputs.desktop_browser_tests != '[]'
run: bunx playwright-core install --with-deps --no-shell chromium
- name: Install WebKit
if: needs.gate.outputs.webkit_tests != '[]'
run: bunx playwright-core install --with-deps webkit
- name: Run the changed tests
env:
TESTS: ${{ needs.gate.outputs.tests }}
BROWSER_TESTS: ${{ needs.gate.outputs.browser_tests }}
WEBKIT_TESTS: ${{ needs.gate.outputs.webkit_tests }}
DESKTOP_BROWSER_TESTS: ${{ needs.gate.outputs.desktop_browser_tests }}
run: bun scripts/ci-run-tests.ts

# The same checks CI runs, against the commit being published, unless `gate` found a tree whose CI
# passed that differs from this one only in the release files and tests. This or that run is the
# gate: nothing is built or tagged unless one of them passed on this tree.
checks:
needs: [metadata, verify, gate]
if: needs.metadata.outputs.is_release == 'true' && needs.gate.outputs.full_checks == 'true'
Expand All @@ -354,15 +412,18 @@ jobs:
# decision made in `verify`, the same one that marks the GitHub release Latest: whoever pulls
# `latest` gets the newest stable release, never a candidate, a beta or an older patch.
#
# After `checks` passed, or after `gate` passed having decided `checks` need not run. Nothing else:
# a `checks` skipped for any other reason, or a `gate` that failed, publishes nothing.
# After `checks` passed, or after `gate` passed having decided `checks` need not run, and the
# changed tests passed when it decided they run. Nothing else: a `checks` or `release tests`
# skipped for any other reason, or a `gate` that failed, publishes nothing.
images:
needs: [metadata, verify, gate, checks]
needs: [metadata, verify, gate, release-tests, checks]
if: >-
!cancelled() && needs.metadata.outputs.is_release == 'true' &&
needs.verify.result == 'success' && needs.gate.result == 'success' &&
(needs.checks.result == 'success' ||
(needs.checks.result == 'skipped' && needs.gate.outputs.full_checks == 'false'))
(needs.checks.result == 'skipped' && needs.gate.outputs.full_checks == 'false' &&
(needs.release-tests.result == 'success' ||
(needs.release-tests.result == 'skipped' && needs.gate.outputs.mode != 'tests'))))
uses: $/.github/workflows/images.yml
with:
ref: ${{ github.sha }}
Expand Down
81 changes: 56 additions & 25 deletions docs/releasing.md
Original file line number Diff line number Diff line change
Expand Up @@ -1026,8 +1026,9 @@ Then, in order:
- the version in the tree is checked against the branch that is publishing it, and the changelog is
checked for a section with that number
- the commit is checked, as described under [What has to be green](#what-has-to-be-green): the full
CI suite, or, when the release PR changed only the release files on a commit main's CI passed,
that run and the checks that read the release files
CI suite, or, when a commit CI passed has a tree that differs from the release commit's only in
the release files and tests, that run and only what differs: nothing for the same tree, the checks
that read the release files, and the changed tests
- the OpenBot images, `ghcr.io/copilotkit/openbot` (the server and every Bot's computer) and
`openbot-supervisor`, are taken at the tag `backend-images.env` names, the release's version,
and pinned by digest in `container-images.json`, where `openbot`, `server` and `agent-computer`
Expand Down Expand Up @@ -1140,29 +1141,59 @@ and refuses to publish without (see [What merging does](#what-merging-does)).
These checks gate the publish rather than the proposal, which is why the release PR arriving
without its own checks does not matter: a pull request opened by a workflow does not trigger them.
When the release PR merges, the publish workflow's `checks needed` job
([`scripts/release-ci-gate.ts`](../scripts/release-ci-gate.ts)) decides whether they run again on the
release commit:

- When the release commit changes nothing but the release files from the commit it merged onto
(its first parent), and main's CI passed on that commit, they do not. That commit's tree has been
through all of them already. The release files are `CHANGELOG.md` and `release-policy.json`, which
may change freely, and the `version` in `package.json`, the `OPENBOT_BACKEND_TAG` line in
`backend-images.env` and the `openbot-desktop` version line in
`desktop/src-tauri/Cargo.toml` and `Cargo.lock`, which may change nothing else. Only a run of `ci.yml` for a push to this repository's `main`, at
exactly that commit, counts; a pull request's run tests a merge of the PR, not the commit, and
skips the component dockerfile checks unless it was labelled `full-ci`. A run still in progress is waited for, up to 10 minutes; past that the full checks run. In
their place the job re-runs the checks that read the files the release did change: formatting and
lint, the desktop version against `package.json`, and every test that names
`CHANGELOG.md` or `release-policy.json`.
- Otherwise they all run again, as before: when any other path is added, removed, renamed or
changed, when a version file changes more than its version, or when main's CI on that commit
failed, was cancelled, never ran, could not be read, or was still running after the wait.

The diff is read with renames turned off, so a source file moved onto a release file's name is still
seen as the source file it removed. Every commit on `main` keeps its own CI run for this (the
`concurrency` group in `ci.yml` is per commit on `main`), so a commit pushed while another's run was
in progress still gets a result. A final's parent is its candidate on `release/X.Y`, which main's CI
never ran on, so a final always runs the full suite.
([`scripts/release-ci-gate.ts`](../scripts/release-ci-gate.ts)) decides what runs again on the
release commit. A test is never run again on code that already passed it: the job looks for a
commit whose CI passed and whose tree differs from the release commit's in nothing a run would check
differently, and runs only the difference.

The commits it looks at are the release commit itself, its first parents (along `main`, or along the
`release/X.Y` branch it publishes on) and `main`'s first parents, 50 of each. It compares trees, not
history, so a revert back to a tree that passed is that tree, and a candidate that carries main's tree
at a commit is that commit's tree. Of the commits that qualify, it uses the one that leaves the least
to run, then the nearest:

- **Same tree.** CI already passed on exactly this tree, on the release commit itself (a second
attempt at the publish, once main's run of it passed, or the merge queue's run) or on any commit
with the same tree, such as the commit before a change that was then reverted. Nothing runs again
but the 12-month support window, which counts from the day of the release.
- **Release files only.** The trees differ only in the release files: `CHANGELOG.md` and
`release-policy.json`, which may change freely, and the `version` in `package.json`, the
`OPENBOT_BACKEND_TAG` line in `backend-images.env` and the `openbot-desktop` version line in
`desktop/src-tauri/Cargo.toml` and `Cargo.lock`, which may change nothing else. The job runs the
checks that read them: formatting and lint, the desktop version against `package.json`, every
test that names `CHANGELOG.md` or `release-policy.json`, and the support window.
- **Release files and tests.** The trees differ only in those and in the suite's test files, each
added or changed, none deleted. The job runs the release-file checks and type checks the tree, and
`release tests` runs the changed test files, with every test that names one, in each engine CI
runs them in: `bun test`, a real Chromium for a browser test, WebKit as well for one on the
WebKit job's list in `ci.yml` or that asks for it, and the desktop setup window's browser for one
under `desktop/` ([`scripts/ci-run-tests.ts`](../scripts/ci-run-tests.ts)).
- **Anything else: the full suite.** Any other path added, removed, renamed or changed (the app,
`shared/`, `desktop/src-tauri`, the server-facing code, a workflow, a fixture, a Python harness's
or the TypeScript engine's test, the docs), a deleted test, a version file that changes more than
its version, a diff or a list of engines that could not be read, or no such commit whose CI passed.

A commit's CI passed when one run that tested it finished with every job succeeded or skipped: a run
of `ci.yml` for a push to this repository's `main` or main's merge queue at exactly that commit, or a
Publish release run at that commit whose own `checks` ran and passed (`checks / verify`). A pull
request's run tests a merge of the PR, not the commit, so it never counts, and neither does the
publish deciding. A run still in progress on an older commit is waited for, up to 10 minutes, unless
another commit that qualifies has already passed; past that the full suite runs. main's push run of the release
commit itself is not waited for: it is the full suite on this tree, just started, and waiting would
only start the same suite later. CI that cannot be read means the full suite.

On v1.2.10 this would have run one changed test and the one test that names it. Its last release PR
sat on a revert of a change taken back out of the release, and changed one browser test, so its tree
differs from the last commit CI passed before that change only in the release files and that test.
Each of its publishes ran the whole suite instead, and the same flaky WebKit crash failed each one.

The diff is read with renames turned off, so a source file moved onto a release file's or a test's
name is still seen as the source file it removed. Every commit on `main` keeps its own CI run for
this (the `concurrency` group in `ci.yml` is per commit on `main`), so a commit pushed while another's
run was in progress still gets a result. A final's parent is its candidate on `release/X.Y`, which
main's CI never ran on; the candidate's own publish ran every check on it, so a final that changes
only the release files runs only their checks, and the full suite when the candidate's publish relied
on another run instead.

The release PR's own CI run is as small, for the same reason
([`scripts/ci-changes.ts`](../scripts/ci-changes.ts)). A PR labelled `release`, from this repository's
Expand Down
Loading
Loading