Worked example: a YAML jobspec generator#

Consider the YAML test file:

tests:
  hello_yaml:
    keywords: [demo]
    script:
      - echo "hello from yaml"

This file can be turned into a runnable canary test spec in just a few lines of plugin code:

import canary

@canary.hookimpl
def canary_collectstart(collector) -> None:
    collector.add_generator(YAMLJobGenerator)

Further sections will describe how the generator recognizes files, validates YAML, and generates one or more ResolvedSpec objects.