Continuous delivery

Table of contents

Introduction

Your product is a configuration of released features, and SPLENT delivers it as one. Every push is checked against the line, a new feature release arrives as a pull request, and a product release publishes an image to a channel that production can follow.

Everything around the release is automatic. Merging the pull request and running product:release stay your decision.

From a feature release to the running product feature:release Feature A tag on the forge and on PyPI splent-upgrade Pull request New pins, checked against the model product:release Release Image tagged with the version and stable SPLENT_IMAGE Deploy The host follows the channel Running Migrated once, ready on /readyz Does not start, so the previous version and its database come back Automatic, checked against the line A person decides Automatic, safe to fail
Everything around the release is automatic. The release itself, merging the pull request and running product:release, stays a person's decision.

Continuous integration

product:create gives your product two Forgejo workflows in .forgejo/workflows/. Add them to a product that lacks them with product:sync-template --ci.

splent product:sync-template my_product --ci
Workflow When What it does
splent-validate.yml Every push to main and every pull request Checks the product against its line, lints it and runs the tests
splent-upgrade.yml Mondays at 06:00 UTC, or upgrade_schedule under [tool.splent.ci] Runs feature:upgrade --yes and opens a pull request on splent/feature-upgrades when the pins change

Neither workflow releases or deploys. The runner clones the public features over HTTPS.

What the validate workflow checks

It runs three jobs, and the alert job after them.

  • validate runs product:resolve --prod --strict, product:validate and product:build --no-image, and fails when the build changes anything versioned (deploy/, docker/requirements.lock, docker/frontend.lock.json, splent.contracts.json, docker/spl/). Then product:frontend-audit audits the bundles and keeps their SBOM, and check:vendor fails on Keenthemes code.
  • lint runs splent lint --target app on your product’s code.
  • test runs the features’ tests in your configuration, then your product’s own. See below.

Runs on main queue and each runs to the end. A newer push to a pull request cancels that pull request’s previous run.

When a workflow fails

Both workflows end with an alert job. When a run on main fails, it opens an issue on the product’s repository named after the workflow, for example “SPLENT validate is failing on main”. Later failures comment on that issue, and the first run that passes closes it. Pull requests and cancelled runs change nothing.

Watch the repository to get these issues as notifications. They arrive by email when the forge sends mail. The job uses splent_ci_alert and the workflow’s own token, so there is nothing to set up.

The validate job installs no feature packages, so the menus phase of product:validate only warns there. Check menus where the product runs, with splent product:validate --only menus --strict.


Testing the features in your product

A feature’s tests passed when it was released, in some other product. The test job runs them again against the releases you pin, the refiners you select and your configuration, which is where a combination breaks. Then it runs your product’s own tests/.

The job stands in for your web container, with a MariaDB 11.4 service called db. It

  1. installs the framework and CLI that [tool.splent.runtime] pins, with docker/requirements.lock as constraints,
  2. resolves the features with product:resolve --dev --strict,
  3. installs them with feature:pip-install,
  4. fetches the line’s model with spl:fetch, so features load in the model’s order,
  5. applies every migration to an empty database with db:upgrade,
  6. runs product:test.

A product with no tests passes. To leave the job out, set tests = false, then run product:sync-template --ci.

[tool.splent.ci]
tests = false

If [tool.splent.runtime] pins splent_cli 1.36.0 or earlier, its product:test skips your product’s own tests, and product:sync-template --ci warns you.


Giving the tests the servers they need

A feature that brings a server declares it in its compose file and reaches it by service name, as in REDIS_URL=redis://splent_feature_cache:6379. When the workflow is written, the CLI reads each feature’s development compose file and decides per service.

The service runs In the test job
redis, elasticsearch or mailhog A service with the same name and image, a health check, and the URL variables the feature’s docker/.env.example names (REDIS_URL, ELASTICSEARCH_URL, or MAIL_HOST, MAIL_PORT and MAIL_USE_TLS for Mailhog)
nginx or phpmyadmin Nothing, no test needs them
Anything else Nothing, and the test job is left out
      splent_feature_cache:
        image: redis:7.4
        options: >-
          --health-cmd "redis-cli ping" --health-interval 5s
          --health-timeout 5s --health-retries 30
    env:
      REDIS_URL: redis://splent_feature_cache:6379

When a service is unknown, the job is left out rather than failing for no fault of yours, and the CLI tells you how to bring it back.

  The test job is left out of splent-validate.yml. splent_feature_ldap runs splent_feature_ldap (image osixia/openldap:1.5.0), a service the CI does not know how to run.
  To run the tests anyway, set tests = true under [tool.splent.ci].
  If they need splent_feature_ldap, add [tool.splent.ci.services.splent_feature_ldap] with image = "osixia/openldap:1.5.0".

Declare the service yourself, with its image and optionally env and options. It replaces what the CLI would run under that name. No service may be called db.

[tool.splent.ci]
tests = true

[tool.splent.ci.services.splent_feature_ldap]
image = "osixia/openldap:1.5.0"
env = { LDAP_ORGANISATION = "Test" }
options = "--health-cmd \"ldapsearch -x -H ldap://localhost\" --health-retries 30"

Keeping the workflows in step

The workflows depend on your features, so every command that changes the selection or the pins rewrites them when it succeeds. These are product:configure, product:resolve, product:derive, product:auto-require, feature:install, feature:add, feature:remove, feature:attach, feature:detach, feature:upgrade, feature:pin, feature:unlock and feature:rename.

  Updated .forgejo/workflows/splent-validate.yml for the product's features.

Commit the file with the change that brought it, and look at the diff first. The file is written whole with the templates of the CLI you run, so a different CLI may change more than the services.

Only a file SPLENT wrote and nobody edited is rewritten. Its first line holds the sha256 of the rest.

# splent-generated sha256 <hash>

An edited file is left alone, and the command tells you so. product:drift shows what SPLENT would write, and product:sync-template --ci rewrites it.

After you edit [tool.splent.ci], run splent product:sync-template <product> --ci yourself, since those settings are not part of the features.

When a feature is not in the workspace yet

The CLI cannot read the compose files of a feature that is not there, so it writes nothing and names the command that fetches it.

  .forgejo/workflows/splent-validate.yml is updated once splent product:resolve fetches splent_feature_notes, splent_feature_shop and 5 more.

For an editable feature, the command is feature:install <namespace>/<feature> --editable. Until then product:sync-template --ci exits 1 and writes nothing. The upgrade pull request commits pyproject.toml alone, so a new pin that brings a server reaches splent-validate.yml at the next product:resolve.


Following the release channel

product:release publishes your image with two tags. The version tag never moves. The stable tag moves to every release, and only a release moves it.

A production host follows the channel through SPLENT_IMAGE in deploy/.env. The deploy bundle that each release commits already sets it.

SPLENT_IMAGE=git.splent.io/splent-io/my_product:stable

docker compose up on the host, or product:deploy, then pulls the image instead of building one.


Deploying automatically

Deploying can be a feature of the line. A feature that follows the channel brings the deploying agent, usually a container in the production stack, and your product gets it by selecting the feature. SPLENT gives such a feature what it needs.

  • A channel only a release moves. stable always points at the last product:release.
  • The channel’s name. The feature reads SPLENT_IMAGE like the host does.
  • Migrations apart. splent db:upgrade runs in a one-off container of the new image before it serves.
  • A readiness probe. /readyz answers 200 once every readiness check the features add passes.
  • A way back. MariaDB commits DDL as it goes, so dump the database before migrating and restore it when the new version does not become ready.

The feature’s settings reach deploy/.env.example like any other. A required one is "<SET>", and product:deploy offers a random value when its name ends in _SECRET or _PASSWORD.

Turning it on

  1. Add the feature to the line’s model as optional and publish it with spl:publish.
  2. Attach the feature to your product and release it with product:release.
  3. On the server, clone (or pull) the product’s repository, copy deploy/.env.example to deploy/.env, fill in the required values, and run docker compose up -d in deploy/. From a workspace, product:deploy does the same.

From then on, releasing is deploying.

Whoever holds the Docker socket is root on the host. An agent that holds it should run no code it is sent, publish no port, accept nothing without a shared secret, and run only on a host that serves this product.


Who decides what

Step Who
Checking every change against the line The forge, on every push
Proposing newer feature releases The forge, on a schedule
Accepting them You, by merging the pull request
Publishing a version You, with product:release
Deploying it The agent
Undoing a version that does not start The agent, database included

See also


Back to top

splent. Distributed by an LGPL license v3. Contact us: drorganvidez@us.es