-
Notifications
You must be signed in to change notification settings - Fork 0
docs: Editor Integration guide + promote .yaml-workflow.yaml convention #39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| # Editor Integration | ||
|
|
||
| yaml-workflow ships a [JSON Schema](https://json-schema.org/) (draft-07) that | ||
| describes the workflow file format. Point your editor at it to get **inline | ||
| validation and autocomplete** for `name`, `params`, `settings`, `imports`, | ||
| `steps`, `flows`, task types, and their inputs. | ||
|
|
||
| The schema lives at | ||
| [`schema/workflow-schema.json`](https://github.com/orieg/yaml-workflow/blob/main/schema/workflow-schema.json) | ||
| and is served over HTTPS at its canonical `$id`: | ||
|
|
||
| ``` | ||
| https://raw.githubusercontent.com/orieg/yaml-workflow/main/schema/workflow-schema.json | ||
| ``` | ||
|
|
||
| There are three ways to wire it up, from most to least portable. | ||
|
|
||
| ## 1. Per-file modeline (works everywhere) | ||
|
|
||
| Add a `yaml-language-server` modeline as the first line of any workflow file. | ||
| This works in VS Code (Red Hat YAML extension), Neovim (via `yaml-language-server`), | ||
| and any editor that speaks the YAML Language Server — no settings file required, | ||
| and it works regardless of how the file is named: | ||
|
|
||
| ```yaml | ||
| # yaml-language-server: $schema=https://raw.githubusercontent.com/orieg/yaml-workflow/main/schema/workflow-schema.json | ||
| name: My Workflow | ||
| steps: | ||
| - name: hello | ||
| task: shell | ||
| inputs: | ||
| command: echo "hi" | ||
| ``` | ||
|
|
||
| Prefer a local copy (e.g. offline, or to pin a version)? Point at a schema file | ||
| on disk with a path relative to the workflow file: | ||
|
|
||
| ```yaml | ||
| # yaml-language-server: $schema=./schema/workflow-schema.json | ||
| ``` | ||
|
|
||
| The schema is also bundled inside the installed package (at | ||
| `yaml_workflow/schema/workflow-schema.json`) for programmatic access via | ||
| `importlib.resources`. | ||
|
|
||
| ## 2. VS Code workspace setting | ||
|
|
||
| Install the [Red Hat YAML extension](https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml) | ||
| and map the schema to your workflow files in `.vscode/settings.json`: | ||
|
|
||
| ```json | ||
| { | ||
| "yaml.schemas": { | ||
| "https://raw.githubusercontent.com/orieg/yaml-workflow/main/schema/workflow-schema.json": [ | ||
| "**/*.yaml-workflow.yaml", | ||
| "workflows/**/*.yaml" | ||
| ] | ||
|
orieg marked this conversation as resolved.
|
||
| } | ||
| } | ||
| ``` | ||
|
|
||
| Adjust the globs to match wherever your workflow files live. | ||
|
|
||
| ## 3. JetBrains IDEs (IntelliJ, PyCharm) | ||
|
|
||
| 1. Open **Settings → Languages & Frameworks → Schemas and DTDs → JSON Schema Mappings**. | ||
| 2. Click **+** and set **Schema file or URL** to the URL above (or a local path). | ||
| 3. Set **Schema version** to `JSON Schema version 7`. | ||
| 4. Add a file path pattern such as `*.yaml-workflow.yaml` or `workflows/*.yaml`. | ||
|
|
||
| ## Recommended file-naming convention | ||
|
|
||
| For **zero-config** autocomplete via [SchemaStore](https://www.schemastore.org/) | ||
| (see below), name your workflow files with a `.yaml-workflow.yaml` (or | ||
| `.yaml-workflow.yml`) suffix: | ||
|
|
||
| ``` | ||
| deploy.yaml-workflow.yaml | ||
| etl/nightly.yaml-workflow.yaml | ||
| ``` | ||
|
|
||
| This distinctive suffix lets editors auto-detect the schema without any | ||
| per-project configuration, and avoids clashing with the many other tools that | ||
| use generically-named `*.yaml` files. Any filename still works with the | ||
| modeline or the explicit mappings above — the suffix is only needed for | ||
| SchemaStore auto-detection. | ||
|
|
||
| ## SchemaStore auto-detection | ||
|
|
||
| The schema is [submitted to SchemaStore](https://github.com/SchemaStore/schemastore/pull/6213). | ||
| Once merged, editors that consume the SchemaStore catalog — VS Code with the | ||
| Red Hat YAML extension, JetBrains IDEs, and others — will automatically validate | ||
| and autocomplete files matching `*.yaml-workflow.yaml` / `*.yaml-workflow.yml` | ||
| with no manual configuration. | ||
|
|
||
| ## Command-line validation | ||
|
|
||
| Validate workflow files in CI or a pre-commit hook with any JSON Schema | ||
| validator, for example [`check-jsonschema`](https://check-jsonschema.readthedocs.io/): | ||
|
|
||
| ```bash | ||
| check-jsonschema \ | ||
| --schemafile https://raw.githubusercontent.com/orieg/yaml-workflow/main/schema/workflow-schema.json \ | ||
| workflows/my_workflow.yaml | ||
| ``` | ||
|
|
||
| You can also validate with the built-in command, which uses the engine's own | ||
| validator: | ||
|
|
||
| ```bash | ||
| yaml-workflow validate workflows/my_workflow.yaml | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.