diff --git a/cli/__main__.py b/cli/__main__.py index eb41cfda36..9855de8665 100755 --- a/cli/__main__.py +++ b/cli/__main__.py @@ -4,10 +4,10 @@ from __future__ import annotations import sys from pathlib import Path -# This file is invoked directly as ``python3 cli/__main__.py ...`` (the -# ``cli`` console-script entry-point and the integration help-test), in -# which case ``from . import PROJECT_ROOT`` fails with ``attempted -# relative import with no known parent package``. Compute the repo root +# This file is invoked directly as a script (the ``cli`` console-script +# entry-point and the integration help-test), in which case +# ``from . import PROJECT_ROOT`` fails with ``attempted relative import +# with no known parent package``. Compute the repo root # locally and prepend it to sys.path before any project-package import # resolves. Without this, sys.path[0] points to ``/cli`` and # importing ``cli.*`` may accidentally resolve to an installed package diff --git a/cli/deploy/development/deps.py b/cli/deploy/development/deps.py index a63fb78ee2..b7875ff3f3 100644 --- a/cli/deploy/development/deps.py +++ b/cli/deploy/development/deps.py @@ -1,4 +1,3 @@ -# cli/deploy/development/deps.py from __future__ import annotations from typing import TYPE_CHECKING diff --git a/cli/deploy/development/init.py b/cli/deploy/development/init.py index dcf29902b6..17e5b1fcfe 100644 --- a/cli/deploy/development/init.py +++ b/cli/deploy/development/init.py @@ -1,4 +1,3 @@ -# cli/deploy/development/init.py from __future__ import annotations import argparse diff --git a/cli/deploy/development/mirrors.py b/cli/deploy/development/mirrors.py index 8d4177f373..ac2bcb720e 100644 --- a/cli/deploy/development/mirrors.py +++ b/cli/deploy/development/mirrors.py @@ -1,4 +1,3 @@ -# cli/deploy/development/mirrors.py from __future__ import annotations import os diff --git a/cli/meta/applications/resolution/combined/resolver.py b/cli/meta/applications/resolution/combined/resolver.py index 8e16c3c681..85034d2f23 100644 --- a/cli/meta/applications/resolution/combined/resolver.py +++ b/cli/meta/applications/resolution/combined/resolver.py @@ -1,4 +1,3 @@ -# cli/meta/applications/resolution/combined/resolver.py from __future__ import annotations from dataclasses import dataclass diff --git a/cli/meta/applications/resolution/combined/role_introspection.py b/cli/meta/applications/resolution/combined/role_introspection.py index a937ac5639..995ffe3839 100644 --- a/cli/meta/applications/resolution/combined/role_introspection.py +++ b/cli/meta/applications/resolution/combined/role_introspection.py @@ -1,4 +1,3 @@ -# cli/meta/applications/resolution/combined/role_introspection.py from __future__ import annotations from cli.meta.applications.resolution.services.errors import ServicesResolutionError diff --git a/cli/meta/applications/ressources/__main__.py b/cli/meta/applications/ressources/__main__.py index 9cae804664..1462e2e0e0 100755 --- a/cli/meta/applications/ressources/__main__.py +++ b/cli/meta/applications/ressources/__main__.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# cli/meta/applications/ressources/__main__.py from __future__ import annotations import argparse diff --git a/cli/meta/applications/sufficient_storage/__main__.py b/cli/meta/applications/sufficient_storage/__main__.py index cca3b8d60e..01a41726a4 100755 --- a/cli/meta/applications/sufficient_storage/__main__.py +++ b/cli/meta/applications/sufficient_storage/__main__.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# cli/meta/applications/sufficient_storage/__main__.py from __future__ import annotations import argparse diff --git a/cli/meta/callorder/__main__.py b/cli/meta/callorder/__main__.py index 48c18ae9e5..c5b0cfa828 100755 --- a/cli/meta/callorder/__main__.py +++ b/cli/meta/callorder/__main__.py @@ -1,7 +1,5 @@ #!/usr/bin/env python3 """ -cli/meta/callorder/__main__.py - What it does: - 📄 Prints the call order of roles per tasks/groups/*.yml - 🎯 With --marker (and no --call): shows all groups/roles split into ✅ called (<= marker) vs ⏳ remaining (> marker) diff --git a/cli/meta/categories/invokable/command.py b/cli/meta/categories/invokable/command.py index 9a0180cd92..ea888841f2 100755 --- a/cli/meta/categories/invokable/command.py +++ b/cli/meta/categories/invokable/command.py @@ -2,10 +2,9 @@ """ CLI for extracting invokable or non-invokable role paths from a nested roles YAML file. -Layout assumption: - /cli/meta/categories/invokable/command.py - /plugins/filter/... - /roles/categories.yml +Layout assumption: this module sits under ``cli/`` and reads +``/roles/categories.yml`` plus filter plugins under +``/plugins/filter/``. """ from __future__ import annotations diff --git a/cli/mirror/providers.py b/cli/mirror/providers.py index 0cfc7a0b0a..aa6d4a99ee 100644 --- a/cli/mirror/providers.py +++ b/cli/mirror/providers.py @@ -1,4 +1,3 @@ -# cli/mirror/providers.py from __future__ import annotations import argparse diff --git a/docs/contributing/actions/testing/suppression.md b/docs/contributing/actions/testing/suppression.md index 49d08a372a..e630ba3204 100644 --- a/docs/contributing/actions/testing/suppression.md +++ b/docs/contributing/actions/testing/suppression.md @@ -70,6 +70,7 @@ The placement rule is per check. The catalog column "Position" uses these labels | `project-root-import`| same or above | [tests/lint/repository/test_project_root_import.py](../../../../tests/lint/repository/test_project_root_import.py) | Permits a local `PROJECT_ROOT` / `parents[N]` / `os.pardir` chain on the marked line. Reserved for two cases: a `__main__.py` bootstrap shim that prepends the repo root to `sys.path` before any package import resolves, and a standalone script under `roles//files/` that has no package container to import from. The marker MUST carry an inline comment that explains why the local computation is unavoidable. | | `domain-spot` | same or above | [tests/lint/repository/test_domain_primary_spot.py](../../../../tests/lint/repository/test_domain_primary_spot.py) | Marks a line that legitimately uses a `.{{ DOMAIN_PRIMARY }}` host literal outside the SPOT (`roles//meta/server.yml` / `meta/variants.yml`). Use only for legacy domain cleanups (e.g. removing stale nginx config for a renamed host) where the canonical SPOT cannot represent the historical name. | | `literal-protocol-lookup`| same or above | [tests/lint/repository/test_literal_protocol_with_lookup.py](../../../../tests/lint/repository/test_literal_protocol_with_lookup.py) | Allows a hardcoded `http://` / `https://` literal next to a `lookup(...)` call. Reserved for legitimate internal cases where the protocol is genuinely fixed: Docker-network upstreams that always speak plaintext (`http://:`), loopback URLs in CI fixtures, and similar. Production-facing URLs MUST go through `lookup('tls', …, 'protocols.web')`. | +| `self-path-reference`| same line | [tests/lint/repository/test_no_self_path_reference.py](../../../../tests/lint/repository/test_no_self_path_reference.py) | Allows a file to contain its own relative path from the repo root as a string literal on the marked line. Reserved for cases where the self-reference is load-bearing (e.g. a static site generator that injects its own source path into the rendered output). Files at the repo root (no `/` in their relative path) are exempt without a marker. | ## Examples 💡 diff --git a/plugins/filter/on_off.py b/plugins/filter/on_off.py index fb7a4fb5fc..f0831cc2d3 100644 --- a/plugins/filter/on_off.py +++ b/plugins/filter/on_off.py @@ -1,4 +1,3 @@ -# plugins/filter/on_off.py # # `on_off` filter — render a boolean as the literal string "on" or # "off". Replaces the verbose Jinja idiom diff --git a/plugins/lookup/version.py b/plugins/lookup/version.py index d9ebd95aac..9ff9dc3baa 100644 --- a/plugins/lookup/version.py +++ b/plugins/lookup/version.py @@ -2,8 +2,8 @@ Ansible lookup plugin: version No parameters. -Reads pyproject.toml relative to this plugin file: -/plugins/lookup/version.py -> /pyproject.toml +Reads ``pyproject.toml`` from the repository root, located by walking +parents from this plugin file's location. Resolution order: 1) [project].version (PEP 621) diff --git a/roles/svc-db-openldap/tasks/04_users.yml b/roles/svc-db-openldap/tasks/04_users.yml index 9f749ed659..8fd4c2771b 100644 --- a/roles/svc-db-openldap/tasks/04_users.yml +++ b/roles/svc-db-openldap/tasks/04_users.yml @@ -1,5 +1,4 @@ ############################################################################### -# roles/svc-db-openldap/tasks/04_users.yml # # Purpose: # - Ensure base LDAP tree exists (suffix + OUs) diff --git a/roles/sys-dns-wildcards/filter_plugins/wildcard_dns.py b/roles/sys-dns-wildcards/filter_plugins/wildcard_dns.py index 3b7f0b1366..02061ab3d1 100644 --- a/roles/sys-dns-wildcards/filter_plugins/wildcard_dns.py +++ b/roles/sys-dns-wildcards/filter_plugins/wildcard_dns.py @@ -1,4 +1,3 @@ -# roles/sys-dns-wildcards/filter_plugins/wildcard_dns.py import ipaddress from ansible.errors import AnsibleFilterError diff --git a/roles/sys-service-terminator/files/docker_diagnostics.sh b/roles/sys-service-terminator/files/docker_diagnostics.sh index eba36c24e5..be7b9ad53d 100755 --- a/roles/sys-service-terminator/files/docker_diagnostics.sh +++ b/roles/sys-service-terminator/files/docker_diagnostics.sh @@ -1,5 +1,4 @@ #!/usr/bin/env bash -# roles/sys-service-terminator/files/docker_diagnostics.sh # # Best-effort Docker diagnostics for sys-service-terminator. # Never fails hard (always exits 0). diff --git a/roles/sys-svc-compose/lookup_plugins/compose_ca_inject_cmd.py b/roles/sys-svc-compose/lookup_plugins/compose_ca_inject_cmd.py index 8bddb0f8ec..a0fd7f5df7 100644 --- a/roles/sys-svc-compose/lookup_plugins/compose_ca_inject_cmd.py +++ b/roles/sys-svc-compose/lookup_plugins/compose_ca_inject_cmd.py @@ -1,4 +1,3 @@ -# roles/sys-svc-compose/lookup_plugins/compose_ca_inject_cmd.py from __future__ import annotations from pathlib import Path diff --git a/roles/sys-svc-container/templates/healthcheck/http.yml.j2 b/roles/sys-svc-container/templates/healthcheck/http.yml.j2 index 8ff8acd5f0..19648efb24 100644 --- a/roles/sys-svc-container/templates/healthcheck/http.yml.j2 +++ b/roles/sys-svc-container/templates/healthcheck/http.yml.j2 @@ -17,10 +17,10 @@ - retries: 5 → Mark unhealthy after 5 consecutive failures - start_period: 20s → Grace period before health checks begin - Usage: - {% filter indent(4) %} - {% include 'roles/sys-svc-container/templates/healthcheck/http.yml.j2' %} - {% endfilter %} + Usage: consumers include this template via the standard Jinja2 + ``include`` tag, indenting the block by four spaces with the + ``indent(4)`` filter so the rendered ``healthcheck:`` map slots into + a Compose service definition. ------------------------------------------------------------------------------ #} healthcheck: diff --git a/roles/web-app-dashboard/templates/javascript/oidc.js.j2 b/roles/web-app-dashboard/templates/javascript/oidc.js.j2 index 5885c30a46..6a270a3025 100644 --- a/roles/web-app-dashboard/templates/javascript/oidc.js.j2 +++ b/roles/web-app-dashboard/templates/javascript/oidc.js.j2 @@ -1,5 +1,4 @@ /* ========================================================================================== - roles/web-app-dashboard/templates/javascript/oidc.js.j2 Purpose: Hide "Login" and show "Account" when a Keycloak SSO session exists, wire login/logout clicks to the Keycloak adapter, and keep state fresh. NOTE: Ensure CSP allows {{ OIDC.URL }} for script-src-elem, connect-src, and frame-src. diff --git a/roles/web-app-keycloak/filter_plugins/kcadm.py b/roles/web-app-keycloak/filter_plugins/kcadm.py index e39250dce6..6487f4fb2e 100644 --- a/roles/web-app-keycloak/filter_plugins/kcadm.py +++ b/roles/web-app-keycloak/filter_plugins/kcadm.py @@ -1,4 +1,3 @@ -# roles/web-app-keycloak/filter_plugins/kcadm.py from __future__ import annotations import importlib.util diff --git a/roles/web-app-keycloak/library/keycloak_kcadm_update.py b/roles/web-app-keycloak/library/keycloak_kcadm_update.py index 591f1c0473..590ed34d6b 100755 --- a/roles/web-app-keycloak/library/keycloak_kcadm_update.py +++ b/roles/web-app-keycloak/library/keycloak_kcadm_update.py @@ -1,5 +1,4 @@ #!/usr/bin/python -# roles/web-app-keycloak/library/keycloak_kcadm_update.py import json diff --git a/roles/web-app-keycloak/module_utils/kcadm_json.py b/roles/web-app-keycloak/module_utils/kcadm_json.py index c6a06d5c9a..6ca1ce693f 100644 --- a/roles/web-app-keycloak/module_utils/kcadm_json.py +++ b/roles/web-app-keycloak/module_utils/kcadm_json.py @@ -1,4 +1,3 @@ -# roles/web-app-keycloak/module_utils/kcadm_json.py from __future__ import annotations import json diff --git a/roles/web-app-keycloak/tasks/assert/05_ldap.yml b/roles/web-app-keycloak/tasks/assert/05_ldap.yml index a7492326bd..6b602746a1 100644 --- a/roles/web-app-keycloak/tasks/assert/05_ldap.yml +++ b/roles/web-app-keycloak/tasks/assert/05_ldap.yml @@ -1,4 +1,3 @@ -# roles/web-app-keycloak/tasks/assert/05_ldap.yml # # Read-only assertions for LDAP configuration in Keycloak. # Ensures: diff --git a/roles/web-app-keycloak/tasks/update/05_ldap.yml b/roles/web-app-keycloak/tasks/update/05_ldap.yml index 2f637e5707..6cad756ab1 100644 --- a/roles/web-app-keycloak/tasks/update/05_ldap.yml +++ b/roles/web-app-keycloak/tasks/update/05_ldap.yml @@ -1,4 +1,3 @@ -# roles/web-app-keycloak/tasks/update/05_ldap.yml - name: "Update REALM settings (merge LDAP component .config)" keycloak_kcadm_update: diff --git a/roles/web-app-keycloak/tasks/update/ldap/groups_path.yml b/roles/web-app-keycloak/tasks/update/ldap/groups_path.yml index 98cd294eb7..51258398ad 100644 --- a/roles/web-app-keycloak/tasks/update/ldap/groups_path.yml +++ b/roles/web-app-keycloak/tasks/update/ldap/groups_path.yml @@ -1,4 +1,3 @@ -# roles/web-app-keycloak/tasks/update/ldap/groups_path.yml # # This file is included ONLY when desired_groups_top is non-empty. # Do not add an additional "when: desired_groups_top | length > 0" here. diff --git a/roles/web-app-littlejs/vars/examples.yml b/roles/web-app-littlejs/vars/examples.yml index c2e9b283a5..b556ffbe4d 100644 --- a/roles/web-app-littlejs/vars/examples.yml +++ b/roles/web-app-littlejs/vars/examples.yml @@ -1,4 +1,3 @@ -# roles/web-app-littlejs/vars/examples.yml # LittleJS examples for launcher UI (used to generate example tiles and menu) littlejs_examples: diff --git a/roles/web-app-peertube/files/diagnostics.sh b/roles/web-app-peertube/files/diagnostics.sh index 04a4701c77..2d29c140bb 100755 --- a/roles/web-app-peertube/files/diagnostics.sh +++ b/roles/web-app-peertube/files/diagnostics.sh @@ -1,5 +1,4 @@ #!/usr/bin/env bash -# roles/web-app-peertube/files/diagnostics.sh # # Best-effort diagnostics for the PeerTube container after a plugin-install # failure. Prints container state, health, resource limits, logs, stats, diff --git a/roles/web-app-peertube/filter_plugins/install_mem_limit.py b/roles/web-app-peertube/filter_plugins/install_mem_limit.py index c897d49ca5..db3eef8953 100644 --- a/roles/web-app-peertube/filter_plugins/install_mem_limit.py +++ b/roles/web-app-peertube/filter_plugins/install_mem_limit.py @@ -1,4 +1,3 @@ -# roles/web-app-peertube/filter_plugins/install_mem_limit.py # Derive a temporary cgroup memory ceiling for the one-off # `npm run plugin:install` exec. # diff --git a/roles/web-app-prometheus/meta/services.yml b/roles/web-app-prometheus/meta/services.yml index 5b5e50fef2..0945fbcac3 100644 --- a/roles/web-app-prometheus/meta/services.yml +++ b/roles/web-app-prometheus/meta/services.yml @@ -28,7 +28,8 @@ css: prometheus: enabled: true shared: true - provides: prometheus + provides: + - prometheus image: prom/prometheus version: v3.11.3 name: prometheus diff --git a/roles/web-app-prometheus/templates/configuration/alert_rules.yml.j2 b/roles/web-app-prometheus/templates/configuration/alert_rules.yml.j2 index dd0c2041ac..82aa63e5d2 100644 --- a/roles/web-app-prometheus/templates/configuration/alert_rules.yml.j2 +++ b/roles/web-app-prometheus/templates/configuration/alert_rules.yml.j2 @@ -1,6 +1,5 @@ # Prometheus alert rules — auto-generated by Ansible -# DO NOT edit manually; update roles/web-app-prometheus/templates/configuration/alert_rules.yml.j2 - +# DO NOT edit manually; this Jinja2 template IS the source. groups: - name: app_availability interval: 30s diff --git a/roles/web-app-prometheus/templates/configuration/alertmanager.yml.j2 b/roles/web-app-prometheus/templates/configuration/alertmanager.yml.j2 index 384ec7cdd2..55717ee04f 100644 --- a/roles/web-app-prometheus/templates/configuration/alertmanager.yml.j2 +++ b/roles/web-app-prometheus/templates/configuration/alertmanager.yml.j2 @@ -1,5 +1,5 @@ # Alertmanager configuration — auto-generated by Ansible -# DO NOT edit manually; update roles/web-app-prometheus/templates/configuration/alertmanager.yml.j2 +# DO NOT edit manually; this Jinja2 template IS the source. {% set email = lookup('email', application_id) %} global: diff --git a/roles/web-app-prometheus/templates/configuration/blackbox.yml.j2 b/roles/web-app-prometheus/templates/configuration/blackbox.yml.j2 index 7584f101fa..b9ac0ebe53 100644 --- a/roles/web-app-prometheus/templates/configuration/blackbox.yml.j2 +++ b/roles/web-app-prometheus/templates/configuration/blackbox.yml.j2 @@ -1,6 +1,5 @@ # Blackbox exporter configuration — auto-generated by Ansible -# DO NOT edit manually; update roles/web-app-prometheus/templates/configuration/blackbox.yml.j2 - +# DO NOT edit manually; this Jinja2 template IS the source. modules: # Used for strict uptime checks — expects exactly 200. http_2xx: diff --git a/roles/web-app-prometheus/templates/configuration/prometheus.yml.j2 b/roles/web-app-prometheus/templates/configuration/prometheus.yml.j2 index ddae60cf49..8be913eaa5 100644 --- a/roles/web-app-prometheus/templates/configuration/prometheus.yml.j2 +++ b/roles/web-app-prometheus/templates/configuration/prometheus.yml.j2 @@ -1,6 +1,5 @@ # Prometheus scrape configuration — auto-generated by Ansible -# DO NOT edit manually; update roles/web-app-prometheus/templates/configuration/prometheus.yml.j2 - +# DO NOT edit manually; this Jinja2 template IS the source. global: scrape_interval: 30s evaluation_interval: 30s diff --git a/roles/web-app-wordpress/vars/discourse.yml b/roles/web-app-wordpress/vars/discourse.yml index b4e26a40e3..1964ecb309 100644 --- a/roles/web-app-wordpress/vars/discourse.yml +++ b/roles/web-app-wordpress/vars/discourse.yml @@ -1,7 +1,6 @@ # Defines WP Discourse plugin settings # @see https://github.com/discourse/wp-discourse -# roles/web-app-wordpress/vars/discourse.yml # Defines WP Discourse plugin settings (exported from your current wp_options dump) # # Requirement 007 decision: wp-discourse `auto-publish` stays DISABLED by diff --git a/scripts/container/purge/apps.sh b/scripts/container/purge/apps.sh index cb713c6aab..42206779b1 100755 --- a/scripts/container/purge/apps.sh +++ b/scripts/container/purge/apps.sh @@ -12,7 +12,7 @@ # # Designed to be invoked from the host via: # docker exec -e APPS="${APPS}" \ -# bash /opt/src/infinito/scripts/container/purge/apps.sh +# bash /opt/src/infinito/scripts/container/purge/apps.sh # nocheck: self-path-reference set -euo pipefail cd /opt/src/infinito diff --git a/scripts/github/output_apps.sh b/scripts/github/output_apps.sh index 471100421a..e89f3d12ce 100755 --- a/scripts/github/output_apps.sh +++ b/scripts/github/output_apps.sh @@ -1,5 +1,4 @@ #!/usr/bin/env bash -# scripts/github/output_apps.sh # # Resolve the app list and write it to GITHUB_OUTPUT. # Inputs via env (forwarded to scripts/meta/resolve/apps.sh): diff --git a/scripts/github/resolve_effective_whitelist.sh b/scripts/github/resolve_effective_whitelist.sh index 1b54bdd49b..52afc05c6f 100755 --- a/scripts/github/resolve_effective_whitelist.sh +++ b/scripts/github/resolve_effective_whitelist.sh @@ -1,5 +1,4 @@ #!/usr/bin/env bash -# scripts/github/resolve_effective_whitelist.sh # # Resolve the effective WHITELIST that the discover step should pass to # scripts/github/output_apps.sh, and write it to GITHUB_OUTPUT. diff --git a/scripts/image/cleanup.sh b/scripts/image/cleanup.sh index af197bba58..189004e602 100755 --- a/scripts/image/cleanup.sh +++ b/scripts/image/cleanup.sh @@ -24,8 +24,8 @@ Env: DAYS, OWNER, REPOSITORY, DISTROS, REPO_PREFIX can be used as defaults. Examples: - DAYS=14 OWNER=myorg REPOSITORY=myorg/my-repo REPO_PREFIX=my-repo ./scripts/image/cleanup.sh - ./scripts/image/cleanup.sh --days 7 --repository kevinveenbirkenbach/infinito-nexus --distros "arch debian" --repo-prefix infinito-nexus + DAYS=14 OWNER=myorg REPOSITORY=myorg/my-repo REPO_PREFIX=my-repo ./scripts/image/cleanup.sh # nocheck: self-path-reference + ./scripts/image/cleanup.sh --days 7 --repository kevinveenbirkenbach/infinito-nexus --distros "arch debian" --repo-prefix infinito-nexus # nocheck: self-path-reference USAGE } diff --git a/scripts/meta/resolve/apps.sh b/scripts/meta/resolve/apps.sh index 85cac315dd..c983d15a11 100755 --- a/scripts/meta/resolve/apps.sh +++ b/scripts/meta/resolve/apps.sh @@ -1,5 +1,4 @@ #!/usr/bin/env bash -# scripts/meta/resolve/apps.sh set -euo pipefail # Purpose (SRP): Return JSON list of apps based on deployment type, diff --git a/scripts/meta/resolve/diff/affected_roles.sh b/scripts/meta/resolve/diff/affected_roles.sh index 274749d3f2..e923e6f217 100755 --- a/scripts/meta/resolve/diff/affected_roles.sh +++ b/scripts/meta/resolve/diff/affected_roles.sh @@ -1,5 +1,4 @@ #!/usr/bin/env bash -# scripts/meta/resolve/diff/affected_roles.sh # # Compute which roles are affected by the current branch's diff against # `origin/main`, expanded transitively over run_after + dependencies + diff --git a/scripts/tests/deploy/ci/dedicated.sh b/scripts/tests/deploy/ci/dedicated.sh index caa506b7cc..c96ecf26bc 100755 --- a/scripts/tests/deploy/ci/dedicated.sh +++ b/scripts/tests/deploy/ci/dedicated.sh @@ -38,7 +38,7 @@ usage() { cat <<'EOF' Usage: INFINITO_DISTRO= INVENTORY_DIR= INFINITO_DOCKER_VOLUME= \ - scripts/tests/deploy/ci/dedicated.sh \ + scripts/tests/deploy/ci/dedicated.sh \ # nocheck: self-path-reference --apps EOF } diff --git a/scripts/tests/deploy/local/deploy/fresh-kept-app.sh b/scripts/tests/deploy/local/deploy/fresh-kept-app.sh index 772d18bccc..e4b57c5df1 100755 --- a/scripts/tests/deploy/local/deploy/fresh-kept-app.sh +++ b/scripts/tests/deploy/local/deploy/fresh-kept-app.sh @@ -3,7 +3,7 @@ set -euo pipefail # Local app test without teardown/cleanup. # Usage: -# scripts/tests/deploy/local/deploy/fresh-kept-app.sh +# scripts/tests/deploy/local/deploy/fresh-kept-app.sh # nocheck: self-path-reference # # Environment variables: # INFINITO_DISTRO arch|debian|ubuntu|fedora|centos (default from scripts/meta/env/all.sh) @@ -12,8 +12,8 @@ set -euo pipefail # DEBUG true|false (default: true) # # Examples: -# scripts/tests/deploy/local/deploy/fresh-kept-app.sh web-app-mailu -# INFINITO_DISTRO=arch DEBUG=false scripts/tests/deploy/local/deploy/fresh-kept-app.sh web-app-nextcloud +# scripts/tests/deploy/local/deploy/fresh-kept-app.sh web-app-mailu # nocheck: self-path-reference +# INFINITO_DISTRO=arch DEBUG=false scripts/tests/deploy/local/deploy/fresh-kept-app.sh web-app-nextcloud # nocheck: self-path-reference SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" REPO_ROOT="$(cd "${SCRIPT_DIR}/../../../../.." && pwd)" diff --git a/scripts/tests/deploy/local/exec/container.sh b/scripts/tests/deploy/local/exec/container.sh index 2692142151..93de346e59 100755 --- a/scripts/tests/deploy/local/exec/container.sh +++ b/scripts/tests/deploy/local/exec/container.sh @@ -5,8 +5,7 @@ set -euo pipefail # one-off command inside it when CMD or positional arguments are set. # # Usage: -# scripts/tests/deploy/local/exec/container.sh -# scripts/tests/deploy/local/exec/container.sh [command...] +# scripts/tests/deploy/local/exec/container.sh [command...] # nocheck: self-path-reference # # Environment: # INFINITO_DISTRO arch|debian|ubuntu|fedora|centos @@ -14,18 +13,17 @@ set -euo pipefail # CMD One-off shell command to run instead of an interactive shell # # Examples: -# scripts/tests/deploy/local/exec/container.sh -# scripts/tests/deploy/local/exec/container.sh whoami -# CMD='whoami && id' scripts/tests/deploy/local/exec/container.sh +# scripts/tests/deploy/local/exec/container.sh whoami # nocheck: self-path-reference +# CMD='whoami && id' scripts/tests/deploy/local/exec/container.sh # nocheck: self-path-reference SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" REPO_ROOT="$(cd "${SCRIPT_DIR}/../../../../../" && pwd)" usage() { - cat <<'EOF' + cat < [playwright args...] -# scripts/tests/e2e/rerun-spec.sh web-app-nextcloud --grep "talk admin" +# scripts/tests/e2e/rerun-spec.sh [playwright args...] # nocheck: self-path-reference +# scripts/tests/e2e/rerun-spec.sh web-app-nextcloud --grep "talk admin" # nocheck: self-path-reference set -euo pipefail if [[ $# -lt 1 ]]; then diff --git a/tests/integration/oauth2_oidc/rbac/test_group_path_role_declarations.py b/tests/integration/oauth2_oidc/rbac/test_group_path_role_declarations.py index 4539507c80..8f89a2480a 100644 --- a/tests/integration/oauth2_oidc/rbac/test_group_path_role_declarations.py +++ b/tests/integration/oauth2_oidc/rbac/test_group_path_role_declarations.py @@ -86,7 +86,7 @@ EXCLUDED_RELATIVE_PATHS = frozenset( # The lookup plugin's own docstring shows usage examples. "plugins/lookup/rbac_group_path.py", # This guard contains the literal call form in its docstring. - "tests/integration/oauth2_oidc/rbac/test_group_path_role_declarations.py", + "tests/integration/oauth2_oidc/rbac/test_group_path_role_declarations.py", # nocheck: self-path-reference } ) diff --git a/tests/integration/oauth2_oidc/rbac/test_path_join_guard.py b/tests/integration/oauth2_oidc/rbac/test_path_join_guard.py index cfb2f1bb04..d831cc81ef 100644 --- a/tests/integration/oauth2_oidc/rbac/test_path_join_guard.py +++ b/tests/integration/oauth2_oidc/rbac/test_path_join_guard.py @@ -33,7 +33,7 @@ ALLOWED_RELATIVE_PREFIXES = ( # KEYCLOAK_RBAC_GROUP_NAME is a pure alias, not a path construction. "roles/web-app-keycloak/vars/main.yml", # This guard's own file mentions the forbidden pattern literally. - "tests/integration/oauth2_oidc/rbac/test_path_join_guard.py", + "tests/integration/oauth2_oidc/rbac/test_path_join_guard.py", # nocheck: self-path-reference ) EXCLUDED_DIRS = { diff --git a/tests/lint/ansible/test_no_inline_multiline_sql.py b/tests/lint/ansible/test_no_inline_multiline_sql.py index 8b3dd62680..89573ce5cb 100644 --- a/tests/lint/ansible/test_no_inline_multiline_sql.py +++ b/tests/lint/ansible/test_no_inline_multiline_sql.py @@ -79,7 +79,7 @@ _SQL_KEYWORD_LEADERS = ( # Files we must not scan to avoid recursive false positives. _EXCLUDED_RELATIVE_PATHS = frozenset( { - "tests/lint/ansible/test_no_inline_multiline_sql.py", + "tests/lint/ansible/test_no_inline_multiline_sql.py", # nocheck: self-path-reference } ) diff --git a/tests/lint/repository/test_no_self_path_reference.py b/tests/lint/repository/test_no_self_path_reference.py new file mode 100644 index 0000000000..93fd10df6f --- /dev/null +++ b/tests/lint/repository/test_no_self_path_reference.py @@ -0,0 +1,122 @@ +"""Lint guard: a project file MUST NOT contain its own relative path +from the repo root as a string literal anywhere in its content. + +Background +========== +Hard-coded self-path references rot the moment the file is renamed or +moved: a header comment like ``# utils/foo/bar.py`` at the top of a +module, a docstring referring to ``utils/foo/bar.py``, or a docs entry +linking ``utils/foo/bar.py`` from inside ``utils/foo/bar.py`` itself +all silently desync from reality after the next ``git mv``. Cross-file +references survive moves (the link target updates with the renamed file +on the other side), but self-references survive nothing. + +Detection +========= +For every file the project tracks (via :func:`utils.cache.files.iter_project_files`), +the lint computes the file's POSIX-style relative path from +``PROJECT_ROOT`` and reports any line whose text contains that path as +a substring. + +Scope and exemptions +==================== +* Files at the repo root (relative path without any ``/`` separator) + are exempt: a bare filename like ``Makefile`` or ``pyproject.toml`` + appears in too many cross-references to flag meaningfully, and it + has no directory part to drift away from. +* The lint test itself is exempt — its docstring legitimately spells + out the rule and the example shapes that fire. +* Symlinks point elsewhere by definition; their text is the link target, + not file-local content. +* Per-line opt-out via ``# nocheck: self-path-reference`` (case- + insensitive) on the offending line. Reserve the marker for files + whose self-reference is load-bearing (e.g. a static site generator + injects its own source path into the rendered output) and document + the reason next to the marker. + +Caching +======= +File reads route through :func:`utils.cache.files.read_text`, so the +sweep adds no fresh disk I/O when other lints have already touched the +same files in this ``make test`` run. +""" + +from __future__ import annotations + +import unittest +from pathlib import Path + +from utils.annotations.suppress import line_has_rule +from utils.cache.files import PROJECT_ROOT, iter_project_files, read_text + +SUPPRESS_RULE = "self-path-reference" + +# Paths the lint deliberately does not flag. Relative to ``PROJECT_ROOT``, +# POSIX-style. The lint's own source file mentions the rule shape in its +# docstring; flagging it would force a useless ``nocheck`` on every +# example. +_EXEMPT_PATHS: frozenset[str] = frozenset( + { + "tests/lint/repository/test_no_self_path_reference.py", + } +) + + +def _scan_file(abs_path: Path, rel_str: str) -> list[str]: + """Return ``rel_str:lineno: ...`` failure lines for *abs_path*. + + Empty list means the file is clean. Reads route through the + project-wide cached text reader. + """ + try: + text = read_text(str(abs_path)) + except (OSError, UnicodeDecodeError): + return [] + + failures: list[str] = [] + for lineno, line in enumerate(text.splitlines(), start=1): + if rel_str not in line: + continue + if line_has_rule(line, SUPPRESS_RULE): + continue + failures.append(f"{rel_str}:{lineno}: contains its own path as a string") + return failures + + +class TestNoSelfPathReference(unittest.TestCase): + def test_no_self_path_reference(self) -> None: + project_root = Path(str(PROJECT_ROOT)) + offenders: list[str] = [] + + for path_str in iter_project_files(): + abs_path = Path(path_str) + if abs_path.is_symlink(): + continue + try: + rel = abs_path.relative_to(project_root) + except ValueError: + continue + rel_str = rel.as_posix() + if "/" not in rel_str: + # Repo-root file exemption per the rule. + continue + if rel_str in _EXEMPT_PATHS: + continue + if rel.parts and rel.parts[0].endswith(".egg-info"): + # setuptools-generated metadata; the SOURCES.txt manifest + # legitimately lists every project file including itself. + continue + offenders.extend(_scan_file(abs_path, rel_str)) + + if offenders: + self.fail( + f"{len(offenders)} self-path reference(s) found " + "(file contains its own relative path as a string; " + "remove the literal or mark with " + "'# nocheck: self-path-reference'):\n" + + "\n".join(f" - {o}" for o in offenders) + ) + + +if __name__ == "__main__": # pragma: no cover + unittest.main() diff --git a/tests/lint/repository/test_noqa_only_ruff_codes.py b/tests/lint/repository/test_noqa_only_ruff_codes.py index c7331139c2..68911585f0 100644 --- a/tests/lint/repository/test_noqa_only_ruff_codes.py +++ b/tests/lint/repository/test_noqa_only_ruff_codes.py @@ -73,7 +73,7 @@ _ALLOWLIST: frozenset[str] = frozenset( "tests/unit/utils/annotations/test_suppress.py", "docs/contributing/actions/testing/suppression.md", "tests/lint/repository/test_no_direct_yaml_calls.py", - "tests/lint/repository/test_noqa_only_ruff_codes.py", + "tests/lint/repository/test_noqa_only_ruff_codes.py", # nocheck: self-path-reference } ) diff --git a/tests/unit/cli/create/inventory/test_credentials_generator.py b/tests/unit/cli/create/inventory/test_credentials_generator.py index 8d0df666d0..1a0ce1d794 100644 --- a/tests/unit/cli/create/inventory/test_credentials_generator.py +++ b/tests/unit/cli/create/inventory/test_credentials_generator.py @@ -1,5 +1,3 @@ -# tests/unit/cli/create/inventory/test_credentials_generator.py - import tempfile import unittest from pathlib import Path diff --git a/tests/unit/cli/create/inventory/test_mirror_overrides.py b/tests/unit/cli/create/inventory/test_mirror_overrides.py index e7b116c8ba..12e2991369 100644 --- a/tests/unit/cli/create/inventory/test_mirror_overrides.py +++ b/tests/unit/cli/create/inventory/test_mirror_overrides.py @@ -1,4 +1,3 @@ -# tests/unit/cli/create/inventory/test_mirror_overrides.py from __future__ import annotations import unittest diff --git a/tests/unit/cli/create/inventory/test_services_disabler.py b/tests/unit/cli/create/inventory/test_services_disabler.py index 39ac6f42e9..475394429e 100644 --- a/tests/unit/cli/create/inventory/test_services_disabler.py +++ b/tests/unit/cli/create/inventory/test_services_disabler.py @@ -1,4 +1,3 @@ -# tests/unit/cli/create/inventory/test_services_disabler.py from __future__ import annotations import os diff --git a/tests/unit/cli/meta/applications/resolution/affected/test_main.py b/tests/unit/cli/meta/applications/resolution/affected/test_main.py index e231682a35..4a96027b03 100644 --- a/tests/unit/cli/meta/applications/resolution/affected/test_main.py +++ b/tests/unit/cli/meta/applications/resolution/affected/test_main.py @@ -1,4 +1,3 @@ -# tests/unit/cli/meta/applications/resolution/affected/test_main.py from __future__ import annotations import io diff --git a/tests/unit/cli/meta/applications/resolution/combined/test_main.py b/tests/unit/cli/meta/applications/resolution/combined/test_main.py index 7055ec1416..42d92e593f 100644 --- a/tests/unit/cli/meta/applications/resolution/combined/test_main.py +++ b/tests/unit/cli/meta/applications/resolution/combined/test_main.py @@ -1,4 +1,3 @@ -# tests/unit/cli/meta/applications/resolution/combined/test_main.py from __future__ import annotations import io diff --git a/tests/unit/cli/meta/applications/resolution/combined/test_repo_paths.py b/tests/unit/cli/meta/applications/resolution/combined/test_repo_paths.py index 10974552a5..a8d48ecc60 100644 --- a/tests/unit/cli/meta/applications/resolution/combined/test_repo_paths.py +++ b/tests/unit/cli/meta/applications/resolution/combined/test_repo_paths.py @@ -1,4 +1,3 @@ -# tests/unit/cli/meta/applications/resolution/combined/test_repo_paths.py from __future__ import annotations import unittest diff --git a/tests/unit/cli/meta/applications/resolution/combined/test_tree.py b/tests/unit/cli/meta/applications/resolution/combined/test_tree.py index c6bd4df27f..c580f9b82e 100644 --- a/tests/unit/cli/meta/applications/resolution/combined/test_tree.py +++ b/tests/unit/cli/meta/applications/resolution/combined/test_tree.py @@ -1,4 +1,3 @@ -# tests/unit/cli/meta/applications/resolution/combined/test_tree.py from __future__ import annotations import io diff --git a/tests/unit/cli/meta/applications/resolution/combined/test_yaml_utils.py b/tests/unit/cli/meta/applications/resolution/combined/test_yaml_utils.py index a84a012f54..77720d2b52 100644 --- a/tests/unit/cli/meta/applications/resolution/combined/test_yaml_utils.py +++ b/tests/unit/cli/meta/applications/resolution/combined/test_yaml_utils.py @@ -1,4 +1,3 @@ -# tests/unit/cli/meta/applications/resolution/combined/test_yaml_utils.py from __future__ import annotations import tempfile diff --git a/tests/unit/cli/meta/applications/resolution/dependencies/test_dependencies_main.py b/tests/unit/cli/meta/applications/resolution/dependencies/test_dependencies_main.py index b0649e1032..1a9436a77c 100644 --- a/tests/unit/cli/meta/applications/resolution/dependencies/test_dependencies_main.py +++ b/tests/unit/cli/meta/applications/resolution/dependencies/test_dependencies_main.py @@ -1,4 +1,3 @@ -# tests/unit/cli/meta/applications/resolution/dependencies/test_dependencies_main.py from __future__ import annotations import io diff --git a/tests/unit/cli/meta/applications/resolution/services/test_yaml_utils.py b/tests/unit/cli/meta/applications/resolution/services/test_yaml_utils.py index 4997bca0f8..ce538e0315 100644 --- a/tests/unit/cli/meta/applications/resolution/services/test_yaml_utils.py +++ b/tests/unit/cli/meta/applications/resolution/services/test_yaml_utils.py @@ -1,4 +1,3 @@ -# tests/unit/cli/meta/applications/resolution/services/test_yaml_utils.py from __future__ import annotations import tempfile diff --git a/tests/unit/cli/meta/applications/type/test_main.py b/tests/unit/cli/meta/applications/type/test_main.py index 871e373e00..4a8a67c2ba 100644 --- a/tests/unit/cli/meta/applications/type/test_main.py +++ b/tests/unit/cli/meta/applications/type/test_main.py @@ -1,4 +1,3 @@ -# tests/unit/cli/meta/applications/type/test_main.py from __future__ import annotations import io diff --git a/tests/unit/cli/test_inventory_manager.py b/tests/unit/cli/test_inventory_manager.py index e7c87fd9ad..b46cd24d91 100644 --- a/tests/unit/cli/test_inventory_manager.py +++ b/tests/unit/cli/test_inventory_manager.py @@ -1,5 +1,3 @@ -# tests/unit/cli/test_inventory_manager.py - import shutil import tempfile import unittest diff --git a/tests/unit/plugins/filter/test_add_csp_hash.py b/tests/unit/plugins/filter/test_add_csp_hash.py index cd7bfb417e..8012752299 100644 --- a/tests/unit/plugins/filter/test_add_csp_hash.py +++ b/tests/unit/plugins/filter/test_add_csp_hash.py @@ -1,4 +1,3 @@ -# tests/unit/plugins/filter/test_add_csp_hash.py import unittest from ansible.errors import AnsibleFilterError diff --git a/tests/unit/plugins/filter/test_generate_all_domains.py b/tests/unit/plugins/filter/test_generate_all_domains.py index 1756252639..4cead89d72 100644 --- a/tests/unit/plugins/filter/test_generate_all_domains.py +++ b/tests/unit/plugins/filter/test_generate_all_domains.py @@ -1,5 +1,3 @@ -# tests/unit/plugins/filter/test_generate_all_domains.py - import unittest from plugins.filter.generate_all_domains import FilterModule diff --git a/tests/unit/plugins/filter/test_get_all_invokable_apps.py b/tests/unit/plugins/filter/test_get_all_invokable_apps.py index 3a97bb296d..28382597cf 100644 --- a/tests/unit/plugins/filter/test_get_all_invokable_apps.py +++ b/tests/unit/plugins/filter/test_get_all_invokable_apps.py @@ -1,4 +1,3 @@ -# tests/unit/plugins/filter/test_get_all_invokable_apps.py import shutil import tempfile import unittest diff --git a/tests/unit/plugins/filter/test_get_deployment_types_from_groups.py b/tests/unit/plugins/filter/test_get_deployment_types_from_groups.py index 7d2c32095a..fbf6f18497 100644 --- a/tests/unit/plugins/filter/test_get_deployment_types_from_groups.py +++ b/tests/unit/plugins/filter/test_get_deployment_types_from_groups.py @@ -1,4 +1,3 @@ -# tests/unit/plugins/filter/test_get_deployment_types_from_groups.py from __future__ import annotations import unittest diff --git a/tests/unit/plugins/filter/test_get_docker_paths.py b/tests/unit/plugins/filter/test_get_docker_paths.py index 8726ad3988..90724990ce 100644 --- a/tests/unit/plugins/filter/test_get_docker_paths.py +++ b/tests/unit/plugins/filter/test_get_docker_paths.py @@ -1,4 +1,3 @@ -# tests/unit/plugins/filter/test_get_docker_paths.py import unittest from unittest.mock import patch diff --git a/tests/unit/plugins/filter/test_get_url.py b/tests/unit/plugins/filter/test_get_url.py index faba899bb1..ff19ed6d84 100644 --- a/tests/unit/plugins/filter/test_get_url.py +++ b/tests/unit/plugins/filter/test_get_url.py @@ -1,4 +1,3 @@ -# tests/unit/plugins/filter/test_get_url.py import sys import unittest from pathlib import Path diff --git a/tests/unit/plugins/filter/test_node_autosize.py b/tests/unit/plugins/filter/test_node_autosize.py index a2a73f4846..7b08726c73 100644 --- a/tests/unit/plugins/filter/test_node_autosize.py +++ b/tests/unit/plugins/filter/test_node_autosize.py @@ -1,4 +1,3 @@ -# tests/unit/plugins/filter/test_node_autosize.py import unittest from unittest.mock import patch diff --git a/tests/unit/plugins/filter/test_resource_filter.py b/tests/unit/plugins/filter/test_resource_filter.py index 2242be38b2..0c5fae762c 100644 --- a/tests/unit/plugins/filter/test_resource_filter.py +++ b/tests/unit/plugins/filter/test_resource_filter.py @@ -1,4 +1,3 @@ -# tests/unit/plugins/filter/test_resource_filter.py import importlib import unittest from unittest.mock import patch diff --git a/tests/unit/plugins/filter/test_text_filters.py b/tests/unit/plugins/filter/test_text_filters.py index 7ae94c7462..f1631ef867 100644 --- a/tests/unit/plugins/filter/test_text_filters.py +++ b/tests/unit/plugins/filter/test_text_filters.py @@ -1,4 +1,3 @@ -# tests/unit/plugins/filter/test_text_filters.py import unittest from ansible.errors import AnsibleFilterError diff --git a/tests/unit/plugins/filter/test_timeout_start_sec_for_domains.py b/tests/unit/plugins/filter/test_timeout_start_sec_for_domains.py index 1f0567e87e..d694505772 100644 --- a/tests/unit/plugins/filter/test_timeout_start_sec_for_domains.py +++ b/tests/unit/plugins/filter/test_timeout_start_sec_for_domains.py @@ -1,4 +1,3 @@ -# tests/unit/plugins/filter/test_timeout_start_sec_for_domains.py import unittest from ansible.errors import AnsibleFilterError diff --git a/tests/unit/plugins/lookup/test_cert.py b/tests/unit/plugins/lookup/test_cert.py index 8396070b5d..ab759abe80 100644 --- a/tests/unit/plugins/lookup/test_cert.py +++ b/tests/unit/plugins/lookup/test_cert.py @@ -1,4 +1,3 @@ -# tests/unit/plugins/lookup/test_cert.py import sys import unittest from unittest.mock import patch diff --git a/tests/unit/plugins/lookup/test_compose_file_args.py b/tests/unit/plugins/lookup/test_compose_file_args.py index 5e9f824be3..0414bb533e 100644 --- a/tests/unit/plugins/lookup/test_compose_file_args.py +++ b/tests/unit/plugins/lookup/test_compose_file_args.py @@ -1,4 +1,3 @@ -# tests/unit/plugins/lookup/test_compose_file_args.py import importlib.util import unittest from unittest.mock import patch diff --git a/tests/unit/plugins/lookup/test_database.py b/tests/unit/plugins/lookup/test_database.py index 1824b19bc4..52a19e0b2c 100644 --- a/tests/unit/plugins/lookup/test_database.py +++ b/tests/unit/plugins/lookup/test_database.py @@ -1,4 +1,3 @@ -# tests/unit/plugins/lookup/test_database.py import importlib.util import unittest from unittest.mock import patch diff --git a/tests/unit/plugins/lookup/test_domain_lookup.py b/tests/unit/plugins/lookup/test_domain_lookup.py index a3940e3c36..4bf3a08d6c 100644 --- a/tests/unit/plugins/lookup/test_domain_lookup.py +++ b/tests/unit/plugins/lookup/test_domain_lookup.py @@ -1,4 +1,3 @@ -# tests/unit/plugins/lookup/test_domain_lookup.py import sys import unittest from unittest.mock import patch diff --git a/tests/unit/plugins/lookup/test_nginx.py b/tests/unit/plugins/lookup/test_nginx.py index ecf50fad34..3585d342ba 100644 --- a/tests/unit/plugins/lookup/test_nginx.py +++ b/tests/unit/plugins/lookup/test_nginx.py @@ -1,4 +1,3 @@ -# tests/unit/plugins/lookup/test_nginx.py import unittest from unittest.mock import patch diff --git a/tests/unit/plugins/lookup/test_tls.py b/tests/unit/plugins/lookup/test_tls.py index aa969528c5..c954c149d1 100644 --- a/tests/unit/plugins/lookup/test_tls.py +++ b/tests/unit/plugins/lookup/test_tls.py @@ -1,4 +1,3 @@ -# tests/unit/plugins/lookup/test_tls.py import sys import unittest from unittest.mock import patch diff --git a/tests/unit/roles/sys-ctl-bkp-docker-2-loc/library/test_file_has_content.py b/tests/unit/roles/sys-ctl-bkp-docker-2-loc/library/test_file_has_content.py index d98c675cab..745964c37c 100644 --- a/tests/unit/roles/sys-ctl-bkp-docker-2-loc/library/test_file_has_content.py +++ b/tests/unit/roles/sys-ctl-bkp-docker-2-loc/library/test_file_has_content.py @@ -1,5 +1,3 @@ -# tests/unit/roles/sys-ctl-bkp-docker-2-loc/library/test_file_has_content.py - from __future__ import annotations import contextlib @@ -46,9 +44,7 @@ def _import_module_under_test(): """ Load the module under test via file path computed by walking parents only. - Test file: - tests/unit/roles/sys-ctl-bkp-docker-2-loc/library/test_file_has_content.py - Repo root is parents[5] from the test file path. + Repo root is ``parents[5]`` from this test file's location. """ module_path = ( PROJECT_ROOT diff --git a/tests/unit/roles/sys-ctl-cln-bkps/files/test_script.py b/tests/unit/roles/sys-ctl-cln-bkps/files/test_script.py index 97aca0235d..101e34e0e4 100644 --- a/tests/unit/roles/sys-ctl-cln-bkps/files/test_script.py +++ b/tests/unit/roles/sys-ctl-cln-bkps/files/test_script.py @@ -1,4 +1,3 @@ -# tests/unit/roles/sys-ctl-cln-bkps/files/test_script.py from __future__ import annotations import io diff --git a/tests/unit/roles/sys-ctl-hlth-csp/files/test_script.py b/tests/unit/roles/sys-ctl-hlth-csp/files/test_script.py index 7207a47cab..cd366dbc9d 100644 --- a/tests/unit/roles/sys-ctl-hlth-csp/files/test_script.py +++ b/tests/unit/roles/sys-ctl-hlth-csp/files/test_script.py @@ -1,4 +1,3 @@ -# tests/unit/roles/sys-ctl-hlth-csp/files/test_script.py from __future__ import annotations import sys diff --git a/tests/unit/roles/sys-dns-wildcards/filter_plugins/test_wildcard_dns.py b/tests/unit/roles/sys-dns-wildcards/filter_plugins/test_wildcard_dns.py index 780db34ab5..43d6fa8153 100644 --- a/tests/unit/roles/sys-dns-wildcards/filter_plugins/test_wildcard_dns.py +++ b/tests/unit/roles/sys-dns-wildcards/filter_plugins/test_wildcard_dns.py @@ -1,4 +1,3 @@ -# tests/unit/roles/sys-dns-wildcards/filter_plugins/test_wildcard_dns.py import importlib.util import unittest diff --git a/tests/unit/roles/sys-front-inj-all/filter_plugins/test_inj_snippets.py b/tests/unit/roles/sys-front-inj-all/filter_plugins/test_inj_snippets.py index 1dfefcaadc..451bf935d7 100644 --- a/tests/unit/roles/sys-front-inj-all/filter_plugins/test_inj_snippets.py +++ b/tests/unit/roles/sys-front-inj-all/filter_plugins/test_inj_snippets.py @@ -1,4 +1,3 @@ -# tests/unit/roles/sys-front-inj-all/filter_plugins/test_inj_snippets.py """ Unit tests for roles/sys-front-inj-all/filter_plugins/inj_snippets.py diff --git a/tests/unit/roles/sys-svc-container/files/test_container.py b/tests/unit/roles/sys-svc-container/files/test_container.py index ce03755b9e..65643452aa 100644 --- a/tests/unit/roles/sys-svc-container/files/test_container.py +++ b/tests/unit/roles/sys-svc-container/files/test_container.py @@ -16,7 +16,6 @@ from . import PROJECT_ROOT THIS_FILE = Path(__file__).resolve() -# tests/unit/roles/sys-svc-container/files/test_container.py -> project root CONTAINER_PY = PROJECT_ROOT / "roles" / "sys-svc-container" / "files" / "container.py" if not CONTAINER_PY.exists(): diff --git a/tests/unit/roles/web-svc-logout/filter_plugins/test_domain_filters.py b/tests/unit/roles/web-svc-logout/filter_plugins/test_domain_filters.py index 7451b776f9..2eaa364c19 100644 --- a/tests/unit/roles/web-svc-logout/filter_plugins/test_domain_filters.py +++ b/tests/unit/roles/web-svc-logout/filter_plugins/test_domain_filters.py @@ -1,5 +1,3 @@ -# tests/unit/roles/web-svc-logout/filter_plugins/test_domain_filters.py - import importlib.util import unittest diff --git a/tests/unit/roles/web_app_keycloak/test_filter_plugins_kcadm.py b/tests/unit/roles/web_app_keycloak/test_filter_plugins_kcadm.py index 5a6aa8c7e2..daf6ee9478 100644 --- a/tests/unit/roles/web_app_keycloak/test_filter_plugins_kcadm.py +++ b/tests/unit/roles/web_app_keycloak/test_filter_plugins_kcadm.py @@ -1,4 +1,3 @@ -# tests/unit/roles/web_app_keycloak/test_filter_plugins_kcadm.py from __future__ import annotations import importlib.util diff --git a/tests/unit/roles/web_app_keycloak/test_library_keycloak_kcadm_update.py b/tests/unit/roles/web_app_keycloak/test_library_keycloak_kcadm_update.py index 4c0232cbb7..c53daad5d1 100644 --- a/tests/unit/roles/web_app_keycloak/test_library_keycloak_kcadm_update.py +++ b/tests/unit/roles/web_app_keycloak/test_library_keycloak_kcadm_update.py @@ -1,4 +1,3 @@ -# tests/unit/roles/web_app_keycloak/test_library_keycloak_kcadm_update.py from __future__ import annotations import importlib.util diff --git a/tests/unit/roles/web_app_keycloak/test_module_utils_kcadm_json.py b/tests/unit/roles/web_app_keycloak/test_module_utils_kcadm_json.py index f32411c9f8..62c412899e 100644 --- a/tests/unit/roles/web_app_keycloak/test_module_utils_kcadm_json.py +++ b/tests/unit/roles/web_app_keycloak/test_module_utils_kcadm_json.py @@ -1,4 +1,3 @@ -# tests/unit/roles/web_app_keycloak/test_module_utils_kcadm_json.py from __future__ import annotations import importlib.util diff --git a/tests/unit/utils/manager/test_inventory_manager.py b/tests/unit/utils/manager/test_inventory_manager.py index d7b4f2b8de..2f6600ce50 100644 --- a/tests/unit/utils/manager/test_inventory_manager.py +++ b/tests/unit/utils/manager/test_inventory_manager.py @@ -1,5 +1,3 @@ -# tests/unit/utils/manager/test_inventory_manager.py - import tempfile from pathlib import Path from unittest import TestCase, main, mock diff --git a/utils/docker/paths_utils.py b/utils/docker/paths_utils.py index 842895fece..ac44b074ce 100644 --- a/utils/docker/paths_utils.py +++ b/utils/docker/paths_utils.py @@ -1,4 +1,3 @@ -# utils/docker/paths_utils.py from __future__ import annotations from utils.roles.entity_name import get_entity_name diff --git a/utils/roles/meta_lookup.py b/utils/roles/meta_lookup.py index 0c13915b4a..420ebb6ce5 100644 --- a/utils/roles/meta_lookup.py +++ b/utils/roles/meta_lookup.py @@ -126,8 +126,7 @@ def _resolve_role(role: PathLike, role_name: str | None) -> tuple[Path, str]: if role_path.is_absolute() or role_path.parts[:1] == (".",): role_dir = role_path.resolve() else: - # Treat as a role name relative to /roles. The repo root is - # two levels above this module: utils/roles/meta_lookup.py -> repo. + # Treat as a role name relative to /roles. repo_root = PROJECT_ROOT role_dir = repo_root / "roles" / str(role) name = role_name or role_dir.name diff --git a/utils/roles/validation/invokable.py b/utils/roles/validation/invokable.py index c183a67777..95c0a0c41f 100644 --- a/utils/roles/validation/invokable.py +++ b/utils/roles/validation/invokable.py @@ -1,4 +1,3 @@ -# utils/roles/validation/invokable.py from __future__ import annotations import re diff --git a/utils/templating/ansible.py b/utils/templating/ansible.py index de602dad3b..5ddb09c030 100644 --- a/utils/templating/ansible.py +++ b/utils/templating/ansible.py @@ -1,4 +1,3 @@ -# utils/templating/ansible.py from __future__ import annotations import contextlib diff --git a/utils/templating/jinja.py b/utils/templating/jinja.py index 492bba64cb..64dd70aeea 100644 --- a/utils/templating/jinja.py +++ b/utils/templating/jinja.py @@ -1,4 +1,3 @@ -# utils/templating/jinja.py # # Strict Jinja2 renderer for values that may contain Jinja markers. # diff --git a/utils/tls_common.py b/utils/tls_common.py index 6cd7fd5e57..95b439764c 100644 --- a/utils/tls_common.py +++ b/utils/tls_common.py @@ -1,4 +1,3 @@ -# utils/tls_common.py # # Shared strict resolution helpers for Infinito.Nexus TLS/cert lookups.