Skip to content
Merged
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
67 changes: 44 additions & 23 deletions .github/workflows/lint-bash.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,48 +31,69 @@ jobs:
with:
python-version: "3.11"

- name: Install Bash Linters
run: |
pip install beautysh
sudo apt-get update
sudo apt-get install -y shellcheck
- name: Set up uv
uses: astral-sh/setup-uv@v6
with:
enable-cache: true

- name: Run Beautysh
run: |
shopt -s globstar nullglob
if compgen -G "**/*.sh" > /dev/null; then
beautysh **/*.sh --indent-size 2 --check
uv tool run --from beautysh beautysh **/*.sh --indent-size 2 --check
fi
shopt -u globstar nullglob

- name: Check Bash Script Shebang
- name: Check Bash Scripts for bash shebang
run: |
while IFS= read -r -d '' file; do
if head -n 1 "$file" | grep -Eq '^#!/usr/bin/env bash$|^#!/bin/bash$'; then
while read -r file
do
shebang="$(head -n 1 "$file")"
if [[ "$shebang" = "#!/bin/bash" || "$shebang" = "#!/usr/bin/env bash" ]]
then
echo "[bash shebang -> Present] $file"
else
echo "[bash shebang -> NOT FOUND] $file"
exit 1
echo "[bash shebang -> NOT FOUND] $file" && exit 1
fi
done < <(find . -name '*.sh' -print0)
done < <(find . -name '*.sh')

- name: Check Bash Scripts for Pipefail
- name: Check Bash Scripts for strict mode opt-in
run: |
while IFS= read -r -d '' file; do
while read -r file
do
if grep -q \
-e "^[[:space:]]*set -euo pipefail$" \
-e "^[[:space:]]*set -Eeuo pipefail$" \
-e "^[[:space:]]*# @paradedb-skip-check-pipefail$" \
"$file"; then
echo "[pipefail -> Present] $file"
-e "^# @paradedb-skip-check-pipefail$" \
"$file"
then
echo "[strict mode -> Present] $file"
else
echo "[pipefail -> NOT FOUND] $file"
exit 1
echo "[strict mode -> NOT FOUND] $file" && exit 1
fi
done < <(find . -name '*.sh' -print0)
done < <(find . -name '*.sh')

- name: Run ShellCheck
run: |
while IFS= read -r -d '' file; do
shellcheck -x "$file"
done < <(find . -name '*.sh' -print0)
uv run --no-sync python - <<'PY'
import glob
import subprocess
import sys

sh_files = sorted(set(glob.glob("**/*.sh", recursive=True)))
if not sh_files:
print("[Shellcheck skipped] No shell scripts found.")
sys.exit(0)
for file in sh_files:
p = subprocess.run(
f"shellcheck -x -P scripts {file}",
shell=True,
capture_output=True,
check=False,
)
print(p.stdout.decode())
if p.returncode != 0:
print(f"[Shellcheck did not pass] {file}")
sys.exit(1)
print(f"[Shellcheck passed] {len(sh_files)} script(s)")
PY
26 changes: 21 additions & 5 deletions .github/workflows/lint-format.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# workflows/lint-format.yml
#
# Lint Format
# Lint file line endings and trailing whitespace.
# Lint the project's file trailing spaces, line endings, and format.

name: Lint Format

Expand All @@ -26,17 +26,33 @@ jobs:
- name: Check for CRLF Files
run: |
FILES=$(git ls-files --eol | grep crlf || true)
if [[ -n "$FILES" ]]; then
if [[ ! -z "$FILES" ]]; then
echo "The following files have incorrect line endings:"
echo "$FILES"
exit 1
false
fi

- name: Check for Trailing Whitespaces
run: |
FILES=$(git grep -Ilr '[[:blank:]]$' -- . || true)
if [[ -n "$FILES" ]]; then
FILES=$(git grep -Ilr '[[:blank:]]$' -- \
':(exclude)*.nix' \
':(exclude)*.sql' \
':(exclude)*.out' \
':(exclude)*.rs' \
':(exclude)docker/manifests/**' || true)
if [[ ! -z "$FILES" ]]; then
echo "The following files have trailing whitespaces:"
echo "$FILES"
exit 1
fi

- name: Print Modified Files
run: |
FILES=$(git ls-files --modified)
if [[ ! -z "$FILES" ]]; then
echo "The following files have incorrect trailing newlines:"
echo "$FILES"
echo "Please fix them using:"
echo -e 'if [[ -f "$1" ]]; then\n echo -n "$1"\n if (diff /dev/null "$1" || true) | tail -1 | grep -q "^\\ No newline"; then\n echo >> "$1"\n echo "...fixed"\n else\n echo ""\n fi\nfi'
false
fi
8 changes: 4 additions & 4 deletions .github/workflows/lint-markdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ on:
paths:
- "**/*.md"
- "**/*.mdx"
- ".github/workflows/lint-markdown.yml"
- ".markdownlint.yaml"
- ".prettierignore"
- ".prettierrc"
- ".github/workflows/lint-markdown.yml"
workflow_dispatch:

concurrency:
Expand All @@ -33,11 +33,11 @@ jobs:
- name: Set up NodeJS Environment
uses: actions/setup-node@v6

- name: Install Markdown Linters
- name: Install Prettier and markdownlint
run: npm install -g prettier markdownlint-cli

- name: Run Markdown Lint
run: markdownlint '**/*.md'
run: markdownlint "**/*.md"

- name: Run Prettier
run: prettier --check '{**/*.md,**/*.mdx}' --ignore-path .prettierignore
run: prettier --check "{**/*.md,**/*.mdx}" --ignore-path .prettierignore
Loading