Improve linting and fix agent-engine module name

This commit is contained in:
Wiktor Niesiobędzki
2025-10-26 09:51:37 +00:00
parent dc64184739
commit 269e47a565
5 changed files with 39 additions and 48 deletions

View File

@@ -23,7 +23,6 @@ on:
branches: branches:
- master - master
- fast-dev - fast-dev
jobs: jobs:
linting: linting:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@@ -93,38 +92,30 @@ jobs:
- name: Check python formatting - name: Check python formatting
id: yapf id: yapf
run: | uses: pre-commit/action@1b06ec171f2f6faa71ed760c4042bd969e4f8b43
yapf -p -d -r \ with:
tools/*.py \ extra_args: yapf --all-files
fast
- name: Check modules versions - name: Check modules versions
id: versions id: versions
run: | uses: pre-commit/action@1b06ec171f2f6faa71ed760c4042bd969e4f8b43
OUTPUT_TF=$( with:
find . -type f -name 'versions.tf' -exec diff -I '[[:space:]]*module_name' -ub default-versions.tf {} \; extra_args: versions --all-files
)
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}" ]]
- name: Check for diverging files - name: Check for diverging files
id: duplicates id: duplicates
run: | uses: pre-commit/action@1b06ec171f2f6faa71ed760c4042bd969e4f8b43
python3 tools/duplicate-diff.py with:
extra_args: duplicate-diff --all-files
- name: yaml-lint - name: Check YAML files
uses: ibiqlik/action-yamllint@b74a2626a991d676b6ec243a6458ff86cccf2d2d 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

View File

@@ -81,17 +81,13 @@ repos:
require_serial: true require_serial: true
files: ^fast/.*tf files: ^fast/.*tf
- id: versions - id: versions
name: Align Terraform provider versions name: Align Terraform/OpenTofu provider versions
language: script language: python
files: (versions.tf|^default-versions.tf)$ additional_dependencies:
- click
files: (versions.tf|^default-versions.tf|versions.tofu|default-versions.tofu)$
pass_filenames: false pass_filenames: false
entry: /usr/bin/find . -type f -name 'versions.tf' -exec cp default-versions.tf {} \; entry: tools/versions.py --quiet
- 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 {} \;
- id: check-names - id: check-names
name: Check name lengths for FAST name: Check name lengths for FAST
language: python language: python
@@ -149,7 +145,7 @@ repos:
exclude: ".*tpl" exclude: ".*tpl"
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0 rev: v6.0.0
hooks: hooks:
- id: end-of-file-fixer - id: end-of-file-fixer
- id: trailing-whitespace - id: trailing-whitespace

View File

@@ -27,9 +27,9 @@ terraform {
} }
} }
provider_meta "google" { 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" { 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"
} }
} }

View File

@@ -27,9 +27,9 @@ terraform {
} }
} }
provider_meta "google" { 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" { 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"
} }
} }

View File

@@ -85,7 +85,8 @@ def process_file(template, file_path, context):
@click.option("--tofu-version", help="Override OpenTofu version") @click.option("--tofu-version", help="Override OpenTofu version")
@click.option("--write-defaults/--no-write-defaults", default=False, @click.option("--write-defaults/--no-write-defaults", default=False,
help="Also rewrite default-versions.t*f*") 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] root_path = Path(__file__).parents[1]
overrides = {k: v for k, v in kwargs.items() if v is not None} overrides = {k: v for k, v in kwargs.items() if v is not None}
# process versions.tf and versions.tofu # process versions.tf and versions.tofu
@@ -98,19 +99,22 @@ def main(write_defaults, **kwargs):
context['engine_version'] = kwargs[f'{engine}_version'] context['engine_version'] = kwargs[f'{engine}_version']
for file_path in root_path.rglob(f"versions.{engine}"): 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 | { process_file(FABRIC_VERSIONS_TEMPLATE, file_path, context | {
"path": file_path.parent.relative_to(root_path), "path": file_path.parent.relative_to(root_path),
}) })
if write_defaults: 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_file(FABRIC_VERSIONS_TEMPLATE, defaults_fname, context)
# process fast_version.txt. # process fast_version.txt.
fast_context = {"fast_release": context["fabric_release"]} fast_context = {"fast_release": context["fabric_release"]}
for file_path in root_path.rglob(f"fast_version.txt"): 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) process_file(FAST_VERSIONS_TEMPLATE, file_path, fast_context)