The parts that are yours
On this page
A factory line has six stations: automatic tests, the independent review check, a trial run on a test copy, the release decision, the release, and the watch afterwards. Three are the factory's: the independent review check, the release decision, and the watch afterwards. Three are always the project's own, because they depend on what the project is and where it runs: its tests, its trial run on a test copy, and the release itself. So are the two small commands the watch calls: the check that says whether the live system is well, and the undo.
This page says, for each of yours: what it has to do, how the factory meets it, and what the factory never does to it.
The factory never runs, starts or changes any of these. Your own automation runs them, and calls the factory at set points. The one exception is the watch, which runs your check and your undo itself.
| Yours | Needed for | How the factory meets it |
|---|---|---|
| Tests | Everything | Waits for the checks you name; records how they ended |
| The trial run on a test copy | Optional | Only by position: the release decision is asked after it |
| The release | The release half | Runs only when the decision says go; tells the factory how it ended |
| The live check | The watch | The watch runs it and reads its exit code |
| The undo | The watch, strongly advised | The watch runs it once when a release has gone wrong |
#You do not need all of it to start
| Where the project is | What it can run | What it rests on |
|---|---|---|
| Nothing live yet | Tests, then an independent review (setup guide) | The review catching what the tests miss |
| One live environment | As above, then the release decision, the release, the watch and the undo (release half) | No rehearsal: the watch and a working undo carry the weight |
| A test copy and a live one | The whole line | A rehearsal before customers see a change |
A project that has only a pre-production environment and no customers yet is on the second rung: that environment is its live one as far as the factory is concerned. It is a good place to practise the release half while a mistake costs little.
Climb when you are ready. Nothing in the factory makes you, and nothing on a lower rung has to be redone on the next.
#Your tests
What they must do. Run by themselves on every pull request, report a check GitHub can require, and fail when the product is broken. The readiness check, section B, asks the six questions that decide whether they can carry a line: can they be trusted, are they quick, is the main branch green, do they reach the risky areas, do they need nothing a pull request should not have, can an author run them first.
How the factory meets them. The factory file names the checks (uses: checks, require:). GitHub's branch rules make them required. The automatic reviewer waits for them before it reads a change. The record says, for each version of a change, whether they passed or failed.
What the factory does not do. It does not run them, read their output, or judge whether they are good tests.
#The trial run (optional)
A job of your own in your release workflow, before the release decision. It puts the commit on a test copy of the live system and proves it works there.
What a good one proves.
- The release itself works: the same steps, scripts and packaging as production, pointed at the test copy. A trial run that deploys another way rehearses nothing.
- The product answers after it: a few checks that only a working system passes. Sign in, read something real, write something and read it back.
- Changes to stored data go through it first: a migration that fails should fail here.
- It fails when it should: it ends red when a check fails. A trial run that cannot fail is decoration.
How the factory meets it. By position only. The gate job needs: it, so when the trial run fails the release decision is never asked and nothing is released. The factory does not look inside it.
Without one. Delete the job. Everything after it works the same. You have given up the rehearsal, so make up for it: keep risk: high among the gate's hold_when rules so risky changes wait for a person, and do not run without an undo.
#The release
A job of your own that puts the commit on the live system.
What it must do.
- Run only when the decision says go.
if: needs.gate.outputs.go == 'true', exactly that. Anything looser (!= 'false',always()) releases when the gate failed to answer. - Release the commit the run is for, by automation, from the releasing branch. A release from somebody's own computer is invisible to the gate, which then judges the next change against the wrong starting point.
- End red when it did not finish, and only then. The run is the record: a run that succeeded as a whole, with the gate's go in it, is what the next decision counts from, and what the watch watches.
- Confirm that it arrived; do not judge whether it is well. It is natural to finish a release by running the live check. Do not. If the system is unwell the job then ends red, a red run is not a release, so the watch does not start and nothing is undone: the unwell release stays live with only an alert. End the job by confirming the live system is now this commit, and leave "is it well?" to the watch.
- Give it what it needs to reach your host. More
permissions, anenvironment, a role the owner has set up. Adding a permission to your own job is part of writing it, and is reviewed like any workflow change; creating or reading a secret is not yours to do. - Tell the factory how it ended:
python3 -m factory.release releasedafter success closes the waiting issue, and... failedwhen it did not finish opens the issue that holds the line until a person has looked. The starter has both steps. - One release at a time: a
concurrencygroup on the job.
What makes it safe to undo. Keep what was live before in a form you can put back: the previous package, image or build, by name. One way that works: before it replaces anything, the release reads which commit is live now (from a version line the live system shows) and stores that beside what it publishes; the undo reads it back. Do not use "the last successful release run" for this: a release the watch undid still ended as a success, so that would put the bad one back. Know what an undo does not put back (a database change, a setting, a message already sent) and write it in the repository's README or runbook: nothing your scripts print is copied into the factory's alert, which links to the run. Prefer changes to stored data that the previous code can still live with.
What the factory does not do. It does not deploy, hold your cloud credentials, or know where you are hosted.
#The live check
A command of yours that the watch runs after a release, every few minutes.
- Exit
0: well. Exit10: not well. Anything else, a crash included: could not tell. - Ask what only a working system answers rightly. "The server is up" is not enough; "the page a customer uses shows real data" is.
- Ask only whether it is well, not whether it is the release being watched. A later release, or an undo, changes what is live while a watch is still going. A check that compares the live version with the one it was started for calls a healthy system unwell: a false alarm after two quick releases, and "still not well" after every successful undo.
- "Not well" means the system answered and the answer was wrong. Not being able to reach it is "could not tell".
- You cannot see it answer
0until something has been released. Before that, run it and expect "not well" or "could not tell". - If your system fails a little all the time, give the watch counts instead and let it judge whether failures have risen (the watch, "Judging counts").
#The undo
A command of yours that puts back what was live before. Exit 0 when it has.
- The watch runs it once, after two bad looks in a row, and never over a later release.
- On one environment it is not optional in practice. Without a rehearsal it is the only net. The watch works without one, and then all it can do is tell a person.
- Try it before you need it. An undo that has never run is a hope. It needs two releases before there is anything to put back: the first release cannot be undone. With one environment the first real try is the test at the end of the setup guide.
- Where the release is done by a workflow's own steps (a hosting action, say, and not a command a script can run), the undo cannot be a plain script either. Make it a small workflow of its own that publishes a named earlier commit, refusing any commit not in the releasing branch's history, and have your undo command start that workflow and wait for it to finish. The watch's job then needs
actions: write(the starter hasactions: read). That workflow releases without asking the gate, so it is reviewed as carefully as the release itself.
#What to build, in short
| Rung | You build | You copy from starter/ |
|---|---|---|
| Nothing live | Tests that run on every pull request | factory.yml, factory-gate.yml |
| One environment | The release job; the live check; the undo | factory-release.yml (without its staging job), factory-release-watch.yml, scripts/ |
| Test copy and live | The trial-run job as well | The same, keeping staging |
This guide is docs/YOUR_OWN_PARTS.md in the repository, and this page is made from it. Something wrong or unclear? Open an issue or send a pull request. Next: Setup guide: stage 1.