Contributing to Countersign

Copy Markdown View Source

Thank you for helping. Bug reports, fixes, documentation and new hosts are all welcome.

Before you start

  • For a bug, open an issue with the smallest reproduction you can: the calls you made, what you expected, and what happened.
  • For a change to a behaviour's callbacks (Countersign.Host, Countersign.Signable, Countersign.Delivery), open an issue first. Every host implements them, so a change there is a change for everyone.
  • For a security problem, do not open an issue; see SECURITY.md.

Development

You need the Elixir and Erlang versions in .tool-versions (OTP linked to OpenSSL 3.5 or later) and PostgreSQL 15 or later. The tests create and use a database named countersign_test; set DATABASE_URL to point them anywhere else.

mix deps.get
mix test

Before you open a pull request, run what CI runs:

mix format --check-formatted
mix compile --warnings-as-errors
mix credo --strict
mix dialyzer
mix test
(cd examples/demo && mix deps.get && mix compile --warnings-as-errors)

Rules the code keeps

  • No global state. Nothing under lib/ reads application env, OS env or :persistent_term; everything arrives through Countersign.Config. A test (test/countersign/no_global_state_test.exs) enforces it.
  • Tests are async and isolated. Tests run against Countersign.TestHost, whose state lives in an Agent started per test under that test's own scope id. No shared ETS table, no process dictionary.
  • Migrations are idempotent. Countersign.Migrations uses create_if_not_exists, drop_if_exists and IF NOT EXISTS, and its test runs up twice and down twice. A new table change is a new version, never an edit to a shipped one.
  • Secrets stay secret. Addresses, tokens and codes are stored encrypted or hashed, and schema fields that hold them are redact: true. Never log them.
  • Allowed dependencies are ecto_sql, oban, phoenix, phoenix_live_view, plug, bcrypt_elixir, jason and x509 (and, for development, ex_doc, credo, dialyxir, postgrex). No third-party PDF-signing dependency.

Pull requests

  • One logical change per pull request, with tests.
  • Add a line under "Unreleased" in CHANGELOG.md. Mark a breaking change as Breaking.
  • CI must be green; main is protected and requires it.
  • Pull requests are squash-merged.

Changes that also change a host application

Countersign's first host, HomeCareBilling, lives in a separate repository and depends on this one by a pinned commit. A change that needs both is delivered in this order:

  1. Package code is written only here. Never as a vendored copy inside a host, and never as a path: dependency committed to a host's main branch.
  2. The package change lands first: a reviewed pull request on this repository's main, with its CI green, squash-merged.
  3. Then the host bumps its pin ({:countersign, github: ..., ref: "<sha>"}) to that squash-merge commit, in a commit whose subject names the sha. The host's CI fails when the pinned ref is not on this repository's main.
  4. While developing, a host may point at a local checkout with a path: override, but only as an uncommitted edit to its mix.exs, never in a commit.

Code of conduct

This project follows the Contributor Covenant. By taking part you agree to it.