Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
- all-globs-to-all-files: ['!doc/styles/**', '!doc/.vale.ini']

## -- Other labels ------------------------------------------------------------
'code-style':
'style':
- any:
- changed-files:
- any-glob-to-any-file: ['.pre-commit-config.yaml', 'doc/.vale.ini']
Expand All @@ -38,4 +38,4 @@
'deploy-pr-doc':
- all:
- changed-files:
- all-globs-to-all-files: ['THIS-NEVER-MATCHES-A-FILE']
- all-globs-to-all-files: ['THIS-NEVER-MATCHES-A-FILE']
10 changes: 9 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
repos:

- repo: local
hooks:
- id: shellcheck
name: shellcheck
entry: python bin/shellcheck
language: python
additional_dependencies: [shellcheck-py, pyyaml]

- repo: https://github.com/psf/black
rev: 25.1.0
hooks:
Expand Down Expand Up @@ -38,4 +46,4 @@ repos:
files: '/.*\.(yml)$'
args:
- --start_year=2022
exclude: '^(.github|doc)/.*'
exclude: '^(.github|doc)/.*'
36 changes: 36 additions & 0 deletions bin/shellcheck
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import pathlib
import subprocess

import yaml

ACTIONS_DIRECTORY = pathlib.Path(__file__).parent.resolve()

for actionfile in ACTIONS_DIRECTORY.glob("**/*.yml"):
if any(substring in str(actionfile) for substring in [".venv", "doc", ".github"]):
continue

print(f"Reading {actionfile}", flush=True)

try:
action = yaml.safe_load(actionfile.read_text(encoding="utf-8"))
except yaml.YAMLError as e:
print(f"YAML parse error in {actionfile}: {e}", flush=True)
continue

# Check for existence of "runs" and "steps"
runs = action.get("runs", {})
steps = runs.get("steps", [])

for step in steps:
if step.get("shell") != "bash":
continue
if "run" not in step:
continue

run_content = "#!/bin/bash\n" + step["run"]
result = subprocess.run(
["shellcheck", "-"],
input=run_content,
capture_output=True,
text=True,
)
1 change: 1 addition & 0 deletions doc/source/changelog/906.maintenance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add shellcheck hook

Check failure on line 1 in doc/source/changelog/906.maintenance.md

View workflow job for this annotation

GitHub Actions / Doc style

[vale] reported by reviewdog 🐶 [Vale.Spelling] Did you really mean 'shellcheck'? Raw Output: {"message": "[Vale.Spelling] Did you really mean 'shellcheck'?", "location": {"path": "doc/source/changelog/906.maintenance.md", "range": {"start": {"line": 1, "column": 5}}}, "severity": "ERROR"}
Loading