GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — trellis/docs/releasing.md at main · salesforce-misc/trellis

Expand file tree

/

releasing.md

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
368 lines (323 loc) · 26.4 KB
/

releasing.md

Copy path

File metadata and controls

368 lines (323 loc) · 26.4 KB
Raw
Copy raw file
Download raw file
Outline
Edit and raw actions

Releasing

A Trellis release is one version for everything it ships, cut from one tag, v<version>, on a commit of main:

What Where How it gets there
The trellis CLI The tag's GitHub release .github/workflows/release.yml
The Elixir binding's precompiled NIFs The tag's GitHub release, where trellis_pg downloads them .github/workflows/release.yml
The Ruby binding's platform gems and source gem The tag's GitHub release .github/workflows/release.yml
The engine crate, trellis-pg crates.io .github/scripts/publish-packages.sh, by hand
The Elixir binding, trellis_pg Hex .github/scripts/publish-packages.sh, by hand
The Ruby binding, trellis-pg RubyGems .github/scripts/publish-packages.sh, by hand

The version

Every version below is the release's:

  • trellis/Cargo.toml, cli/Cargo.toml, clients/embed/Cargo.toml, clients/elixir/native/trellis_nif/Cargo.toml and clients/ruby/ext/trellis_ruby/Cargo.toml, and their entries in Cargo.lock
  • @version in clients/elixir/mix.exs
  • Trellis::VERSION in clients/ruby/lib/trellis/version.rb, and its entry in clients/ruby/Gemfile.lock
  • the install text in the READMEs: the banner's "Version 0.1" and the trellis-pg = "0.1" line in README.md and trellis/README.md, the gem "trellis-pg", "~> 0.1.0" line in clients/ruby/README.md, and the {:trellis_pg, "~> 0.1.0"} line in clients/elixir/README.md
  • DEVELOPING in trellis/src/defs/floor.rs, the release the tree builds: the version's release, without a prerelease tag (0.2.0 for 0.2.0 and 0.2.0-alpha)

The install text pins the release's series, not its patch: 0.1.1 leaves it as it is, and 0.2.0 makes the banner "Version 0.2", the Rust line "0.2" and the gem and Hex lines ~> 0.2.0. All three allow the same range. Before 1.0 the minor is the unit that may break, so the range is the minor series (>= 0.2.0, < 0.3.0). From 1.0 on a minor doesn't break, so the text pins the series' lower bound and allows later minors of the major: 1.2.3 makes the Rust line "1.2" and the gem and Hex lines ~> 1.2 (>= 1.2.0, < 2.0.0). A minor release can raise the catalog floor (ADR-0024), which limits rolling back across it; the lockfile, not the README line, fixes the version a deployed application runs.

The bump changes only the banner's label, not its prose. The sentence "the API may change between 0.x minor releases, before 1.0" is false from 1.0 on, and check-release-versions.sh doesn't catch it, so the 1.0.0 release commit edits it by hand.

The release builds run with --locked and a frozen bundle, so a lockfile left behind fails them. .github/scripts/bump-version.sh <version> sets all of them and checks the result with .github/scripts/check-release-versions.sh; it updates no dependency and rewrites only the banner's label and the version on those install lines. Commit what it changes as an ordinary pull request, and tag the merged commit on main.

Between releases, main keeps the last release's version everywhere but DEVELOPING, which names the release main is building: a development build runs as that release, so the definition floors it stamps for a new feature are ones the last release refuses (ADR-0024). The release commit sets it to the release's own, and the first commit after a final release's tag raises it to the next release (step 4 below).

A prerelease (0.1.0-alpha) is released the same way, as a GitHub prerelease. RubyGems writes its - as .pre., so its gems are 0.1.0.pre.alpha. Cargo, Bundler and Mix never pick a prerelease from a range, so the install text of a prerelease names it exactly (trellis-pg = "0.1.0-alpha", gem "trellis-pg", "0.1.0.pre.alpha", {:trellis_pg, "0.1.0-alpha"}) and the banner reads "Version 0.1.0-alpha, pre-release".

A prerelease belongs to its release: a 0.3.0-alpha binary runs as 0.3.0, and main keeps developing 0.3.0 after the alpha's tag. So a feature merged after the alpha, declared since = 0.3.0, also runs on the alpha, which doesn't carry it: the alpha reads a definition using it as one it can run.

Cutting a release

  1. Write the release notes into a draft GitHub release for the tag, on the commit to release: gh release create v<version> --draft --target <commit> --title "Trellis <version>" --notes-file <notes>. The notes open with a summary of what shipped and the validation the release had beyond CI (runs, hours and source rows written by the benchmarks, generative sweeps, soak and chaos runs and repro loops, from the maintainers' validation logbook).
  2. Run the .github/scripts/bump-version.sh <version> command and commit the changes
  3. Push the annotated tag v<version> on that commit to salesforce-misc/trellis.
  4. For a final release cut from main, start the next release on main: run .github/scripts/start-next-release.sh <next> (the next minor, e.g. 0.3.0 after v0.2.0) and commit what it changes, DEVELOPING alone, as an ordinary pull request. It mustn't be in the tagged commit, which would then run as <next>. Skip it for a prerelease, whose release main is still developing, and for a patch release cut from a release branch, which main is already past. Until it merges, CI's floor check (check-floors.py check) fails every change on main, naming this step.

The tag starts release.yml. It checks the versions, then builds:

  • the CLI for x86_64 and aarch64 Linux (glibc 2.17 and later, and static musl builds for Alpine and scratch images) and for Apple silicon and Intel macOS, as trellis-v<version>-<target>.tar.gz;
  • the NIF for every target Trellis.Native lists;
  • the six platform gems and the source gem, installing and loading each;

and checks the Hex package builds from source. Each CLI build also checks its binary carries none of the engine's test-only code (.github/scripts/check-release-binary.sh, which CI runs on every change too). It then attaches everything, with a SHA256SUMS file, to the draft and publishes it. With no draft for the tag, it creates the release itself, with short notes.

The release job refuses to replace the assets of a version already on crates.io, Hex or RubyGems: the published packages were made from them (Hex's checksum file names the exact NIFs). Before any package is published, a failed release can be re-run.

Running the workflow by hand (Actions, "Release", Run workflow) is a dry run: it builds and checks everything and keeps it as workflow artifacts, touching no release. Its versions are the engine crate's, and it leaves DEVELOPING unchecked, since a commit between releases develops the next one.

Publishing the packages

Once the GitHub release is published, publish the packages from the tag:

.github/scripts/publish-packages.sh <version> --dry-run
.github/scripts/publish-packages.sh <version>

It runs on Linux or macOS, from any checkout of the repository: only the script comes from the checkout. It clones the tag into a scratch directory, checks the versions and every asset against SHA256SUMS, then publishes, asking before each:

  • crates.io: the engine crate as trellis-pg (trellis is taken there). Its library is still trellis, so code reads use trellis::... with trellis-pg = "<version>" in Cargo.toml. The rename is made in the published copy only.
  • Hex: trellis_pg, built the way the workflow checks it, plus checksum-Elixir.Trellis.Native.exs written from the NIFs the release serves. Its NIF crate depends on trellis by git, at the tag's commit, for a host that builds the NIF from source.
  • RubyGems: the release's gems, byte for byte, platform gems first, so no host finds only the source gem and compiles it for want of its platform's.

A package already on its registry is skipped, so a run that stopped halfway is simply re-run. --only crates,hex,gems picks a subset. The script's header lists the tools and credentials each registry needs (cargo login, mix hex.user auth, gem signin).

The upgrade battery

A release that has a published predecessor is gated on a battery run by hand in the release cycle: the predecessor's released build defines and builds databases of every definition shape, and the release candidate takes them over. It is not a CI test and does not run on every pull request. Between releases the design rules keep upgrades compatible: the append-only migration list, the stored-definition rules (grammar versions, ADR-0018) and the grammar's mirror of Postgres (ADR-0022). An incompatibility is found at release time, not in the pull request that introduced it, and each finding is filed as its own issue, labelled Next Release when it blocks the release.

The starting points are the releases of the previous line: the battery runs once from each (--old-tag v<release>). A pre-release is not a supported starting point. To try a starting point before it is tagged, pass --old-src <checkout> (for example a checkout of 0.1.0-dev) with --build-old, or with --old-bin <cli> for a CLI built from it. --old-tag then only names it in the output, and the migrations step compares the candidate's migration files with the checkout's commit.

Running it

.github/scripts/upgrade-battery.sh --candidate <commit-or-directory> [--old-tag v0.1.0] [step ...]

upgrade-battery.sh --help lists the options and the steps. From a 0.2.x starting point (--old-tag v0.2.1) the cases that exist only because a release before 0.2.0 read text differently are skipped, as 0.2.x refuses or reads the same text as the candidate itself (the grammar row says which). The script

  1. takes the predecessor's published CLI from its GitHub release and checks it against SHA256SUMS (--build-old builds the tag instead, which is also the fallback when the download fails), and builds the candidate's CLI; the candidate reports the release version string exactly (by default DEVELOPING, the release the tree develops; --candidate-version changes it, none keeps the tree's own), because version handover compares the exact string. The version is set in a scratch checkout (a directory candidate's HEAD plus its uncommitted changes) and never committed; the release process bumps the real version when the release is cut;
  2. builds upgrade-battery/check, a small probe over the trellis library for the two calls the CLI lacks (self_check and dump_definitions_sql), once against the tag and once against the candidate;
  3. starts throwaway clusters of its own on 127.0.0.1 (it touches no other database), builds the databases with the old CLI, with writers running and ring segments the old build has not drained, stops the old build and starts the candidate on the same databases, with the writers still running; and
  4. runs each step below, printing PASS, FAIL, INFO, MANUAL or SKIP per check, then a summary. It exits 1 on any FAIL.

INFO is an observation to quote in the release notes, MANUAL a check the script does not run, and SKIP a step not selected or one whose tooling did not build. A summary with a SKIP or MANUAL is not a pass of that step.

Record the run in the maintainers' validation logbook (kind acceptance) and give its id in the release notes. The script prints an estimate of the source rows it wrote; pass it to logbook finish --rows. Logs, the clusters' data and the base backup stay under target/upgrade-battery/ (--work); --keep leaves the clusters running for a manual step.

The steps

Step What it checks How
migrations A database the old build created opens under the candidate: no checksum mismatch, the old build's history rows unchanged, and only the candidate's new migrations added. The old tag's migration files are byte-identical at the candidate; a file the candidate adds is reported as INFO, since it changes the upgrade path and rules out downgrade, and the release notes say so. A changed or removed file of the old tag fails. Control: with one stored checksum altered the candidate refuses. Script
definitions One of each shape the release supports, built under the old build with writers running and undrained ring segments in flight: a plain 1-1, a chained 1-1, a 1-1 with a paused column, a group-basis aggregate, an aggregate over a JOIN (inner and LEFT), an aggregate and a JOIN over a hash-partitioned source, a 1-1 with a held key, and a paused transform. Under the candidate each resumes, converges and has a clean self_check; the held key and the pauses are unchanged; nothing else pauses. A plain recompute of two targets in SQL cross-checks self_check. Script
grammar A definition the old build accepted and the candidate refuses pauses with a reason that names the remedy, not an error loop and not silent staleness, and the remedy works: a bare reserved word as a column name, and an expression nested over 100 levels (as a chain and as parentheses). Sources the candidate keys differently: a key with INCLUDE columns, a deferrable primary key, and a primary key dropped after define with a unique index left over a nullable column each pause naming the remedy, and the remedy (RESUME; recreating the key not deferrable, then RESUME; adding a primary key, then RESUME) brings each back with a clean self_check. A primary key dropped after define with a unique index left over its columns keeps running, with KEY (…) written into the stored definition. A definition reading a column named null or false bare keeps reading the column, compared against Postgres, and the same text defined now reads the literal, stamped grammar 2. A definition the old build accepted that parses but fails one of the candidate's define-time checks keeps running, as the takeover does not run those checks again: a chain of 51 or 120 calculated fields stays live and equals Postgres after updates and inserts, with a clean self_check; a fresh define of the same text is refused. A stored constant that Postgres can't evaluate is left as the old build left it by the takeover (status, held keys and target rows unchanged, nothing paused as a refusal). From a 0.2.x starting point only these define-time-check cases run (an old build that refuses a chain itself makes it no upgrade case); the reserved word, nesting, key and null/false cases are 0.1-only, since 0.2.x refuses or reads that text as the candidate does. Script, plus the manual cases below
inflight Upgrading while a definition is mid-build, mid-rebuild (a RESUME), waiting for capture, paused, or holding a key: each continues to live, or stays as it was. The candidate that takes the database over is an embedded application's worker that never calls migrate (the library probe's worker), so the pending migrations run in its handover pass with the work in flight. A held key stands for quarantine: the script does not trip the whole-definition fuse, so no definition is quarantined at the upgrade. Script
structure A structure.sql made by the old build (a pg_dump --schema-only of the Trellis schema and public, plus the old build's dump_definitions_sql) loads into an empty database and every definition builds. Covers the older format only (see the release notes checklist). Script
pgrestore A pg_dump and pg_restore of the old database opens under the candidate, pauses every definition with the documented reason (operations — runbooks), and RESUME brings each back to live with a clean self_check. Script
basebackup A pg_basebackup taken while the old build and its writers ran starts as a cluster, and the candidate converges it with no pause and no RESUME. Script
clients The Ruby gem and the Elixir package built from the candidate open a database the predecessor's clients used, with the same options. Manual
mixed The candidate started while an old instance runs on the database stands by (version handover): it stays up, says it is standing by naming its own version (the one it was built as; a candidate reporting the old build's version string fails, since with migrations pending it stands by beside its own version too) and the old build as a release with no registered version, runs no migration, and pauses nothing, while the old instance's writes keep converging. Once the old instance stops, the candidate takes over: it migrates, its worker_registry row carries that version, and the writes made since converge with a clean self_check. The same handover with no migrate step anywhere: an embedded candidate worker (the library probe's worker, not trellis run) stands by beside a live old instance (from a 0.1.x start its status() names the pending migrations; from 0.2.x its log says it stands by, and status() answers); once the old instance stops it runs them itself and takes over, and the writes converge with a clean self_check. Script
downgrade Rollback (ADR-0024). The candidate defines every shape on a fresh database, with a definition for each feature its feature-floor manifest dates after the old release (a candidate-only type admission among them), and runs with writes. The old build then runs on that database with writes: the candidate-only definitions pause with the documented reason, and RESUME and DROP of one refuse naming its floor and change nothing; every other definition converges with a clean self_check; the process stays up. The candidate runs again: the paused definitions stay paused until RESUME, then converge, and DROP of one removes everything it owned. If the candidate raised the catalog floor above the old release, the old build's run stands by and its apply refuses, each naming the floor, instead. An old release before 0.2.0 refuses the candidate's database from run and from apply. Script

The manual steps, and what the script expects

Clients (the clients step). Open one database the old clients used from both versions, with the same options the old clients were given (the connection-budget options, max_call_pool_size and call_pool_wait_timeout_ms, came with 0.1.0). upgrade-battery.sh --candidate <candidate> --keep clients leaves a cluster holding a database the old CLI built and ran and the candidate has not opened (postgres://[email protected]:54920/clients, at the default --port); then, from the candidate's checkout:

export DSN=postgres://[email protected]:54920/clients
tmp=$(mktemp -d)
cat >"$tmp/open.rb" <<'RUBY'
require "trellis/pg"
Trellis.connect(url: ENV.fetch("DSN"), staging: true, drain_threads: 2,
                max_call_pool_size: 5, call_pool_wait_timeout_ms: 30_000)
Trellis.migrate
Trellis.definitions.each { |d| puts "#{d.target_table} #{d.status}" }
RUBY
# Ruby: the predecessor's published gem, then the candidate's, from source.
gh release download v0.1.0 --repo salesforce-misc/trellis -p 'trellis-pg-0.1.0-x86_64-linux.gem' --dir "$tmp"
(cd clients/ruby && gem install --local --no-document --ignore-dependencies --install-dir "$tmp/gems-old" "$tmp"/trellis-pg-0.1.0-x86_64-linux.gem)
(cd clients/ruby && GEM_HOME=$tmp/gems-old GEM_PATH=$tmp/gems-old ruby "$tmp/open.rb")  # old
(cd clients/ruby && bundle install && bundle exec rake compile)
(cd clients/ruby && bundle exec ruby -Ilib "$tmp/open.rb")                           # candidate
# Elixir: the candidate's package, building its NIF from source.
(cd clients/elixir && TRELLIS_PG_BUILD=1 mix run --no-start -e '
  {:ok, t} = Trellis.connect(url: System.fetch_env!("DSN"), staging: true, drain_threads: 2,
                             max_call_pool_size: 5, call_pool_wait_timeout_ms: 30_000)
  {:ok, defs} = Trellis.definitions(t)
  for d <- defs, do: IO.puts("#{d.target_table} #{d.status}")')

The three runs print the same definitions and statuses, and migrate raises no error. A client that cannot open the database, or a gem or package that does not build, is a finding. bundle install may add a bundler line to clients/ruby/Gemfile.lock; discard it.

Refusals the script does not build (the grammar step). The script constructs the refusals it can build with the old CLI. Check the rest by reading the candidate's list of refusals against what the old build accepted (the refusals in errors, the changes since the predecessor's tag), and for each one the old build accepts, define it under the old CLI, upgrade, and confirm the outcome: text the candidate can't parse pauses with a reason that names the remedy, and the remedy works; text that parses but fails a define-time check is left as the old release left it, and the release notes list it. Cases that the old build refuses itself are not upgrade cases: a JOIN on a repeated column pair, an index over more than 32 key columns, and (not tried by the script) a table over 1600 columns. Add each new case to the script when you find one.

Mixed versions (the mixed step). Two versions never run side by side: a candidate started beside a running old instance stands by until the old one stops, then takes over (version handover). The step starts the candidate's trellis run beside the old build's, expects it to stay up and log that it is standing by (its migrations are pending and a process is live), with the history unchanged and nothing paused, then stops the old build and expects the candidate to migrate and converge. It then does the same with an embedded application's worker as the candidate (the library probe's worker: a handle with the staging worker and drain threads that never calls migrate) on a database of its own, so nothing but the worker's handover pass can run the migrations, and expects the marker to record that the worker ran the takeover work. A candidate that runs beside the old one, exits, pauses definitions, or (the worker) doesn't migrate once the old one stops fails the step, and the finding is filed.

Rollback (the downgrade step). The old release is the previous release and the candidate the release being cut. The step fails a line of the candidate's .github/feature-floors.txt dated after the old release that no definition in the script's rollback_new_defs list uses: when a release adds a feature, add a definition using it there, one over the shapes tables. The step also fails an entry whose definition the candidate stamps with a floor the old release meets. A release before 0.2.0 carries no floors: the step asserts that it refuses the candidate's database (v0.1.0 refuses the instance format the floor migration sets, before its migration runner starts), and records that rolling back to it means restoring a backup taken before the upgrade (upgrading). Quote that, or what the step found, in the release notes.

Release notes checklist

For each release, the notes carry:

  • Definitions the new version refuses. Two kinds, listed separately. A definition the previous release accepted that this one can't parse pauses on upgrade, with its reason in capture_failure; the notes list each case, with the remedy (DROP TRANSFORM, then define it again in the current grammar). A definition that parses but fails one of this release's define-time checks is left as the previous release left it, because the takeover does not run those checks again (rows that arrive later follow this release's rules); the notes list each case, with no remedy beyond what the refusal message of a fresh define gives. Add every case from the manual refusal check, under the kind it belongs to.
  • What new text means differently. A grammar version bump (ADR-0018) keeps every stored definition's meaning, but the same text written after the upgrade reads the new way. The notes say what reads differently, what new text refuses, and how scripts and migrations that address existing targets must now spell them.
  • Definitions that pause because the new version keys a table differently, each with its remedy (the key entry).
  • Changes an upgrade makes that users don't see, so a question about them has an answer: a build restarted, hidden tables re-laid out, a definition rebuilt at the takeover.
  • The upgrade procedure, from upgrading, and whether the release adds a migration. A worker of the new release runs its migrations itself once the old release has stopped; say when a deploy step that runs migrate still matters (a worker role that can't alter Trellis's tables, and a rollback to a release before 0.2.0, which has no catalog floor to stop it). Releases before 0.2.0 have no version handover, so between two of them, stop every process of the old release before starting the new one.
  • Compatibility floors: the floors this release raised (the catalog floor, and which features carry a new definition floor) and what that means for rolling back to the previous release (ADR-0024, upgrading — Rolling back). .github/scripts/check-floors.py notes v<previous> lists them: the migrations that raised the catalog floor, and the features, overloads and admissions whose release is after the previous release's.
  • structure.sql in the format ADR-0025 writes, which the battery does not check: a file the old build's schema_dump wrote (a pg_dump --schema-only with its pg_dump_args, through filter_schema_dump, then its appendix) loading under the candidate. The structure step covers the older dump_definitions_sql format only: the probe (upgrade-battery/check) is built from one source against the old tag and the candidate alike, and a tag before schema_dump (v0.1.0) has no call for it to build against.
  • For databases that came from a pre-release, which the battery does not start from: what such a database needs after the upgrade.
  • The validation the release had: the battery's logbook id and its result, with every FAIL, SKIP and MANUAL it left and how each was settled.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.