From 314ebbcf3687817b0e5fa6a9cfa2b7e4e9a7892b Mon Sep 17 00:00:00 2001 From: Frantisek Hrbata Date: Mon, 12 Jun 2023 13:06:41 +0200 Subject: [PATCH] tools: add sbom-hash check to pre-commit This uses the test from CI introduced in MR !23989. Even though the original CI test is run with pytest, it doesn't use any pytest specific code/features and it should never need them. So it make sense just to re-use the code. Signed-off-by: Frantisek Hrbata --- .pre-commit-config.yaml | 6 ++++++ tools/test_sbom/test_submodules.py | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bf1ea1948b..abdf8bca4e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -152,6 +152,12 @@ repos: additional_dependencies: - PyYAML == 5.3.1 - ruamel.yaml + - id: submodule-sbom-hash-check + name: Check if sbom-hash values for submodules in .gitmodules match submodules checkout hash in git tree + entry: python tools/test_sbom/test_submodules.py + language: python + always_run: true + pass_filenames: false - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.0.1 hooks: diff --git a/tools/test_sbom/test_submodules.py b/tools/test_sbom/test_submodules.py index 0bc161bcfb..90c622fd0d 100644 --- a/tools/test_sbom/test_submodules.py +++ b/tools/test_sbom/test_submodules.py @@ -67,3 +67,7 @@ def test_sha() -> None: f'information if necessary. It is important to keep this information ' f'up-to-date for SBOM generation.') assert submodule['hash'] == sbom_hash, msg + + +if __name__ == '__main__': + test_sha()