Skip to content

Workflows as files

A workflow can be written as a file: one YAML file holding its name, its folder and tags, and its steps, one sentence to a line. You keep the files in your repository beside the code they test, and a pipeline sends them to Belay to run. A workflow stays in the app until it is put in a repository; from then on a pipeline’s update replaces its steps with the file’s, and the app says so.

id: buy-a-helmet
name: Buy a helmet
folder: Checkout
tags: [smoke, checkout]
description: A guest adds a helmet to the cart.
variables:
email: robin@example.com
steps:
- Go to the shop page.
- Click the Add to cart button on the "Trail Helmet" card.
- Check that the "Trail Helmet" row in the cart has price "$89.00".
- Enter {{email}} into the Email field.
Member What it is
id The workflow’s file id. Required.
name The workflow’s name, as the workflow list shows it. Required.
folder Its folder. Left out, the workflow is in no folder.
tags Its tags, as a list. Left out, it has none.
description The line under its name.
variables The workflow’s own variables, each a name and its value.
steps The steps, in order, one sentence each. Required.

A file says everything about its workflow: a member that is left out means none. A file may also say version: 1; a file with no version is version 1, and kind: workflow, which is the same as no kind.

A routine is a file too. It starts with kind: routine, and holds only its file id, name, description, and steps:

kind: routine
id: log-in-as-admin
name: Log in as admin
description: Signs in with the admin account. Use it before any step that needs the admin pages.
steps:
- Click the Sign in link.
- Enter {{email}} into the Email field.
- Enter {{password}} into the Password field.

A routine’s file has no folder, tags, or variables: a routine uses the values of the workflow that runs it, and a file that has one of them is refused. Its description is at most 2,000 characters. Belay writes a routine’s file at routines/<file id>.yaml, beside the workflows’ files.

Every value is text, exactly as written. count: 3 is the text “3”, and answer: yes is the text “yes”. Nothing in a file becomes a number, a date, or true or false.

The project keeps everything a workflow shares with others, and a file names it the same way a step does:

  • Routes and the start page. “Go to the shop page.” goes to the shop route.
  • The project’s variables and secrets. A secret’s value is never in a file; a step uses it by name, as in {{password}}.
  • Environments, and so the address the steps run against.

Every workflow has a file id: lowercase letters, digits, and -, starting with a letter, up to 80 characters, such as buy-a-helmet. It is how a file finds its workflow, so it is unique in its project. A file’s own name and folder do not matter.

Belay makes a workflow’s file id from its name when the workflow is first saved, or when a draft becomes a workflow, which has no file id before: lowercased, with each run of other characters made one -, and cut at 60 characters. “Buy a helmet!” becomes buy-a-helmet. An id that would not start with a letter gets w- in front, such as w-2026-sale, and a name with no letters or digits gets workflow. When another workflow of the project already has the id, deleted ones included, the new one gets -2, -3, and so on. Renaming a workflow does not change its file id, and a duplicate gets one of its own.

A workflow’s file id is on its page in the editor, after File id in the line under its title and tags. It is also the downloaded file’s name and on the file’s first line. A file you write for a test that is not in Belay yet gets the id you give it.

YAML reads some sentences as something else. Put a step in single quotes when it:

  • has : (a colon and a space) or # (a space and a hash) in it, or ends with :;
  • starts with a quote, {, or [;
  • starts with one of , ] } # & * ! | > % @ or `;
  • starts with - , ? , or : , the mark and a space.

Written plain, this step is read wrong, because of the : inside the quoted text:

- Check that the Repair booked banner shows "Ticket: SC-1035".

In single quotes it is read as written:

- 'Check that the Repair booked banner shows "Ticket: SC-1035".'

A ' inside single quotes is written twice: 'It''s the "Trail Helmet" card.'. Quotes inside a sentence, such as "Trail Helmet", need nothing; only a quote at the start does.

A comment written after a step on the same line (- Click Save. # the blue one) would cut the step short there, so a file cannot have one. Put a comment on a line of its own.

When a step needs quotes, Belay refuses the file, names the line, and says to put the step in single quotes, such as:

Put this step in single quotes. YAML read it as something other than a sentence, because of a ’: ’ in it or a mark at its start.

A file Belay writes for you is already quoted this way.

  • More than one workflow. Put each in a file of its own.
  • YAML’s anchors (&), references (*), type marks (!), and merge keys (<<).
  • A member that is not in the table above.
A file 64 KB
Steps 1 to 200, each up to 500 characters, and no more than your plan allows a workflow
The file id 80 characters
The name 200 characters
A folder or tag name 40 characters, and a tag has no comma
Tags 20

A pipeline sends at most 500 files, and 4 MB of them, at once, and no two files with one id.

To put workflows you wrote in the app into your repository:

  • Download file on a workflow in the editor, the download icon beside File id among the facts under the title. The file is named by the workflow’s file id, such as buy-a-helmet.yaml, and holds the workflow as it was last saved. While the editor has unsaved changes, the icon is off until they are saved. Anyone who can open the workflow can download its file, Viewers included. On a routine’s page, Download file is in the More (…) menu.
  • belay pull, from the command line, writes every workflow of a project, or of a tag or folder, as files under a folder of your repository. Pulling the whole project writes its routines’ files too. See Run from CI.

Commit the files as they are written.

A pipeline sends the files with the belay command or the GitHub Action (Run from CI), in one of two ways.

A run of the files runs the steps in each file and saves nothing. It is for a pull request: a change to your application and to its tests is tested with its own tests, and the saved workflows, and the schedules that run them, are not touched. Each file is one workflow of a batch:

The file What runs
Is the same as its saved workflow The saved workflow, as any batch runs it.
Differs from its saved workflow The file’s steps. The saved workflow does not change.
Has no workflow in the project The file’s steps. Its runs are kept under a workflow that is only in files so far: it is in no list or count of the project until a save brings it in.
Belongs to a workflow that was deleted The file’s steps, under that workflow, which stays deleted until a save brings it back.
Has a step that needs a change, a variable with no value on the environment, or another reason it can’t run Nothing. The batch lists it as not started, with why.

The same means the same description, the same variables with the same values in the same order, and the same steps in the same order. The name, folder, and tags change no run.

A routine’s file is never a workflow of the batch, since a routine never runs on its own. It is read with the workflows’ files instead, in place of the saved routine:

  • A workflow whose file is the same as its saved workflow runs as saved only when none of the routines it runs was sent with a difference. Otherwise its file’s steps run, with the routines as sent.
  • A routine that was not sent is used as saved.
  • A step that says the name of a routine neither sent nor saved is an ordinary step, read as any other; Belay never guesses which routine it meant.
  • A batch of routines’ files alone is refused: send the files of the workflows that run them too.

An update saves the files to the project first, then runs them. It is for the pipeline that releases, so the saved workflows follow what was released. It needs an API key made to update workflows.

The file Its workflow
Has no workflow in the project Made, in the project.
Differs from its workflow Saved over.
Belongs to a workflow that was deleted, or that is only in files Brought into the project, with its runs, and saved. It takes a place in your plan’s workflows, as a new one does.
Is the same as its workflow Left as it is, apart from its name, folder, and tags.

Each workflow takes its name, folder, and tags from its file: a folder or tag the project lacks is made, and a file with no folder or no tags takes them away. A step that needs a change is saved, and that workflow can’t run until the file is changed. A workflow whose file is gone from your repository stays as it is: an update never deletes one.

Routines’ files are saved in the same update as the workflows’ files, so a workflow can run a routine that is made by the same update. Saving a routine reads again every workflow that runs it, including those whose files were not sent, and changes nothing else of theirs. The answer for each routine’s file says how many workflows run it, and how many of them could run before and can’t now. A routine’s step that needs a change makes every workflow that runs it unable to run until it is changed.

Nothing is saved, and nothing runs, when a file cannot be read, a step cannot be read at all, a file has more steps than your plan allows, or the files add more workflows than your plan has room for. Routines take no place among your plan’s workflows. For routines, nothing is saved either when:

  • a workflow’s file has a routine’s file id, or a routine’s file a workflow’s;
  • a routine’s step says another routine’s name, since a routine can’t run another routine;
  • two routines, sent or saved, would have one name, ignoring capitals, spaces at either end, and a final full stop or exclamation mark.

belay check reads the files as an update would and says what it would change and which steps need a change, with each step’s file and line, without saving or running anything. For a routine’s file it says how many workflows run the routine, and how many a save would leave unable to run.

A workflow a pipeline saved says so in the editor, under its title, and the workflow list says From its file under Updated. The workflow stays editable: a save in the app is all it takes to work there again, and the editor and the list then say it was Edited here. The next update replaces that edit with the file’s steps and names who made it, so commit the edit’s file first if you mean to keep it. See The editor.

A run of a file’s own steps says File for its Version on its page, and the run list marks it “file”. A run of a workflow that is only in files says Only in files so far for its Workflow, and offers neither Edit workflow nor Run again, since the workflow has no page yet. On a batch’s page, such a workflow that did not start shows its name with no link.

get_workflow_files gives a project’s workflows as files, each with its text and the path to put it at (checkout/buy-a-helmet.yaml, or buy-a-helmet.yaml for a workflow in no folder). workflow_id gives one workflow’s file, and tag and folder narrow them. With none of them, it gives the project’s routines’ files too, each with kind routine, at routines/<file id>.yaml. get_workflow and list_workflows give each workflow’s fileId, whether it is kept in a repository (inRepository), and whether it was saved here since (editedSinceFile). save_workflow on a workflow kept in a repository saves it, and its answer says that a pipeline’s update will replace the save unless the file is changed and committed too.