Contributing to Replicant

Copy Markdown View Source

This guide covers the toolchain, checks, and release workflow for Replicant contributors.

Prerequisites

CI installs Elixir, Erlang/OTP and Hex at the exact versions in .tool-versions. It uses pipx for the pinned REUSE linter. See compatibility for runtime support.

Submit a change

  1. Fork the repository and make a branch for your change.
  2. Update CHANGELOG.md under [Unreleased] for a behavior, dependency or contract change.
  3. Open a pull request against main.

CI

Quick runs on work branches. It fetches locked dependencies, runs mix check --except ex_unit, and selects covering tests against the pinned engine. A newer push cancels the earlier Quick run for the branch. Quick workflow.

Maintainers submit a kci/<commit> candidate. The qualified check must succeed before main moves. GitHub-hosted runners execute the checks. Pull request and main pushes run no qualification. CI workflow.

Qualification runs mix audit, mix check --except ex_unit, mix test on each supported PostgreSQL major, and Dialyzer. mix check covers formatting, compilation with warnings as errors, Credo, Sobelow, ExDoc with warnings as errors and REUSE. Qualification also builds the package and docs. Qualification workflow.

Compatibility majors use pinned upstream images. The platform engine lane uses a same-major upstream companion for pglogical. Each major checks plugin parity, schema halts and crash recovery. Integration tests read REPLICANT_TEST_URL and require logical WAL. The Livebook test executes the tutorial against the real server. Qualification uses fresh builds without dependency, build or Dialyzer PLT caches.

Each job's timeout comment cites its slowest measured green run. An unmeasured publish job uses the unmeasured limit. Runtime setup reads the declared toolchain and refuses a different Elixir version, full OTP patch or Elixir OTP build suffix. The example release image pins its own container toolchain.

Reference stack

The reference pipeline is a separate Mix project with its own lockfile. The static job audits that lock. The example job runs its checks, builds the stack, and verifies delivery, TOAST preservation and resume with no duplicate receipts. The root .dockerignore admits only explicit files used by the example image.

Publishing (release operator only)

The pinned Hex action builds the package and docs with the selected commit's locked runtime. It checks the file set, source bytes and requirements against the package declaration and compiles a consumer of the unpacked package. Qualification retains the package, docs and manifest for seven days.

When cutting a release, move its entries from Unreleased to the dated version section and use the package-scoped tag in the new comparison links.

Give the infrastructure maintainers the repository, full release_commit, version, release contents and successful qualified run. They obtain the owner's approval and dispatch Publish to Hex from the default branch with that 40-character lowercase commit SHA. The workflow requires authorized maintainers as both the original and triggering actors.

Only upload enters the publish environment. The shared action checks the selected commit's qualification, the packaged changelog stamp, package and tag state, and public/private version collisions before exchanging a package-scoped token for any required upload. First publication belongs to the owner.

If Hex holds a release for approval, retry with the same release_commit. Upload selects the newest successful qualification for that SHA. Keep the original run and its archives available through approval.

read-back uses the qualification run and manifest digest from upload. The shared action verifies the signed registry entry, byte equality for both archives, and the docs' release.json naming the package, version and selected commit. The workflow retains the two archives and their SHA256SUMS in a single release-assets artifact.

The maintainers compare the package against Hex, annotate baselabs_replicant-v<version> at the published commit, and create the GitHub release with notes from the packaged changelog. Existing releases keep their legacy v<version> tags.

Consumers verify the permanent GitHub release by downloading the archives and checksums:

gh release download baselabs_replicant-vX.Y.Z --repo baselabs/replicant --pattern 'replicant-*' --pattern SHA256SUMS
sha256sum --check SHA256SUMS
curl --fail --silent --show-error https://repo.hex.pm/tarballs/replicant-X.Y.Z.tar -o hex.tar
cmp replicant-X.Y.Z.tar hex.tar
tar -xOf replicant-X.Y.Z-docs.tar.gz release.json
rm hex.tar

Check that release.json names replicant, the release version and the full commit at the GitHub release tag. Record the verified package digest in scripts/release/published_packages.sha256 through the normal landing process after the Hex package, HexDocs, annotated tag and GitHub release agree.

The infrastructure maintainers own the dispatch, release, tag and credentials.

Code style

  • Use the repository's .formatter.exs with mix format.
  • Add @moduledoc and @doc to public modules and functions.
  • Apply the sink invariants when changing decoder, assembler, identifier or telemetry code.

License

By contributing, you agree that your contributions will be licensed under the MIT License.