Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(HIS): introduction to the HIS checker #52

Merged
merged 4 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/workflows/templates/c.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,15 @@ jobs:
with:
submodules: recursive
- run: make PLATFORM=${{ matrix.platform }} misra-check

his:
runs-on: ubuntu-latest
container: baoproject/bao:latest
strategy:
matrix:
platform: ["qemu-aarch64-virt", "qemu-riscv64-virt"]
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- run: make PLATFORM=${{ matrix.platform }} his-check
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ include ci.mk

python_scripts:= \
$(root_dir)/misra/deviation_suppression.py \
$(root_dir)/license_check.py
$(root_dir)/license_check.py \
$(root_dir)/his_checker.py
$(call ci, pylint, $(python_scripts))

yaml_files:= \
Expand Down
20 changes: 20 additions & 0 deletions ci.mk
Original file line number Diff line number Diff line change
Expand Up @@ -287,5 +287,25 @@ endef

#############################################################################

# HIS Checker
# Use this rule to run the HIS add-on checker:
# make his-check <files>
# @param files space separated list of files (with path)
# @example $(call ci, his, file1.c file2.c file3.h)

his_check_script:=$(ci_dir)/his_checker.py

his-check:
@$(his_check_script) $(_his_files)

.PHONY: his-check
non_build_targets+=his-check

define his
_his_files+=$1
endef

#############################################################################

ci=$(eval $(call $1, $2, $3, $4, $5, $6, $7, $8, $9))

24 changes: 24 additions & 0 deletions his_checker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/python3

# SPDX-License-Identifier: Apache-2.0
# Copyright (c) Bao Project and Contributors. All rights reserved

"""
Generating HIS metrics check
"""

import sys
import argparse

if __name__ == "__main__":
METRICS_LIST = []
CHECK_FAIL = 0
PARSER = argparse.ArgumentParser()
PARSER.add_argument("files", nargs="+", help="The files to process")
ARGS = PARSER.parse_args()

for metric in METRICS_LIST:
CHECK_FAIL += metric(ARGS)

if CHECK_FAIL:
sys.exit(-1)
Loading