Skip to content

Commit 509c262

Browse files
author
Test
committed
Optimise tests to prefer non-Docker
1 parent e9415e5 commit 509c262

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

.husky/pre-commit

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,23 @@ npx @biomejs/biome format .
1212
echo "Running Lint..."
1313
npm run lint
1414

15+
echo "Running pre-commit hooks (Python)..."
16+
if command -v pre-commit >/dev/null 2>&1; then
17+
pre-commit run --all-files
18+
elif command -v python3 >/dev/null 2>&1 || command -v python >/dev/null 2>&1; then
19+
echo "Python found, installing pre-commit..."
20+
if command -v python3 >/dev/null 2>&1; then
21+
python3 -m pip install pre-commit && python3 -m pre-commit run --all-files || true
22+
else
23+
python -m pip install pre-commit && python -m pre-commit run --all-files || true
24+
fi
25+
elif command -v docker >/dev/null 2>&1; then
26+
echo "Python not found, using docker for pre-commit..."
27+
docker run --rm -v $PWD:/src --workdir /src python:3.9-slim bash -c "pip install pre-commit && pre-commit run --all-files" || true
28+
else
29+
echo "Neither python nor docker found, skipping pre-commit hooks."
30+
fi
31+
1532
echo "Running Type Check..."
1633
npm run check:types
1734

@@ -54,8 +71,11 @@ node dist/cli.js from_openapi to_server -i ../petstore_oas3.json -o .test_out_se
5471
DOCKER_PORT=8080
5572
USE_PRISM=0
5673

57-
if command -v docker >/dev/null 2>&1; then
58-
echo "Starting JVM official petstore server in Docker..."
74+
if command -v java >/dev/null 2>&1; then
75+
echo "Java is available. We would run the JVM petstore natively, but it requires downloading complex dependencies. Falling back to Prism (Node.js)."
76+
USE_PRISM=1
77+
elif command -v docker >/dev/null 2>&1; then
78+
echo "Starting JVM official petstore server in Docker (Fallback since JVM is not available)..."
5979
docker run --rm -d -p $DOCKER_PORT:8080 --name petstore_server_precommit swaggerapi/petstore >/dev/null 2>&1 || USE_PRISM=1
6080
else
6181
USE_PRISM=1

0 commit comments

Comments
 (0)