DocsWorkflows

Workflows

A workflow is a folder of a repository of the desk server that other repositories read at a fixed landing (#245). It holds Buck2 rules, scripts and settings that many repositories need, so no repository keeps a copy and none can change it by accident. A change of a workflow lands once, and each repository takes it with one line.

How a repository uses one

A workflow is an entry of checkouts in .desk/config.json (docs/runs.md):

"checkouts": [
  {"repo": "munhq/desk", "path": ".desk/workflows/buck-base", "at": 561, "subpath": "workflows/buck-base"},
  {"repo": "munhq/desk", "path": ".desk/workflows/buck-rust", "at": 561, "subpath": "workflows/buck-rust"}
]
  • at is a log entry of the repository that holds the workflow. The run reads the tree of that entry, not the tree of main. A later landing there changes no run until this config names the new entry.
  • subpath writes one folder of that repository at path in the run.
  • The run id holds the tree of the folder. A change of a file of the workflow gives a new run. An unchanged workflow keeps the ids, so the cache stays right.
  • To take a newer version, change at and land it. To stay on a version, change nothing.
  • The gate of a landing mounts the checkouts that the tree names, and the checks that run come from main. A checkout of the tree that does not resolve leaves the gate with the checkouts of main.
  • desk repo move writes the entry for a Rust repository at the newest landing of munhq/desk.

The workflows of munhq/desk

Workflow Cells What it holds
workflows/buck-base/ toolchains, desk_platforms The C, Python, Rust and test toolchains, the execution platform with the remote cache and the remote execution of NativeLink, and scripts/buck-run.sh. Every repository mounts it.
workflows/buck-rust/ desk_rust The rule that runs one test binary as an action, gen_buck.py (the BUCK files from cargo metadata, with BUCK.extra for hand-written rules), buckify.sh, run_tests.py and the settings of reindeer.
workflows/buck-node/ desk_node The rule action, and node_modules for a project or for workspaces, with private packages.

Each README says how a repository names the cells in its .buckconfig. Each cell folder holds a .buckconfig that names the build file BUILD.desk, so munhq/desk, which holds the folders, sees no Buck2 package in them. munhq/desk names the same cells with the in-tree paths workflows/....

The shared step: buck-run.sh

sh .desk/workflows/buck-base/scripts/buck-run.sh <buck2 arguments> is what each check of a repository wrote for itself: the toolchain text for the key of every action, the remote cache or remote execution of the runner, the end of the Buck2 daemon, and the rule that an exit of Buck2 for an error of its infrastructure is exit 75, so desk records an error of the run and a bisect reverts nothing.

Private packages in an action

A package that needs a registry token is installed by an action that runs on the machine of the build and reads NODE_AUTH_TOKEN from its environment. The check gets the token from the secret of the repository or the org (docs/secrets.md). The token is no part of the action, so it is no part of the cache key: every run with the same lock file takes the result from the cache, also a desk try, which has no secret. A lock file that was never installed can be installed only on a run that has the secret, which is a check on main.

Add a workflow

  1. Make a folder workflows/<name>/ in munhq/desk with its files. A Buck2 cell is a folder with a .buckconfig (with [buildfile] name = BUILD.desk) and a BUILD.desk.
  2. Write its README: the cells, the lines of .buckconfig, and the commands.
  3. Land it, read the log entry with desk log, and name that entry in at of each repository that uses it.

Not yet

The step lists (validation entries) are still written again in each repository. A workflow.json that a repository names and the server expands is not built (#245).