Skip to content

Commit 7f21524

Browse files
committed
workflows: add LAVA templates schema check
Check schema of LAVA templates that are used for submitting jobs. The workflow fails if the schema is incorrect and doesn't match supported schemas in current LAVA release. Signed-off-by: Milosz Wasilewski <[email protected]>
1 parent 99f2515 commit 7f21524

File tree

4 files changed

+66
-2
lines changed

4 files changed

+66
-2
lines changed

.github/workflows/build-on-pr.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ jobs:
2222

2323
build-pr:
2424
uses: ./.github/workflows/debos.yml
25-
25+
schema-check:
26+
uses: ./.github/workflows/lava-schema-check.yml

.github/workflows/build-on-push.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ permissions:
1313
jobs:
1414
build-daily:
1515
uses: ./.github/workflows/debos.yml
16+
schema-check:
17+
uses: ./.github/workflows/lava-schema-check.yml
1618
test:
1719
uses: ./.github/workflows/test.yml
18-
needs: [build]
20+
needs: [build, schema-check]
1921
secrets: inherit
2022
with:
2123
url: ${{ needs.build.outputs.artifacts_url }}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Chech LAVA templates
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
schema-check:
8+
runs-on: ubuntu-latest
9+
container: lavasoftware/lava-server:2025.04
10+
steps:
11+
- name: Clone repository
12+
uses: actions/checkout@v4
13+
with:
14+
fetch-depth: 0
15+
- name: Schema check
16+
run: |
17+
DEVICE_TYPE="my-device"
18+
BUILD_FILE_NAME="build.tar.gz"
19+
BUILD_DOWNLOAD_URL="https://example.com/downloads/1"
20+
GITHUB_SHA="7e6f96ccf3e911a8a1a18accdbb91991aa0db66e"
21+
22+
find ci/lava/ -name "*.yaml" -exec sed -i "s|{{DEVICE_TYPE}}|${DEVICE_TYPE}|g" '{}' \;
23+
find ci/lava/ -name "*.yaml" -exec sed -i "s|{{GITHUB_SHA}}|${GITHUB_SHA}|g" '{}' \;
24+
find ci/lava/ -name "*.yaml" -exec sed -i "s|{{BUILD_DOWNLOAD_URL}}|${BUILD_DOWNLOAD_URL}|g" '{}' \;
25+
find ci/lava/ -name "*.yaml" -exec sed -i "s|{{BUILD_FILE_NAME}}|${BUILD_FILE_NAME}|g" '{}' \;
26+
find ci/lava/ -name "*.yaml" -exec sed -i "s|{{GITHUB_RUN_ID}}|${GITHUB_RUN_ID}|g" '{}' \;
27+
28+
python3 ci/schemacheck.py ./ci/lava/

ci/schemacheck.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Copyright (c) 2025 Qualcomm Innovation Center, Inc. All rights reserved.
2+
# SPDX-License-Identifier: MIT
3+
4+
import os
5+
import sys
6+
import yaml
7+
import voluptuous
8+
from lava_common.schemas import validate
9+
10+
exitcode = 0
11+
12+
for root, dirs, files in os.walk(sys.argv[1]):
13+
for fname in files:
14+
if fname.endswith(".yaml"):
15+
filename = os.path.join(root, fname)
16+
17+
try:
18+
f = open(filename, "rb")
19+
y = yaml.safe_load(f)
20+
f.close()
21+
validate(y)
22+
print(f"{filename} is valid")
23+
except voluptuous.Invalid as e1:
24+
print(f"{filename} is invalid")
25+
print(e1.msg)
26+
print(e1.path)
27+
exitcode += 1
28+
except yaml.error.MarkedYAMLError as e2:
29+
print(f"{filename} is invalid")
30+
print(e2.problem)
31+
print(e2.problem_mark)
32+
exitcode += 1
33+
sys.exit(exitcode)

0 commit comments

Comments
 (0)