Skip to content
Closed
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
19 changes: 19 additions & 0 deletions .github/ci-probe/handles.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const t0 = Date.now();
const describe = h => {
const n = h && h.constructor ? h.constructor.name : typeof h;
const o = { type: n };
if (h.spawnargs) Object.assign(o, { pid: h.pid, args: h.spawnargs.join(' ').slice(0, 300), exit: h.exitCode });
if (typeof h.remoteAddress !== 'undefined' || typeof h.localPort !== 'undefined')
Object.assign(o, { remote: `${h.remoteAddress}:${h.remotePort}`, local: h.localPort, fd: h._handle && h._handle.fd, destroyed: h.destroyed });
if (typeof h.address === 'function' && !h.remoteAddress) { try { o.listen = JSON.stringify(h.address()); } catch {} }
if (h._onTimeout) Object.assign(o, { ms: h._idleTimeout, fn: String(h._onTimeout).slice(0, 300) });
return o;
};
const iv = setInterval(() => {
const s = (Date.now() - t0) / 1000;
if (s < 30) return;
console.error(`[handles pid=${process.pid} +${s}s]`, JSON.stringify(process.getActiveResourcesInfo()));
for (const h of process._getActiveHandles()) if (h !== iv) console.error(' ', JSON.stringify(describe(h)));
for (const r of process._getActiveRequests()) console.error(' req', r && r.constructor && r.constructor.name);
}, 15000);
iv.unref();
160 changes: 17 additions & 143 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,164 +2,38 @@ name: Tests

on:
pull_request:
push:
branches: [main]

permissions:
contents: read

concurrency:
group: tests-${{ github.ref }}
cancel-in-progress: true

jobs:
# The image of the Host tests job (.github/ci/Dockerfile), tagged with a
# hash of its Dockerfile. It is built and pushed only when no image has that
# tag; otherwise this job only looks it up. A pull request from a fork
# cannot push, so one that changes the Dockerfile fails here.
ci-image:
name: CI image
runs-on: ubuntu-24.04
permissions:
contents: read
packages: write
outputs:
image: ${{ steps.image.outputs.image }}
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
steps:
- uses: actions/checkout@v4
with:
sparse-checkout: .github/ci
- name: Name the image
id: image
shell: bash
run: |
image="ghcr.io/${GITHUB_REPOSITORY,,}-ci:$(sha256sum .github/ci/Dockerfile | cut -c1-16)"
echo "image=$image" >> "$GITHUB_OUTPUT"
echo "IMAGE=$image" >> "$GITHUB_ENV"
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Look for the image
id: found
run: |
if docker manifest inspect "$IMAGE" > /dev/null 2>&1; then
echo "found=true" >> "$GITHUB_OUTPUT"
echo "$IMAGE exists"
fi
# Docker Hub limits the pulls without a login per address, and the
# hosted runners share their addresses.
- if: steps.found.outputs.found != 'true' && env.DOCKERHUB_USERNAME != ''
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push the image
if: steps.found.outputs.found != 'true'
run: |
docker build -t "$IMAGE" .github/ci
docker push "$IMAGE"

host:
name: Host tests
needs: ci-image
probe:
name: combined_load hang probe
runs-on: ubuntu-24.04
timeout-minutes: 15
permissions:
contents: read
packages: read
container:
image: ${{ needs.ci-image.outputs.image }}
image: ghcr.io/jetkvm/mini-ci:9393893429bfe333
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
# The managed components as the component manager downloads them, with
# the project's patches applied, which the configure step finds applied.
# CMakeLists.txt registers the patches.
- uses: actions/cache@v4
with:
path: managed_components
key: managed-components-${{ hashFiles('dependencies.lock', 'CMakeLists.txt', 'cmake/apply_managed_component_patch.cmake', 'patches/*.patch', '**/idf_component.yml') }}
- name: Configure the firmware and run the host tests
# The configure step downloads the managed components, applies the
# project's patches and writes the sdkconfig that the firmware tests
# read; a fresh build directory can stop once with "Run the build
# again" (CMakeLists.txt). The tool tests need none of it, so they
# run meanwhile.
- name: Run combined_load 8 times, 4 at a time
shell: bash
run: |
. "$IDF_PATH/export.sh" > /dev/null
tools/run_all_tests.sh tools > tools-tests.log 2>&1 &
tools_tests=$!
# components/web_app refuses to configure without a built UI. The
# host tests do not read it, so a placeholder page is enough here;
# the frontend job builds the real one.
mkdir -p frontend/jetkvm-ui/dist-p4
echo '<!doctype html><title>host tests</title>' > frontend/jetkvm-ui/dist-p4/index.html
failed=0
echo "::group::idf.py reconfigure"
if idf.py -B build-ci reconfigure || idf.py -B build-ci reconfigure; then
echo "::endgroup::"
export SDKCONFIG="$(ls build-ci/sdkconfig.jetkvm-*)"
export JETKVM_TEST_TOOLCHAIN_BIN="$(dirname "$(command -v riscv32-esp-elf-objcopy)")"
tools/run_all_tests.sh firmware || failed=1
else
echo "::endgroup::"
echo "::error::idf.py reconfigure failed"
failed=1
fi
wait "$tools_tests" || failed=1
cat tools-tests.log
exit "$failed"

frontend:
name: UI and e2e suite checks
runs-on: ubuntu-24.04
defaults:
run:
working-directory: frontend/jetkvm-ui
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22.21.1
cache: npm
cache-dependency-path: frontend/jetkvm-ui/package-lock.json
- run: npm ci
env:
HUSKY: 0
# The checks run side by side; each one's output is printed whole when
# all have ended. Lint and the build both write the generated
# localization files, so they run one after the other.
- name: Lint, build, typecheck and unit-test
shell: bash
run: |
checks=(
"npm run lint && npm run build:device -- --outDir dist-p4"
"npx tsc -p tsconfig.e2e.json --noEmit"
"npx oxlint --deny-warnings e2e"
"npx oxfmt --check e2e/mini"
"node --test e2e/helpers/video-freeze.unit.ts"
"node --test tests/upload-eta.mjs"
"node --test tests/display-schedule.mjs"
"node --test tests/connection-diagnosis.mjs"
)
logs="$(mktemp -d)"
pids=()
for i in "${!checks[@]}"; do
bash -c "${checks[$i]}" > "$logs/$i" 2>&1 &
pids+=($!)
done
failed=0
for i in "${!checks[@]}"; do
if wait "${pids[$i]}"; then status=ok; else status=FAIL; failed=1; fi
echo "::group::$status: ${checks[$i]}"
cat "$logs/$i"
echo "::endgroup::"
[ "$status" = ok ] || echo "::error::failed: ${checks[$i]}"
node --version; nproc
export NODE_OPTIONS="--require $PWD/.github/ci-probe/handles.cjs"
run() {
s=$SECONDS
timeout -s KILL 240 node --test tools/combined_load/runner/combined_load.test.mjs > "run$1.log" 2>&1
echo "run $1: exit $? after $((SECONDS - s)) s" >> summary.txt
}
for round in 0 1; do
for k in 1 2 3 4; do run $((round * 4 + k)) & done
wait
done
exit "$failed"
cat summary.txt
for f in run*.log; do echo "::group::$f"; grep -E "^\[handles|^ |^# (tests|pass|fail)|^not ok" "$f"; echo "::endgroup::"; done

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probe loses hang data on failure

High Severity

GitHub Actions bash runs with errexit, so a non-zero timeout returns from run without appending to summary.txt. When every run hangs, cat summary.txt then fails and the step exits before printing the redirected logs that hold the handle dumps.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit fbcc11b. Configure here.

11 changes: 9 additions & 2 deletions tools/run_all_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@
# The suites run side by side, JOBS at a time (default: the number of CPUs),
# the slowest first. Each one has its own TMPDIR, and its output is printed
# whole when it ends, so the log reads as if they ran one after another.
# A suite that runs longer than SUITE_TIMEOUT seconds (default: 300) is
# stopped and fails.
set -uo pipefail

repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$repo_root"
jobs="${JOBS:-$(nproc)}"
suite_timeout="${SUITE_TIMEOUT:-300}"
group="${1:-all}"
case "$group" in
all|tools|firmware) ;;
Expand Down Expand Up @@ -88,7 +91,7 @@ start() {
(
export TMPDIR="$work/tmp.$i"
begun=$SECONDS
bash -c "${commands[$i]}" > "$work/$i.log" 2>&1
timeout --kill-after=10 "$suite_timeout" bash -c "${commands[$i]}" > "$work/$i.log" 2>&1
echo $? > "$work/$i.status"
echo $((SECONDS - begun)) > "$work/$i.seconds"
) &
Expand All @@ -110,8 +113,12 @@ for i in "${!labels[@]}"; do
echo "== ${labels[$i]}"
cat "$work/$i.log"
took="$(cat "$work/$i.seconds" 2>/dev/null) s"
if [ "$(cat "$work/$i.status" 2>/dev/null)" = 0 ]; then
status="$(cat "$work/$i.status" 2>/dev/null)"
if [ "$status" = 0 ]; then
echo "-- ok: ${labels[$i]} ($took)"
elif [ "$status" = 124 ]; then
echo "-- FAIL: ${labels[$i]} (timed out after ${suite_timeout} s)"
failed=1
else
echo "-- FAIL: ${labels[$i]} ($took)"
failed=1
Expand Down
Loading