From 070a6d1fc7e83902e72b26416b4764b24bddb42e Mon Sep 17 00:00:00 2001 From: Sean Budd Date: Fri, 16 Aug 2024 10:42:13 +1000 Subject: [PATCH 1/5] Support license check in pre-commit CI --- .pre-commit-config.yaml | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2d506f6dcf2..341605f3312 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,14 +3,24 @@ exclude: ^user_docs/(?!en/).*$ # https://pre-commit.ci/ # Configuration for Continuous Integration service ci: - # Can't run Windows scripts on Linux - # These also do not apply fixes, only run tests - skip: [scons-source, checkPot, unitTest, licenseCheck] + # Can't run Windows scons scripts on Linux. + # unit testing requires our python environment, + # which cannot be configured with pre-commit.ci: + # https://stackoverflow.com/questions/70778806/pre-commit-not-using-virtual-environment + skip: [scons-source, checkPot, unitTest] autoupdate_schedule: monthly autoupdate_commit_msg: "Pre-commit auto-update" autofix_commit_msg: "Pre-commit auto-fix" +default_language_version: + python: python3.11 + repos: +- repo: https://github.com/pre-commit-ci/pre-commit-ci-config + rev: v1.6.1 + hooks: + - id: check-pre-commit-ci-config + - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.6.0 hooks: @@ -113,7 +123,8 @@ repos: types_or: [python, c, c++, batch] - id: licenseCheck name: Check license compatibility of pip dependencies - files: ^(requirements\.txt|runlicensecheck\.bat)$ - entry: ./runlicensecheck.bat - language: script + files: ^requirements\.txt$ + entry: py -m licensecheck -0 --format ansi + language: python + additional_dependencies: [licensecheck] pass_filenames: false From 595d59c5a86d739fae23b1ca200e5d5d8d9cb6e5 Mon Sep 17 00:00:00 2001 From: Sean Budd Date: Fri, 16 Aug 2024 11:04:32 +1000 Subject: [PATCH 2/5] add meta hooks --- .pre-commit-config.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 341605f3312..bf4b514136f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -21,6 +21,11 @@ repos: hooks: - id: check-pre-commit-ci-config +- repo: meta + hooks: + - id: check-useless-excludes + - id: check-hooks-apply + - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.6.0 hooks: From 83e738f271016e0f1cd07f9d0e7d8dc2f5b85a43 Mon Sep 17 00:00:00 2001 From: Sean Budd Date: Fri, 16 Aug 2024 11:07:06 +1000 Subject: [PATCH 3/5] change python ref --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bf4b514136f..7069013f5e6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -129,7 +129,7 @@ repos: - id: licenseCheck name: Check license compatibility of pip dependencies files: ^requirements\.txt$ - entry: py -m licensecheck -0 --format ansi + entry: python -m licensecheck -0 --format ansi language: python additional_dependencies: [licensecheck] pass_filenames: false From 686a854343880214e550c61ef572c4376a8fe184 Mon Sep 17 00:00:00 2001 From: Sean Budd Date: Fri, 16 Aug 2024 11:11:25 +1000 Subject: [PATCH 4/5] remove licenseCheck --- .pre-commit-config.yaml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7069013f5e6..c026362be40 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,8 +6,10 @@ ci: # Can't run Windows scons scripts on Linux. # unit testing requires our python environment, # which cannot be configured with pre-commit.ci: - # https://stackoverflow.com/questions/70778806/pre-commit-not-using-virtual-environment - skip: [scons-source, checkPot, unitTest] + # https://stackoverflow.com/questions/70778806/pre-commit-not-using-virtual-environment . + # Can't run licenseCheck as it relies on telemetry, + # which CI blocks. + skip: [scons-source, checkPot, unitTest, licenseCheck] autoupdate_schedule: monthly autoupdate_commit_msg: "Pre-commit auto-update" autofix_commit_msg: "Pre-commit auto-fix" @@ -128,8 +130,7 @@ repos: types_or: [python, c, c++, batch] - id: licenseCheck name: Check license compatibility of pip dependencies - files: ^requirements\.txt$ - entry: python -m licensecheck -0 --format ansi - language: python - additional_dependencies: [licensecheck] + files: ^(requirements\.txt|runlicensecheck\.bat)$ + entry: ./runlicensecheck.bat + language: script pass_filenames: false From f00ca35357a90eba9d0cbadcee740c8324c7069a Mon Sep 17 00:00:00 2001 From: Sean Budd Date: Fri, 16 Aug 2024 15:09:03 +1000 Subject: [PATCH 5/5] Update .pre-commit-config.yaml Co-authored-by: Sascha Cowley <16543535+SaschaCowley@users.noreply.github.com> --- .pre-commit-config.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c026362be40..12ee6d84d81 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -25,7 +25,9 @@ repos: - repo: meta hooks: + # ensures that exclude directives apply to any file in the repository. - id: check-useless-excludes + # ensures that the configured hooks apply to at least one file in the repository. - id: check-hooks-apply - repo: https://github.com/pre-commit/pre-commit-hooks