-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: add schema checks for LAVA test plans
This commit adds a script for checking the schema of LAVA job templates. The test is executed using the LAVA code from lava_common.schemas.validate. Script is executed using lava-server container in version that corresponds to the LAVA server running the actual tests in CI. Signed-off-by: Milosz Wasilewski <[email protected]>
- Loading branch information
Showing
5 changed files
with
101 additions
and
1 deletion.
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,28 @@ | ||
name: Chech LAVA templates | ||
|
||
on: | ||
workflow_call: | ||
|
||
jobs: | ||
schema-check: | ||
runs-on: ubuntu-latest | ||
container: lavasoftware/lava-server:2024.09 | ||
steps: | ||
- name: Clone repository | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Schema check | ||
run: | | ||
DEVICE_TYPE="my-device" | ||
BUILD_FILE_NAME="build.tar.gz" | ||
BUILD_DOWNLOAD_URL="https://example.com/downloads/1" | ||
GITHUB_SHA="7e6f96ccf3e911a8a1a18accdbb91991aa0db66e" | ||
find ci/lava/ -name "*.yaml" -exec sed -i "s|{{DEVICE_TYPE}}|${DEVICE_TYPE}|g" '{}' \; | ||
find ci/lava/ -name "*.yaml" -exec sed -i "s|{{GITHUB_SHA}}|${GITHUB_SHA}|g" '{}' \; | ||
find ci/lava/ -name "*.yaml" -exec sed -i "s|{{BUILD_DOWNLOAD_URL}}|${BUILD_DOWNLOAD_URL}|g" '{}' \; | ||
find ci/lava/ -name "*.yaml" -exec sed -i "s|{{BUILD_FILE_NAME}}|${BUILD_FILE_NAME}|g" '{}' \; | ||
find ci/lava/ -name "*.yaml" -exec sed -i "s|{{GITHUB_RUN_ID}}|${GITHUB_RUN_ID}|g" '{}' \; | ||
python3 ci/schemacheck.py ./ci/lava/ |
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
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
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,35 @@ | ||
# Test setup | ||
|
||
`ci/lava` directory contains directories with names corresponding to build MACHINE names. | ||
New directories should only be added after the build is available for a given MACHINE. | ||
All files in the `ci/lava/<MACHINE>` directory should have `.yaml` extension. | ||
Each file should be a valid LAVA job template. | ||
|
||
LAVA templates are used to create test jobs during the CI runs in this repository. | ||
This happens for the following triggers: | ||
- pull_request | ||
- push | ||
- cron (nightly build) | ||
|
||
# LAVA job templates | ||
|
||
Job templates can use the following variables: | ||
- `DEVICE_TYPE`: name of the LAVA device type or alias. Full list can be found on [LAVA master web interface](https://lava.infra.foundries.io/scheduler/device_types) | ||
- `GITHUB_SHA`: Commit ID corresponding to the github action trigger | ||
- `BUILD_FILE_NAME`: Name of the build artifact to be downloaded. It's constructed as: `core-image-base-${DEVICE_TYPE}.rootfs.qcomflash.tar.gz` | ||
- `BUILD_DOWNLOAD_URL`: URL where the build artifacts can be found. This variable is constructed as: `${{inputs.url}}/${DEVICE_TYPE}/${BUILD_FILE_NAME}` where `{{inputs.url}}` comes from the build action. | ||
- `GITHUB_RUN_ID`: ID of the current Github run. | ||
|
||
After variable substitution the file should form a valid LAVA job definition. | ||
|
||
# Template validation | ||
|
||
Template validation is performed as github action using `lavasoftware/lava-server` container. | ||
Version of the container will be kept in sync with the LAVA server running the test jobs. | ||
Validation script, `schemacheck.py`, uses LAVA code from `lava_common.schemas.validate` method and PyYAML parser. | ||
|
||
## Local template validation | ||
|
||
Templates can be validated locally using `lavasoftware/lava-server` container. | ||
|
||
docker run --rm -v $PWD:/home/ lavasoftware/lava-server:latest python3 /home/ci/schemacheck.py /home/ci/lava |
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,33 @@ | ||
# Copyright (c) 2025 Qualcomm Innovation Center, Inc. All rights reserved. | ||
# SPDX-License-Identifier: MIT | ||
|
||
import os | ||
import sys | ||
import yaml | ||
import voluptuous | ||
from lava_common.schemas import validate | ||
|
||
exitcode = 0 | ||
|
||
for root, dirs, files in os.walk(sys.argv[1]): | ||
for fname in files: | ||
if fname.endswith(".yaml"): | ||
filename = os.path.join(root, fname) | ||
|
||
try: | ||
f = open(filename, "rb") | ||
y = yaml.safe_load(f) | ||
f.close() | ||
validate(y) | ||
print(f"{filename} is valid") | ||
except voluptuous.Invalid as e1: | ||
print(f"{filename} is invalid") | ||
print(e1.msg) | ||
print(e1.path) | ||
exitcode += 1 | ||
except yaml.error.MarkedYAMLError as e2: | ||
print(f"{filename} is invalid") | ||
print(e2.problem) | ||
print(e2.problem_mark) | ||
exitcode += 1 | ||
sys.exit(exitcode) |