-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new worklow: validate automation schema
Using yamale, we're now ensuring the automation file schema is correct: - check for required data - check for data type - check overall structure of the file
- Loading branch information
Showing
3 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,30 @@ | ||
# This schema is used to validate the automation files. | ||
# Be sure to update this file if ou add new parameters, | ||
# or change names or types in the existing files! | ||
# We are using yamale to validate files | ||
# https://github.com/23andMe/Yamale | ||
--- | ||
vas: map(include('_architecture'), key=str()) | ||
|
||
--- | ||
# Define various nested types | ||
_values: | ||
name: str() | ||
src_file: str() | ||
--- | ||
_hook: | ||
name: str() | ||
type: str() | ||
source: str() | ||
inventory: str(required=False) | ||
--- | ||
_stage: | ||
path: str() | ||
wait_conditions: list(min=1) | ||
values: list(include('_values'), min=1) | ||
build_output: str() | ||
pre_stage_run: list(include('_hook'), required=False) | ||
post_stage_run: list(include('_hook'), required=False) | ||
--- | ||
_architecture: | ||
stages: list(include('_stage'), min=1) |
This file contains 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,29 @@ | ||
--- | ||
name: Validate automation schema | ||
on: # yamllint disable-line rule:truthy | ||
pull_request: | ||
branches: | ||
- main | ||
- stable | ||
paths: | ||
- ".ci/automation-schema.yaml" | ||
- "automation/vars/*.yaml" | ||
- "automation/vars/*.yml" | ||
|
||
jobs: | ||
yamale: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.10' | ||
|
||
- name: Install yaml-lint | ||
run: pip install yamale | ||
|
||
- name: Run yamale | ||
run: yamale -s .ci/automation-schema.yaml automation/vars/ |
This file contains 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,14 @@ | ||
# Automation files | ||
|
||
## Schema validation | ||
The files are tested using `yamale`. Be sure to update | ||
the `.ci/automation-schema.yaml` file at the root of this | ||
project if you add a new key, or modify a type! | ||
|
||
More information about [yamale](https://github.com/23andMe/Yamale). | ||
|
||
## Manually check schema | ||
```Bash | ||
$ pip install yamale | ||
$ yamale -s .ci/automation-schema.yaml automation/vars | ||
``` |