Improve linting and fix agent-engine module name
This commit is contained in:
49
.github/workflows/linting.yml
vendored
49
.github/workflows/linting.yml
vendored
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
4
modules/agent-engine/versions.tf
generated
4
modules/agent-engine/versions.tf
generated
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
4
modules/agent-engine/versions.tofu
generated
4
modules/agent-engine/versions.tofu
generated
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user