Skip to content

Playbook templates: contribution guide and CI check - #281

Open
penhouetp wants to merge 3 commits into
mainfrom
chore/playbook-templates-contribution-flow
Open

penhouetp wants to merge 3 commits into
mainfrom
chore/playbook-templates-contribution-flow

Conversation

@penhouetp

Copy link
Copy Markdown
Contributor

Why

Every template merged on main is published in the playbook editor for all customers, at the next release of the playbook service. Until now nothing checked a template before that: the platform skips a template it refuses (and removes it if it was already published), and a reference to a node that does not exist makes every run fail. Contributors also had no guide beyond three lines in the README.

What this adds

  • playbooks/README.md: how to contribute a template (build and run it in Sekoia, export it, complete it, check it, open a pull request), what makes a good template, what the check verifies.
  • playbooks/tools/check_templates.py: checks every template against the production branch of automation-library.
    • Errors: missing or duplicate uuid, account (module or trigger configuration) left in a node, node ids that are not numbers, outputs to missing nodes, unknown action or trigger or wrong module, arguments that do not match the action (required ones included, Jinja values accepted), malformed operators, invalid Jinja, node.N that does not exist.
    • Warnings: empty description, unreachable node, branch that matches no case or output, field read from a node that its action does not declare, tag spelling.
    • On a pull request, only the files it touches can block it.
  • playbooks/tools/export_template.py: turns a playbook into a template file through the public API (GET /v1/symphony/playbooks/{uuid}, "View playbooks" permission), removes the accounts of the community and sets a new uuid. Standard library only.
  • .github: workflow running the check on pull requests, on main and every Monday (an action can change in automation-library after a template is merged); pull request template; issue forms for template ideas and broken templates.
  • Removes playbooks/templates/playbooks.json: the editor has listed templates from the platform API since July 2024 and the platform skips this file. It had drifted (16 of 41 entries differed from their template) and caused most merge conflicts.

Tested

  • The check gives the same verdict as the platform's own template validation on deliberately broken templates (bad edge, bad node id, wrong argument type, missing required argument, unknown action).
  • The guide's commands run as written from a fresh directory with Python 3.11.
  • export_template.py exported a real playbook from FRA1; the file had no account left and passed both the check and the platform validation (the test file was not added).

Before and after merging

🤖 Generated with Claude Code

… templates

- playbooks/README.md: how to contribute a template (build and run it in Sekoia,
  export it with the API, complete it, check it, open a pull request), what makes
  a good template, what the check verifies.
- playbooks/tools/check_templates.py: checks every template against the
  production branch of automation-library. Errors are what the platform refuses
  when it loads a template, or what makes every run fail; on a pull request only
  the files it touches can block it.
- playbooks/tools/export_template.py: turns a playbook into a template file
  through the public API (GET /v1/symphony/playbooks/{uuid}), without the
  accounts of the community.
- .github: workflow running the check on pull requests, on main and weekly;
  pull request template; issue forms for template ideas and broken templates.
- Remove playbooks/templates/playbooks.json: the platform has listed templates
  from its own API since July 2024 and skips this file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The tag check warned on every template using the usual spelling as well.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Problems already on main in other files are summed up in one line and are no
longer annotated, so a contributor only sees what is theirs to fix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant