Skip to content

Commit

Permalink
[ci, sival] Add azure & Github CI testplan validation job on PR
Browse files Browse the repository at this point in the history
Add an azure CI quick lint job step, and a Github Actions quick
lint job step, which will ensure that testplans are formatted correctly
by running the corresponding validation script, currently set to run on
both the `hw/top_earlgrey/data` and `hw/top_earlgrey/data/ip`
directories. This is also added to the `ci/jobs/quick-lint.sh` job so
that it can easily be run locally.

This is added to both azure and Github Actions as at present both of
these jobs still exist as a result of the partial CI migration from
Azure pipelines to Github Actions.

Signed-off-by: Alex Jones <[email protected]>
  • Loading branch information
AlexJones0 authored and nbdd0121 committed Sep 30, 2024
1 parent c5ce570 commit 6819083
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ jobs:
run: ./ci/scripts/python-lint.sh "$GITHUB_BASE_REF"
- name: Python (mypy)
run: ./ci/scripts/mypy.sh
- name: Validate testplans with schema
run: ./ci/scripts/validate_testplans.sh
- name: C/C++ formatting
run: ./ci/scripts/clang-format.sh "$GITHUB_BASE_REF"
- name: Rust formatting
Expand Down
4 changes: 4 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ jobs:
- bash: ci/scripts/clang-format.sh $SYSTEM_PULLREQUEST_TARGETBRANCH
condition: eq(variables['Build.Reason'], 'PullRequest')
displayName: clang-format (C/C++ lint)
# Validate testplans with schema (json schema)
- bash: ci/scripts/validate_testplans.sh
condition: eq(variables['Build.Reason'], 'PullRequest')
displayName: Validate testplans with schema
# Use clang-format to check C/C++ coding style
- bash: ci/scripts/rust-format.sh $SYSTEM_PULLREQUEST_TARGETBRANCH
condition: eq(variables['Build.Reason'], 'PullRequest')
Expand Down
3 changes: 3 additions & 0 deletions ci/jobs/quick-lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ ci/scripts/python-lint.sh $tgt_branch || {
echo -e "\n### Run Python lint (mypy)"
ci/scripts/mypy.sh $tgt_branch

echo -e "\n### Validate testplans with schema."
ci/scripts/validate_testplans.sh

echo -e "\n### Use clang-format to check C/C++ coding style"
ci/scripts/clang-format.sh $tgt_branch

Expand Down
26 changes: 26 additions & 0 deletions ci/scripts/validate_testplans.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
# Copyright lowRISC contributors (OpenTitan project).
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0

# Use a JSON schema to validate the testplan hjson files have the correct structure.

set -e

dirs_with_testplan_files=(
"hw/top_earlgrey/data"
"hw/top_earlgrey/data/ip"
)
testplan_schema="hw/lint/sival_testplan_schema.hjson"

for dir in "${dirs_with_testplan_files[@]}"; do
echo "Validating testplans under $dir:"
util/validate_testplans.py --dir "$dir" --schema "$testplan_schema" || {
echo -n "##vso[task.logissue type=error]"
echo "Failed testplan validation in ${dir}."
echo "::error::Failed testplan validation in ${dir}."
exit 1
}
done

exit 0

0 comments on commit 6819083

Please sign in to comment.