@@ -4,6 +4,7 @@ on: [push, pull_request]
44jobs :
55 build-test :
66 runs-on : ubuntu-latest
7+ timeout-minutes : 20
78 services :
89 postgres :
910 image : postgres:15
3334 run : git diff --exit-code -- pnpm-lock.yaml
3435
3536 # Install Bats for CLI tests executed in this workflow
36- - name : Install Bats (Ubuntu)
37- run : |
38- curl -LO https://github.com/bats-core/bats-core/archive/v1.12.0.tar.gz
39- tar -xzf v1.12.0.tar.gz
40- sudo ./bats-core-1.12.0/install.sh /usr/local
41- echo "/usr/local/bin" >> $GITHUB_PATH
37+ - name : Install Bats
38+ uses : ./.github/actions/install-bats
4239
4340 # Spin local PG via docker-compose init scripts (extensions)
4441 - run : psql -h localhost -U postgres -c "select 1" || true
5249 # (See .github/workflows/cli-tests.yml and cli-quick.yml)
5350
5451 - run : node packages/wesley-host-node/bin/wesley.mjs generate --schema test/fixtures/examples/ecommerce.graphql --allow-dirty
52+
53+ - name : Detect changes for repo Bats tests (no servers)
54+ id : changelog
55+ env :
56+ EVENT : ${{ github.event_name }}
57+ BASE_REF : ${{ github.event.pull_request.base.sha }}
58+ BEFORE : ${{ github.event.before }}
59+ SHA : ${{ github.sha }}
60+ run : |
61+ set -euo pipefail
62+ RANGE="${BEFORE}..${SHA}"
63+ if [ "$EVENT" = "pull_request" ] && [ -n "${BASE_REF}" ]; then
64+ RANGE="${BASE_REF}..${SHA}"
65+ fi
66+ echo "Diff range: $RANGE"
67+ CHANGED=$(git diff --name-only "$RANGE" || true)
68+ echo "$CHANGED" | sed 's/^/ - /'
69+ NEED=false
70+ # Trigger only on unit/serverless tests; exclude browser-contracts and serve-static e2e
71+ echo "$CHANGED" | grep -E -q '^(scripts/serve-static\.mjs|test/serve-static-(unit|relative-unit)\.bats|scripts/compute-progress\.mjs|test/progress-|test/ci-|test/deno-host-webcrypto-guard\.bats)' && NEED=true || true
72+ echo "RUN_BATS=$NEED" >> $GITHUB_ENV
73+
74+ - name : Repo Bats tests (unit/progress/ci checks only)
75+ if : ${{ env.RUN_BATS == 'true' }}
76+ env :
77+ BATS_LIB_PATH : packages/wesley-cli/test
78+ TERM : xterm
79+ BATS_NO_COLOR : " 1"
80+ run : |
81+ # Ensure tests that use `load 'bats-plugins/…'` from the repo-level
82+ # `test/` directory can resolve plugins.
83+ timeout 2m bash scripts/setup-bats-plugins.sh
84+ rm -rf test/bats-plugins || true
85+ ln -sfn "$PWD/packages/wesley-cli/test/bats-plugins" test/bats-plugins
86+ set -euo pipefail
87+ files=(
88+ test/serve-static-unit.bats
89+ test/serve-static-relative-unit.bats
90+ test/progress-dry-run.bats
91+ test/progress-safety.bats
92+ test/ci-browser-smoke.bats
93+ test/ci-pkg-core.bats
94+ test/ci-pkg-host-bun.bats
95+ test/ci-workflows.bats
96+ test/deno-host-webcrypto-guard.bats
97+ )
98+ for f in "${files[@]}"; do
99+ echo "Running Bats: $f"
100+ timeout 3m bats -t "$f"
101+ done
0 commit comments