mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-07 19:32:17 +00:00
feat(lint): check the syntax of the PHP and Ruby the roles ship
Twenty-three PHP and twenty Ruby files reached the applications unchecked, which is where the provisioning scripts live. php -l and ruby -c cover what is reachable here; PHPStan and RuboCop would need the target project's classes, since these scripts run inside Moodle, Snipe-IT or GitLab. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
28475455db
commit
82218087c1
8 files changed
+110
No files matched your search
@@ -405,7 +405,9 @@ lint: install-lint
|
||||
lint-mermaid \
|
||||
lint-packages \
|
||||
lint-playwright \
|
||||
lint-php \
|
||||
lint-python \
|
||||
lint-ruby \
|
||||
lint-shellcheck
|
||||
|
||||
.PHONY: lint-action
|
||||
@@ -458,11 +460,21 @@ lint-packages: install-lint
|
||||
lint-playwright: install-lint
|
||||
@bash scripts/lint/wrapper.sh playwright
|
||||
|
||||
.PHONY: lint-php
|
||||
# Run the PHP syntax check over every tracked PHP file.
|
||||
lint-php: install-lint
|
||||
@bash scripts/lint/wrapper.sh php
|
||||
|
||||
.PHONY: lint-python
|
||||
# Run Python lint checks.
|
||||
lint-python: install-lint
|
||||
@bash scripts/lint/wrapper.sh python
|
||||
|
||||
.PHONY: lint-ruby
|
||||
# Run the Ruby syntax check over every tracked Ruby file.
|
||||
lint-ruby: install-lint
|
||||
@bash scripts/lint/wrapper.sh ruby
|
||||
|
||||
.PHONY: lint-shellcheck
|
||||
# Run shellcheck lint checks.
|
||||
lint-shellcheck: install-lint
|
||||
|
||||
@@ -53,7 +53,9 @@ alias i8lime='m lint-mermaid'
|
||||
alias i8lina='m lint-ansible'
|
||||
alias i8lipa='m lint-packages'
|
||||
alias i8lipa2='m lint-playwright'
|
||||
alias i8liph='m lint-php'
|
||||
alias i8lipo='m lint-python'
|
||||
alias i8liru='m lint-ruby'
|
||||
alias i8lise='m lint-shellcheck'
|
||||
alias i8maco='i8source && python3 -m cli.meta.ci.query --mode compose --matrix' # complexity matrix in compose query order
|
||||
alias i8maho='i8source && python3 -m cli.meta.ci.query --mode host --matrix' # complexity matrix in host query order
|
||||
|
||||
Executable
+19
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
# shellcheck shell=bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd -- "${SCRIPT_DIR}/../.." && pwd)"
|
||||
|
||||
cd "${REPO_ROOT}"
|
||||
|
||||
mapfile -t php_files < <(find . -type f -name '*.php' 2>/dev/null | sed 's|^\./||' | sort)
|
||||
if [[ "${#php_files[@]}" -eq 0 ]]; then
|
||||
printf 'No PHP files found.\n'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
printf 'Checking %d PHP file(s) with php -l.\n' "${#php_files[@]}"
|
||||
printf '%s\0' "${php_files[@]}" | xargs -0 -n1 php -l >/dev/null
|
||||
printf 'php -l OK (%d file(s))\n' "${#php_files[@]}"
|
||||
Executable
+19
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
# shellcheck shell=bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd -- "${SCRIPT_DIR}/../.." && pwd)"
|
||||
|
||||
cd "${REPO_ROOT}"
|
||||
|
||||
mapfile -t ruby_files < <(find . -type f -name '*.rb' 2>/dev/null | sed 's|^\./||' | sort)
|
||||
if [[ "${#ruby_files[@]}" -eq 0 ]]; then
|
||||
printf 'No Ruby files found.\n'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
printf 'Checking %d Ruby file(s) with ruby -c.\n' "${#ruby_files[@]}"
|
||||
printf '%s\0' "${ruby_files[@]}" | xargs -0 -n1 ruby -c >/dev/null
|
||||
printf 'ruby -c OK (%d file(s))\n' "${#ruby_files[@]}"
|
||||
@@ -23,7 +23,9 @@ from utils.install.lint import (
|
||||
mbake,
|
||||
mermaid_cli,
|
||||
packages,
|
||||
php,
|
||||
playwright,
|
||||
ruby,
|
||||
ruff,
|
||||
shellcheck,
|
||||
shfmt,
|
||||
@@ -48,6 +50,8 @@ _STAMP_TOOLS = (
|
||||
"hadolint",
|
||||
"markdownlint-cli2",
|
||||
"mbake",
|
||||
"php",
|
||||
"ruby",
|
||||
"ruff",
|
||||
"shellcheck",
|
||||
"shfmt",
|
||||
@@ -69,6 +73,14 @@ def _install_python_tools() -> None:
|
||||
ruff.ensure()
|
||||
|
||||
|
||||
def _install_php_tools() -> None:
|
||||
php.ensure()
|
||||
|
||||
|
||||
def _install_ruby_tools() -> None:
|
||||
ruby.ensure()
|
||||
|
||||
|
||||
def _install_shellcheck_tools() -> None:
|
||||
shellcheck.ensure()
|
||||
|
||||
@@ -105,6 +117,8 @@ _GROUP_FN_NAMES = {
|
||||
"action": "_install_action_tools",
|
||||
"ansible": "_install_ansible_tools",
|
||||
"python": "_install_python_tools",
|
||||
"php": "_install_php_tools",
|
||||
"ruby": "_install_ruby_tools",
|
||||
"shellcheck": "_install_shellcheck_tools",
|
||||
"dockerfile": "_install_dockerfile_tools",
|
||||
"markdown": "_install_markdown_tools",
|
||||
@@ -120,6 +134,8 @@ def _install_all() -> None:
|
||||
_install_action_tools()
|
||||
_install_ansible_tools()
|
||||
_install_python_tools()
|
||||
_install_php_tools()
|
||||
_install_ruby_tools()
|
||||
_install_shellcheck_tools()
|
||||
_install_dockerfile_tools()
|
||||
_install_markdown_tools()
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
"""Install the PHP interpreter, whose syntax check is the lint."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from utils.install.primitives import log, which
|
||||
from utils.install.system_pkg import install_command_via_pkg
|
||||
|
||||
|
||||
def ensure() -> None:
|
||||
if which("php"):
|
||||
return
|
||||
|
||||
log("Missing command 'php'. Attempting system package installation.")
|
||||
install_command_via_pkg("php")
|
||||
|
||||
if not which("php"):
|
||||
raise RuntimeError("Command 'php' is still unavailable after installation.")
|
||||
@@ -0,0 +1,17 @@
|
||||
"""Install the Ruby interpreter, whose syntax check is the lint."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from utils.install.primitives import log, which
|
||||
from utils.install.system_pkg import install_command_via_pkg
|
||||
|
||||
|
||||
def ensure() -> None:
|
||||
if which("ruby"):
|
||||
return
|
||||
|
||||
log("Missing command 'ruby'. Attempting system package installation.")
|
||||
install_command_via_pkg("ruby")
|
||||
|
||||
if not which("ruby"):
|
||||
raise RuntimeError("Command 'ruby' is still unavailable after installation.")
|
||||
@@ -105,6 +105,14 @@ _COMMAND_PACKAGES: dict[str, dict[str, list[str]]] = {
|
||||
"yum": ["ansible-core", "ansible"],
|
||||
"brew": ["ansible"],
|
||||
},
|
||||
"php": {
|
||||
"pacman": ["php"],
|
||||
"apt-get": ["php-cli"],
|
||||
"dnf": ["php-cli"],
|
||||
"yum": ["php-cli"],
|
||||
"brew": ["php"],
|
||||
},
|
||||
"ruby": {m: ["ruby"] for m in _SUPPORTED},
|
||||
"ruff": {m: ["ruff"] for m in _SUPPORTED},
|
||||
"shfmt": {m: ["shfmt"] for m in _SUPPORTED},
|
||||
"shellcheck": {m: ["shellcheck"] for m in _SUPPORTED},
|
||||
|
||||
Reference in new issue
Block a user