From e9214b186f2377d7a23c65f8df78363facb2b65f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wiktor=20Niesiob=C4=99dzki?= Date: Thu, 30 May 2024 18:28:46 +0000 Subject: [PATCH] Add outstanding checks from lint.sh to pre-commit * versions * validate metadata * check names * check links --- .pre-commit-config.yaml | 22 ++++++++++++++++++++++ tools/check_links.py | 5 ++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e4b2263e78..a9f013245c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -50,6 +50,28 @@ repos: pass_filenames: false require_serial: true files: ^fast/.*tf + - id: versions + name: Align Terraform provider versions + language: script + files: (versions.tf|^default-versions.tf)$ + pass_filenames: false + entry: /usr/bin/find . -type f -name 'versions.tf' -exec cp default-versions.tf {} \; + - id: validate_metadata + name: Validate blueprints metadata + language: system + pass_filenames: false + files: ^blueprints + entry: tools/validate_metadata.py -v --failed-only blueprints + - id: check-names + name: Check name lengths for FAST + language: system + pass_filenames: false + files: ^fast + entry: tools/check_names.py --prefix-length=10 --failed-only fast/stages + - id: check-links + name: Check links in markdown files + language: system + entry: tools/check_links.py --no-show-summary --scan-files # - repo: https://github.com/adrienverge/yamllint # rev: v1.34.0 diff --git a/tools/check_links.py b/tools/check_links.py index 202bc6401f..cbebdea4c6 100755 --- a/tools/check_links.py +++ b/tools/check_links.py @@ -78,9 +78,12 @@ def check_docs(dir_name, external=False): @click.option('-e', '--external', is_flag=True, default=False, help='Whether to test external links.') @click.option('--show-summary/--no-show-summary', default=True) -def main(dirs, external, show_summary=True): +@click.option('--scan-files', default=False, is_flag=True) +def main(dirs, external, show_summary=True, scan_files=False): 'Checks links in Markdown files contained in dirs.' errors = [] + if scan_files: + dirs = [pathlib.Path(x).parent for x in dirs] for dir_name in dirs: if show_summary: print(f'----- {dir_name} -----')