From 269e47a5656caf64536b63e5ddbbce32dc60d604 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wiktor=20Niesiob=C4=99dzki?= Date: Sun, 26 Oct 2025 09:51:37 +0000 Subject: [PATCH] Improve linting and fix agent-engine module name --- .github/workflows/linting.yml | 49 ++++++++++++------------------ .pre-commit-config.yaml | 18 +++++------ modules/agent-engine/versions.tf | 4 +-- modules/agent-engine/versions.tofu | 4 +-- tools/versions.py | 12 +++++--- 5 files changed, 39 insertions(+), 48 deletions(-) diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index f329e33af..c5c26c6bc 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -23,7 +23,6 @@ on: branches: - master - fast-dev - jobs: linting: runs-on: ubuntu-latest @@ -93,38 +92,30 @@ jobs: - name: Check python formatting id: yapf - run: | - yapf -p -d -r \ - tools/*.py \ - fast + uses: pre-commit/action@1b06ec171f2f6faa71ed760c4042bd969e4f8b43 + with: + extra_args: yapf --all-files - name: Check modules versions id: versions - run: | - OUTPUT_TF=$( - find . -type f -name 'versions.tf' -exec diff -I '[[:space:]]*module_name' -ub default-versions.tf {} \; - ) - if [[ -n "${OUTPUT_TF}" ]] ; then - echo "Terraform versions.tf:" - echo "${OUTPUT_TF}" - fi - OUTPUT_TOFU=$( - find . -type f -name 'versions.tofu' -exec diff -I '[[:space:]]*module_name' -ub default-versions.tofu {} \; - ) - if [[ -n "${OUTPUT_TOFU}" ]] ; then - echo "Terraform versions.tofu:" - echo "${OUTPUT_TOFU}" - fi - egrep -v "(required_version|module_name)" default-versions.tf > /tmp/versions.tf - egrep -v "(required_version|module_name)" default-versions.tofu > /tmp/versions.tofu - diff -rub /tmp/versions.tf /tmp/versions.tofu - DIFF_EC=$? - [[ "${DIFF_EC}" -eq "0" && -z "${OUTPUT_TF}" && -z "${OUTPUT_TOFU}" ]] + uses: pre-commit/action@1b06ec171f2f6faa71ed760c4042bd969e4f8b43 + with: + extra_args: versions --all-files - name: Check for diverging files id: duplicates - run: | - python3 tools/duplicate-diff.py + uses: pre-commit/action@1b06ec171f2f6faa71ed760c4042bd969e4f8b43 + with: + extra_args: duplicate-diff --all-files - - name: yaml-lint - uses: ibiqlik/action-yamllint@b74a2626a991d676b6ec243a6458ff86cccf2d2d + - name: Check YAML files + id: yaml-lint + uses: pre-commit/action@1b06ec171f2f6faa71ed760c4042bd969e4f8b43 + with: + extra_args: yamllint --all-files + + - name: Check for spelling mistakes + id: codespell + uses: pre-commit/action@1b06ec171f2f6faa71ed760c4042bd969e4f8b43 + with: + extra_args: codespell --all-files diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 96f226cb3..990923cfe 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -81,17 +81,13 @@ repos: require_serial: true files: ^fast/.*tf - id: versions - name: Align Terraform provider versions - language: script - files: (versions.tf|^default-versions.tf)$ + name: Align Terraform/OpenTofu provider versions + language: python + additional_dependencies: + - click + files: (versions.tf|^default-versions.tf|versions.tofu|default-versions.tofu)$ pass_filenames: false - entry: /usr/bin/find . -type f -name 'versions.tf' -exec cp default-versions.tf {} \; - - id: versions_tofu - name: Align OpenTofu provider versions - language: script - files: (versions.tofu|^default-versions.tofu)$ - pass_filenames: false - entry: /usr/bin/find . -type f -name 'versions.tofu' -exec cp default-versions.tofu {} \; + entry: tools/versions.py --quiet - id: check-names name: Check name lengths for FAST language: python @@ -149,7 +145,7 @@ repos: exclude: ".*tpl" - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: v6.0.0 hooks: - id: end-of-file-fixer - id: trailing-whitespace diff --git a/modules/agent-engine/versions.tf b/modules/agent-engine/versions.tf index 23c02ad27..e5725bd38 100644 --- a/modules/agent-engine/versions.tf +++ b/modules/agent-engine/versions.tf @@ -27,9 +27,9 @@ terraform { } } provider_meta "google" { - module_name = "google-pso-tool/cloud-foundation-fabric/modules/ai-applications:v45.0.0-tf" + module_name = "google-pso-tool/cloud-foundation-fabric/modules/agent-engine:v45.0.0-tf" } provider_meta "google-beta" { - module_name = "google-pso-tool/cloud-foundation-fabric/modules/ai-applications:v45.0.0-tf" + module_name = "google-pso-tool/cloud-foundation-fabric/modules/agent-engine:v45.0.0-tf" } } diff --git a/modules/agent-engine/versions.tofu b/modules/agent-engine/versions.tofu index e868b8c81..aa02aca95 100644 --- a/modules/agent-engine/versions.tofu +++ b/modules/agent-engine/versions.tofu @@ -27,9 +27,9 @@ terraform { } } provider_meta "google" { - module_name = "google-pso-tool/cloud-foundation-fabric/modules/ai-applications:v45.0.0-tofu" + module_name = "google-pso-tool/cloud-foundation-fabric/modules/agent-engine:v45.0.0-tofu" } provider_meta "google-beta" { - module_name = "google-pso-tool/cloud-foundation-fabric/modules/ai-applications:v45.0.0-tofu" + module_name = "google-pso-tool/cloud-foundation-fabric/modules/agent-engine:v45.0.0-tofu" } } diff --git a/tools/versions.py b/tools/versions.py index 7fe189f10..57e62a7f8 100755 --- a/tools/versions.py +++ b/tools/versions.py @@ -85,7 +85,8 @@ def process_file(template, file_path, context): @click.option("--tofu-version", help="Override OpenTofu version") @click.option("--write-defaults/--no-write-defaults", default=False, help="Also rewrite default-versions.t*f*") -def main(write_defaults, **kwargs): +@click.option("-q", "--quiet", is_flag=True) +def main(write_defaults, quiet, **kwargs): root_path = Path(__file__).parents[1] overrides = {k: v for k, v in kwargs.items() if v is not None} # process versions.tf and versions.tofu @@ -98,19 +99,22 @@ def main(write_defaults, **kwargs): context['engine_version'] = kwargs[f'{engine}_version'] for file_path in root_path.rglob(f"versions.{engine}"): - click.echo(f"Processing {file_path}") + if not quiet: + click.echo(f"Processing {file_path}") process_file(FABRIC_VERSIONS_TEMPLATE, file_path, context | { "path": file_path.parent.relative_to(root_path), }) if write_defaults: - click.echo(f"Processing {defaults_fname}") + if not quiet: + click.echo(f"Processing {defaults_fname}") process_file(FABRIC_VERSIONS_TEMPLATE, defaults_fname, context) # process fast_version.txt. fast_context = {"fast_release": context["fabric_release"]} for file_path in root_path.rglob(f"fast_version.txt"): - click.echo(f"Processing {file_path}") + if not quiet: + click.echo(f"Processing {file_path}") process_file(FAST_VERSIONS_TEMPLATE, file_path, fast_context)