Chore: Configure pre-commit to format our s6-overlay files (#11414)

This commit is contained in:
Trenton H
2025-11-19 13:34:29 -08:00
committed by GitHub
parent 4a8d3c858c
commit bc622d67fc
5 changed files with 30 additions and 26 deletions

View File

@@ -11,6 +11,10 @@ end_of_line = lf
charset = utf-8 charset = utf-8
max_line_length = 79 max_line_length = 79
[*.sh]
indent_style = tab
indent_size = 1
[{*.html,*.css,*.js}] [{*.html,*.css,*.js}]
max_line_length = off max_line_length = off

View File

@@ -49,12 +49,12 @@ repos:
- 'prettier-plugin-organize-imports@4.1.0' - 'prettier-plugin-organize-imports@4.1.0'
# Python hooks # Python hooks
- repo: https://github.com/astral-sh/ruff-pre-commit - repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.0 rev: v0.14.5
hooks: hooks:
- id: ruff-check - id: ruff-check
- id: ruff-format - id: ruff-format
- repo: https://github.com/tox-dev/pyproject-fmt - repo: https://github.com/tox-dev/pyproject-fmt
rev: "v2.11.0" rev: "v2.11.1"
hooks: hooks:
- id: pyproject-fmt - id: pyproject-fmt
# Dockerfile hooks # Dockerfile hooks
@@ -64,11 +64,11 @@ repos:
- id: hadolint - id: hadolint
# Shell script hooks # Shell script hooks
- repo: https://github.com/lovesegfault/beautysh - repo: https://github.com/lovesegfault/beautysh
rev: v6.2.1 rev: v6.4.2
hooks: hooks:
- id: beautysh - id: beautysh
additional_dependencies: types: [file]
- setuptools files: (\.sh$|/run$|/finish$)
args: args:
- "--tab" - "--tab"
- repo: https://github.com/shellcheck-py/shellcheck-py - repo: https://github.com/shellcheck-py/shellcheck-py
@@ -76,7 +76,7 @@ repos:
hooks: hooks:
- id: shellcheck - id: shellcheck
- repo: https://github.com/google/yamlfmt - repo: https://github.com/google/yamlfmt
rev: v0.18.0 rev: v0.20.0
hooks: hooks:
- id: yamlfmt - id: yamlfmt
exclude: "^src-ui/pnpm-lock.yaml" exclude: "^src-ui/pnpm-lock.yaml"

View File

@@ -29,5 +29,5 @@ if find /run/s6/container_environment/*"_FILE" -maxdepth 1 > /dev/null 2>&1; the
fi fi
done done
else else
echo "${log_prefix} No *_FILE environment found" echo "${log_prefix} No *_FILE environment found"
fi fi

View File

@@ -12,24 +12,24 @@ declare -i DELAY=0
declare -i STARTED_AT=${EPOCHSECONDS:?EPOCHSECONDS var unset} declare -i STARTED_AT=${EPOCHSECONDS:?EPOCHSECONDS var unset}
delay_next_attempt() { delay_next_attempt() {
local -i elapsed=$(( EPOCHSECONDS - STARTED_AT )) local -i elapsed=$(( EPOCHSECONDS - STARTED_AT ))
local -ri remaining=$(( TIMEOUT - elapsed )) local -ri remaining=$(( TIMEOUT - elapsed ))
if (( remaining <= 0 )); then if (( remaining <= 0 )); then
echo "${LOG_PREFIX} Unable to connect after $elapsed seconds." echo "${LOG_PREFIX} Unable to connect after $elapsed seconds."
exit 1 exit 1
fi fi
DELAY+=1 DELAY+=1
# clamp to remaining time # clamp to remaining time
if (( DELAY > remaining )); then if (( DELAY > remaining )); then
DELAY=$remaining DELAY=$remaining
fi fi
ATTEMPT+=1 ATTEMPT+=1
echo "${LOG_PREFIX} Attempt $ATTEMPT failed! Trying again in $DELAY seconds..." echo "${LOG_PREFIX} Attempt $ATTEMPT failed! Trying again in $DELAY seconds..."
sleep "$DELAY" sleep "$DELAY"
} }
wait_for_postgres() { wait_for_postgres() {
@@ -40,7 +40,7 @@ wait_for_postgres() {
local -r user="${PAPERLESS_DBUSER:-paperless}" local -r user="${PAPERLESS_DBUSER:-paperless}"
while ! pg_isready -h "${host}" -p "${port}" --username "${user}"; do while ! pg_isready -h "${host}" -p "${port}" --username "${user}"; do
delay_next_attempt delay_next_attempt
done done
echo "${LOG_PREFIX} Connected to PostgreSQL" echo "${LOG_PREFIX} Connected to PostgreSQL"
} }
@@ -52,7 +52,7 @@ wait_for_mariadb() {
local -r port="${PAPERLESS_DBPORT:-3306}" local -r port="${PAPERLESS_DBPORT:-3306}"
while ! mariadb-admin --host="$host" --port="$port" ping --silent >/dev/null 2>&1; do while ! mariadb-admin --host="$host" --port="$port" ping --silent >/dev/null 2>&1; do
delay_next_attempt delay_next_attempt
done done
echo "${LOG_PREFIX} Connected to MariaDB" echo "${LOG_PREFIX} Connected to MariaDB"
} }

View File

@@ -10,11 +10,11 @@ export GRANIAN_WORKERS=${GRANIAN_WORKERS:-${PAPERLESS_WEBSERVER_WORKERS:-1}}
# Only set GRANIAN_URL_PATH_PREFIX if PAPERLESS_FORCE_SCRIPT_NAME is set # Only set GRANIAN_URL_PATH_PREFIX if PAPERLESS_FORCE_SCRIPT_NAME is set
if [[ -n "${PAPERLESS_FORCE_SCRIPT_NAME}" ]]; then if [[ -n "${PAPERLESS_FORCE_SCRIPT_NAME}" ]]; then
export GRANIAN_URL_PATH_PREFIX=${PAPERLESS_FORCE_SCRIPT_NAME} export GRANIAN_URL_PATH_PREFIX=${PAPERLESS_FORCE_SCRIPT_NAME}
fi fi
if [[ -n "${USER_IS_NON_ROOT}" ]]; then if [[ -n "${USER_IS_NON_ROOT}" ]]; then
exec granian --interface asginl --ws --loop uvloop "paperless.asgi:application" exec granian --interface asginl --ws --loop uvloop "paperless.asgi:application"
else else
exec s6-setuidgid paperless granian --interface asginl --ws --loop uvloop "paperless.asgi:application" exec s6-setuidgid paperless granian --interface asginl --ws --loop uvloop "paperless.asgi:application"
fi fi