mirror of
https://github.com/OpenHands/OpenHands.git
synced 2026-10-06 14:33:11 +08:00
Fix lint failures and enforce linting in CI (#209)
* Fix lint errors and run lint in CI Closes #208 Co-authored-by: openhands <openhands@all-hands.dev> * fix: enforce LF line endings in CI Co-authored-by: openhands <openhands@all-hands.dev> * chore: address PR review feedback (#209) Co-authored-by: openhands <openhands@all-hands.dev> * chore: use stop hook for OpenHands quality gate Co-authored-by: openhands <openhands@all-hands.dev> * fix: resolve main merge typecheck failure Co-authored-by: openhands <openhands@all-hands.dev> * fix: keep settings retry helper iterative Co-authored-by: openhands <openhands@all-hands.dev> --------- Co-authored-by: openhands <openhands@all-hands.dev>
This commit is contained in:
committed by
GitHub
co-authored by
openhands
parent
7ebf95a66b
commit
00f1d99b1c
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"stop": [
|
||||
{
|
||||
"matcher": "*",
|
||||
"hooks": [
|
||||
{
|
||||
"type": "command",
|
||||
"command": ".openhands/hooks/on_stop.sh",
|
||||
"timeout": 600
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
Executable
+34
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env bash
|
||||
# Stop hook: runs the repo quality gate before allowing OpenHands to finish.
|
||||
#
|
||||
# Hooks can block agent completion by exiting with code 2 and returning JSON.
|
||||
# Keep this aligned with the checks that should run before an agent declares
|
||||
# repository work complete.
|
||||
|
||||
set -o pipefail
|
||||
|
||||
PROJECT_DIR="${OPENHANDS_PROJECT_DIR:-$(pwd)}"
|
||||
cd "$PROJECT_DIR" || exit 1
|
||||
|
||||
run_check() {
|
||||
local name="$1"
|
||||
shift
|
||||
|
||||
echo "=== Running ${name} ===" >&2
|
||||
local output
|
||||
output=$("$@" 2>&1)
|
||||
local exit_code=$?
|
||||
echo "$output" >&2
|
||||
|
||||
if [ "$exit_code" -ne 0 ]; then
|
||||
local escaped_output
|
||||
escaped_output=$(printf '%s' "$output" | jq -Rs .)
|
||||
printf '{"decision":"deny","reason":"%s failed","additionalContext":%s}\n' "$name" "$escaped_output"
|
||||
exit 2
|
||||
fi
|
||||
}
|
||||
|
||||
run_check "npm run lint" npm run lint
|
||||
run_check "npm test" npm test
|
||||
|
||||
echo '{"decision":"allow"}'
|
||||
@@ -1,9 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||||
|
||||
cd "$REPO_ROOT" || exit 1
|
||||
|
||||
npm run lint
|
||||
npm run test
|
||||
Reference in New Issue
Block a user