Skip to content

Checking files

A mistake in a resource file (an unknown key, a reference to a resource that does not exist, an expression that does not parse) otherwise shows only once a daemon loads the file, as a diagnostic in runy ns or the console. runy check finds it before: it reads the files in the CLI process, with no daemon, no state and no network, so it runs on a clean checkout.

Terminal window
runy check

It checks the workspace enclosing the current folder and its declared sources, prints one line per finding (path:line:col: error|warning: message [id]) and a summary, and exits 1 when it found an error. The CLI reference lists what it checks and what it cannot know without running anything.

A daemon remembers the folders loaded with runy load; runy check reads only the .runy.json of the workspace. Give it the other folders with --source, and their default namespace with --ns, as runy load takes them:

Terminal window
runy check --source tools/.runy --ns tools

To check several workspaces, name their roots: runy check . ../other.

Install runy in the job and run runy check from the repository’s root; its exit code fails the job. --strict fails on warnings too, and --format json prints the findings as JSON for a step that annotates them.

Terminal window
curl -fsSL https://setup.runy.dev | sh
export PATH="$HOME/.local/bin:$PATH"
runy check --strict

A Git hook that refuses a commit while the files have errors, in .git/hooks/pre-commit (made executable):

#!/bin/sh
exec runy check

With the pre-commit framework, a local hook in .pre-commit-config.yaml:

repos:
- repo: local
hooks:
- id: runy-check
name: runy check
entry: runy check
language: system
pass_filenames: false
files: '(\.ya?ml|\.runy\.json)$'

runy schema prints a JSON Schema of a resource document, generated from the kinds the installed runy knows, so it matches its version. Write it to a file and point the YAML language server at it (VS Code’s YAML extension, and any editor that runs yaml-language-server):

Terminal window
runy schema -o .runy/schema.json
runy schema --kind config -o .runy/config.schema.json

A file names its schema in a comment on its first line; the schema applies to each document of the file:

# yaml-language-server: $schema=./schema.json
kind: port
name: web
spec:
preferred: 3000

Or associate the files once, in VS Code’s settings.json:

{
"yaml.schemas": {
".runy/schema.json": [".runy/**/*.yaml", ".runy/**/*.yml"]
},
"json.schemas": [
{ "fileMatch": [".runy.json"], "url": "./.runy/config.schema.json" }
]
}

The editor then completes the keys of each kind’s spec once kind is set, and flags unknown keys and values of the wrong type. Any value may be a ${ ... } expression, which the schema accepts in place of a number, a boolean, a list or a mapping. Generate the schema again after upgrading runy.