Skip to content

Routines

A routine is reusable steps: steps several workflows repeat, such as signing in, written once and run by any workflow of the project with one step that says the routine’s name. Change the routine, and every workflow that runs it runs the change from its next run.

A routine named “Log in as admin” might hold these steps:

Click the Sign in link.
Enter {{email}} into the Email field.
Enter {{password}} into the Password field.

A workflow then runs all three with the step “Log in as admin.”, and its other steps go before and after it as usual.

There are two ways, both under Workflows:

  • New routine, on the Routines tab, opens the editor on an empty routine. Give it a name, a description, and its steps, as you would a workflow.
  • Make a routine…, above a saved workflow’s steps, turns steps you pick into a routine. Pick steps that are next to each other, choose Next…, and name it. The workflow gets one step that says the routine’s name in their place, so it does what it did. The steps keep how Belay read them, so nothing is read again. Nothing changes if the workflow could run before and couldn’t after.

Make a routine when the same steps appear in several workflows. The name is what a step says to run it, so name it as a step would say it: “Log in as admin”, “Add a test customer”. The description says what it does and when to use it; Belay reads it too when it decides whether a step means the routine.

When other workflows of the project hold the routine’s steps written out, Use the routine opens as soon as the routine is made. It lists each of them with where the steps are, such as “Steps 2 to 4”, and Use in 3 workflows puts one step that runs the routine in their place in every workflow you leave ticked. Not now leaves them as they are. If the workflow you made it from holds the same steps again further on, it is listed too, marked “(this workflow)”.

A workflow holds a routine’s steps when it has the same sentences, one after another, in the same order. Only spaces at either end of a sentence are ignored: a capital, a full stop, or a word that differs makes it a different step. Belay never decides by meaning here. Every place a workflow holds them is changed, or, when the routine remembers a value, only the first, and none in a workflow that runs it already. A step that already runs a routine is never one of them.

  • A workflow kept in a repository starts unticked, with the note “Kept in a repository. A pipeline’s next update replaces this change with the file’s steps.” Tick it if you will change its file too; see Workflows as files.
  • A workflow that could run before and couldn’t after is left as it is. So is one saved or deleted while the routine was being put in place.
  • When every workflow you ticked changed, the dialog closes and the page says so, such as “Log in as admin now runs in 3 more workflows.” When any was left as it was, the dialog stays and gives each one’s reason, then Done. A changed workflow that couldn’t run before still can’t, and is named.

Each changed workflow keeps how its other steps were read, so nothing is read again.

To find them later, for example after more workflows were written, use Find workflows with these steps on the routine’s page.

Replacing steps with a routine that exists

Section titled “Replacing steps with a routine that exists”

Make a routine… also puts a routine you already have in place of steps. Pick the steps, choose Next…, then Existing routine at the top, which is there when the project has a routine. Choose the routine: its steps and the steps you picked are listed, numbered, so you can compare them, or the dialog says “The same steps.” when they are. Replace steps removes the picked steps and puts one step that runs the routine in their place, and the page says, for example, “Step 2 now runs the routine Log in as admin.”

The picked steps don’t need to be the routine’s: you have looked and decided. A step that already runs a routine can be picked here, but not for a New routine, since a routine can’t run another routine. Nothing changes if the workflow could run before and couldn’t after.

Belay decides when a workflow is saved, and never during a run:

  • The routine’s name. A step that says the name, ignoring capitals and a final full stop, runs it.
  • Words that mean it. A step such as “Sign in as the administrator.” can run “Log in as admin” too, when Belay is sure that is what it means.
  • Otherwise the step is an ordinary step, read as an action or a check.

A step that runs a routine says so under its sentence: Runs the routine Log in as admin, 3 steps., with the routine’s steps listed below it. Read it, as you read any step’s reading.

When Belay is not sure whether a step means a routine, the step needs a change and asks. Each routine it might mean is one answer, such as Yes, run Log in as admin (or Run Log in as admin when there are several), which writes the routine’s name as the step. No, a step on the page (or A step on the page) keeps the step on the page: write it as an action or a check that names what it acts on, since the same words would be asked about again.

A step that was saved as an ordinary step stays one, even if a routine with that name is made later, until you change its sentence. A routine that is renamed keeps running in the workflows that say its old name.

A routine’s steps use the values of the workflow that runs it, as if they were written there. Its page names them under Values, as in “Uses {{email}} and {{password}}, which come from the workflow that runs it: a variable, or a value a step before remembers.” and “Remembers {{ticketNumber}} for the steps after it.”:

  • The values it uses are the variables its steps use that it does not remember itself. Each must be a variable of the project or of the workflow, or remembered by a step before the one that runs the routine. A workflow that lacks one needs a change at that step, naming it.
  • A value a routine’s step remembers is there for the steps after the one that runs it.

A secret keeps its rule inside a routine: it can only be typed into a password field.

  • A routine can’t run another routine. A routine’s step that says another routine’s name needs a change.
  • A routine that remembers a value runs once in a workflow. A value is remembered once, so a second step that runs it needs a change.
  • A routine never runs on its own. It has no Run button, and it is in no batch and no schedule. It runs inside the workflows that use it.
  • A step that runs a routine counts as one step against your plan’s steps per workflow. A workflow can’t run more than 200 steps with its routines’ steps counted, and is refused when it is saved with more.
  • Routines don’t count against your plan’s workflows.
  • Two routines of a project can’t share a name, ignoring capitals, spaces at either end, and a final full stop or exclamation mark.

Saving a routine reads every workflow that runs it again with its new steps. If one of its steps needs a change, every workflow that runs it can’t run until it is fixed. The editor says so before you save, and a routine’s draft with such a step is not saved when you leave a step; only Save saves it.

A routine that a workflow runs can’t be deleted. The refusal names the workflows: change the step that runs it in each of them first.

A routine’s page lists the workflows that run it under Used by, each a link. Find workflows with these steps, below them, looks for the project’s workflows that hold the routine’s steps written out, by the rule above, and opens Use the routine with them, or says “No workflow holds these steps written out.” It compares the saved steps, so it is off while the routine has unsaved changes. Members and Admins see it.

The Routines tab and a routine’s page show how it did in the latest runs of the workflows that use it: “Passed in 310 of the last 313 runs”, and the step it stops at most often, such as “Stops at step 2”. A run that was interrupted, and a run that stopped before it reached the routine, are not counted. A workflow that runs the routine twice counts twice.

A routine’s page has a Live page, as a workflow’s does. Under Start from, choose a workflow that runs the routine, whose steps before it run first, or The project’s start page, then Edit step 1 on live page, or Edit on live page on any step. Only the routine is saved; the workflow it started from is never changed.

In a workflow’s live page, a step that runs a routine is performed whole: its steps run in order, each with its own result, and the first that does not pass stops it. Its earlier steps acted on the page, so it is not performed again on that page; Bring the page here runs the steps before it again on a fresh page. See Live page.

A run shows a routine’s steps under the step that runs it, numbered 2.1, 2.2, and so on, and folded by a button under the sentence. A step inside a routine that did not pass is named by its place, such as “step 2.3, in Log in as admin”, everywhere a run is described. See Reading a run.

list_routines, get_routine, save_routine, make_routine, and delete_routine do what the Routines tab does. make_routine and get_routine give sameSteps, the workflows that hold the routine’s steps written out (each with workflowId, workflow, where in steps, such as “steps 2 to 4”, and inRepository when it is kept in a repository), left out when there are none. use_routine with routine_id and workflow_ids puts the routine in their place, as Use in 3 workflows does, and answers each workflow: changed with the steps that now run it, canRun false when it still can’t run, or a reason it was left as it was. To put a routine in place of steps that are not its own word for word, write its name as a step with save_workflow. save_workflow and validate_workflow give a step that runs a routine its routine, and a step that might mean one its question. start_session with routine_id tries a routine on a live page. A routine is a file too: see Workflows as files.