[ci] Add a mypy lint check for code that uses it
Signed-off-by: Rupert Swarbrick <rswarbrick@lowrisc.org>
diff --git a/ci/jobs/quick-lint.sh b/ci/jobs/quick-lint.sh
index 97e99ea..a399b73 100755
--- a/ci/jobs/quick-lint.sh
+++ b/ci/jobs/quick-lint.sh
@@ -33,11 +33,14 @@
echo -e "\n### Check Licence Headers"
ci/scripts/check-licence-headers.sh $tgt_branch
-echo -e "\n### Run Python lint"
+echo -e "\n### Run Python lint (flake8)"
ci/scripts/python-lint.sh $tgt_branch || {
echo "(ignoring python lint errors)"
}
+echo -e "\n### Run Python lint (mypy)"
+ci/scripts/mypy.sh $tgt_branch
+
echo -e "\n### Ensure all generated files are clean and up-to-date"
ci/scripts/check-generated.sh
diff --git a/ci/scripts/mypy.sh b/ci/scripts/mypy.sh
new file mode 100755
index 0000000..8a31952
--- /dev/null
+++ b/ci/scripts/mypy.sh
@@ -0,0 +1,25 @@
+#!/bin/bash
+# Copyright lowRISC contributors.
+# Licensed under the Apache License, Version 2.0, see LICENSE for details.
+# SPDX-License-Identifier: Apache-2.0
+
+# Run mypy to do Python linting on code that uses it
+
+set -e
+
+dirs_with_lint_makefile=(
+ hw/ip/otbn/dv/rig
+ hw/ip/otbn/dv/otbnsim
+ hw/ip/otbn/util
+)
+
+retcode=0
+for dir in "${dirs_with_lint_makefile[@]}"; do
+ make -C "$dir" lint || {
+ echo -n "##vso[task.logissue type=error]"
+ echo "Failed mypy check in ${dir}."
+ retcode=1
+ }
+done
+
+exit $retcode