From 169556b8e6ee2fb2541afcc6b3cd8c6a1b47e3df Mon Sep 17 00:00:00 2001 From: Mark C Ballew Date: Wed, 26 Aug 2026 19:21:17 -0700 Subject: [PATCH 1/7] ci: enable e2e-pipeline job (PrusaSlicer + p2pp + lint + P3 firmware) --- .github/workflows/live-test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/live-test.yml b/.github/workflows/live-test.yml index 4a5fc17..003f118 100644 --- a/.github/workflows/live-test.yml +++ b/.github/workflows/live-test.yml @@ -35,7 +35,6 @@ jobs: e2e-pipeline: name: Slice -> p2pp -> lint -> P3 firmware runs-on: ubuntu-latest - if: false # disabled until Xvfb + Flatpak + Docker runtime is validated steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 From 27a9e62bd88027785bfb3f187333096a5e4939c3 Mon Sep 17 00:00:00 2001 From: Mark C Ballew Date: Wed, 26 Aug 2026 19:28:07 -0700 Subject: [PATCH 2/7] fix(ci): wrap PrusaSlicer in xvfb-run for headless CI --- scripts/e2e_pipeline.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/e2e_pipeline.sh b/scripts/e2e_pipeline.sh index 476a30b..05c1598 100644 --- a/scripts/e2e_pipeline.sh +++ b/scripts/e2e_pipeline.sh @@ -26,7 +26,11 @@ PROCESSED="${OUTDIR}/processed.gcode" # --- stage 1: slice --------------------------------------------------------- echo "==> [1/4] Slicing $(basename "${MODEL}") with ${SLICER}" -"${SLICER}" --export-gcode --load "${CONFIG}" --output "${RAW}" "${MODEL}" +# Flatpak PrusaSlicer needs a display even with QT_QPA_PLATFORM=offscreen — +# wrap in xvfb-run so it works headless in CI. +XVFB_WRAPPER="" +command -v xvfb-run >/dev/null 2>&1 && XVFB_WRAPPER="xvfb-run -a" +${XVFB_WRAPPER} "${SLICER}" --export-gcode --load "${CONFIG}" --output "${RAW}" "${MODEL}" [ -s "${RAW}" ] || { echo "FAIL: slicer produced no G-code" >&2; exit 1; } # p2pp/psconfig.py:160 keys off this string; without it p2pp will not recognise From e3841762fbc486e5771a4cba097f77f0b30f8f06 Mon Sep 17 00:00:00 2001 From: Mark C Ballew Date: Wed, 26 Aug 2026 19:34:51 -0700 Subject: [PATCH 3/7] fix(profile): add use_relative_e_distances=1 (required for wipe tower) --- profiles/prusaslicer/Palette3-cli.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/profiles/prusaslicer/Palette3-cli.ini b/profiles/prusaslicer/Palette3-cli.ini index 64456e5..beee666 100644 --- a/profiles/prusaslicer/Palette3-cli.ini +++ b/profiles/prusaslicer/Palette3-cli.ini @@ -61,6 +61,7 @@ wipe_tower_x = 170 wipe_tower_y = 140 wipe_tower_width = 60 wipe_tower_rotation_angle = 0 +use_relative_e_distances = 1 # --- p2pp configuration ----------------------------------------------------- # Kept in sync with profiles/prusaslicer/Palette3.ini. Deliberately omits From abb930ea80466d4d35ccff0718eb0532805be696 Mon Sep 17 00:00:00 2001 From: Mark C Ballew Date: Wed, 26 Aug 2026 19:41:40 -0700 Subject: [PATCH 4/7] fix: add layer_gcode G92 E0 for relative E + wrap p2pp in xvfb-run --- profiles/prusaslicer/Palette3-cli.ini | 3 +++ scripts/e2e_pipeline.sh | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/profiles/prusaslicer/Palette3-cli.ini b/profiles/prusaslicer/Palette3-cli.ini index beee666..1717f0e 100644 --- a/profiles/prusaslicer/Palette3-cli.ini +++ b/profiles/prusaslicer/Palette3-cli.ini @@ -69,5 +69,8 @@ use_relative_e_distances = 1 # and those directives would make p2pp attempt network I/O. start_gcode = G28 ; home all axes\nG1 Z5 F5000\n;P2PP PALETTE3_PRO\n;P2PP PRINTERPROFILE=0123456789abcdef\n;P2PP LINEARPINGLENGTH=350\n;P2PP SPLICEOFFSET=30\n;P2PP MINSTARTSPLICE=100\n;P2PP MINSPLICE=70\n;P2PP EXTRAENDFILAMENT=200\n;P2PP MATERIAL_DEFAULT_0_0_0\n;P2PP MATERIAL_PLA_PLA_2_1_2 +# Required for use_relative_e_distances=1: reset extruder position each layer +layer_gcode = G92 E0 + # p2pp/psconfig.py:127 parses this block to recover the wipe tower position. end_gcode = ; EXTRA_CONFIG_VARIABLES\n; wipe_tower_x = {wipe_tower_x}\n; wipe_tower_y = {wipe_tower_y}\nM104 S0 ; turn off temperature\nM140 S0\nG28 X0\nM84 \ No newline at end of file diff --git a/scripts/e2e_pipeline.sh b/scripts/e2e_pipeline.sh index 05c1598..df23806 100644 --- a/scripts/e2e_pipeline.sh +++ b/scripts/e2e_pipeline.sh @@ -50,10 +50,11 @@ echo " tool changes in raw G-code: ${TOOLCHANGES}" # --- stage 2: p2pp ---------------------------------------------------------- # NOTE: P2PP.py takes positional args (p2pp/main.py:100-104). There is no -i flag. echo "==> [2/4] Post-processing with p2pp" -XVFB="" -command -v xvfb-run >/dev/null 2>&1 && XVFB="xvfb-run -a" +# p2pp imports GUI modules that use Xlib; wrap in xvfb-run in CI +XVFB2="" +command -v xvfb-run >/dev/null 2>&1 && XVFB2="xvfb-run -a" QT_QPA_PLATFORM="${QT_QPA_PLATFORM:-offscreen}" \ - ${XVFB} python3 "${REPO_ROOT}/P2PP.py" "${RAW}" "${PROCESSED}" + ${XVFB2} python3 "${REPO_ROOT}/P2PP.py" "${RAW}" "${PROCESSED}" [ -s "${PROCESSED}" ] || { echo "FAIL: p2pp produced no output" >&2; exit 1; } # --- stage 3: lint ---------------------------------------------------------- From 1b0aefc76393c809ee19d54f31b26b962e3269f2 Mon Sep 17 00:00:00 2001 From: Mark C Ballew Date: Wed, 26 Aug 2026 19:48:13 -0700 Subject: [PATCH 5/7] fix: tolerate slicer non-zero exit (Xlib crash after G-code written) --- scripts/e2e_pipeline.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/e2e_pipeline.sh b/scripts/e2e_pipeline.sh index df23806..97b6f08 100644 --- a/scripts/e2e_pipeline.sh +++ b/scripts/e2e_pipeline.sh @@ -28,9 +28,11 @@ PROCESSED="${OUTDIR}/processed.gcode" echo "==> [1/4] Slicing $(basename "${MODEL}") with ${SLICER}" # Flatpak PrusaSlicer needs a display even with QT_QPA_PLATFORM=offscreen — # wrap in xvfb-run so it works headless in CI. +# The slicer may crash with Xlib errors after writing G-code (Flatpak sandbox +# cleanup), so don't use set -e for this command. XVFB_WRAPPER="" command -v xvfb-run >/dev/null 2>&1 && XVFB_WRAPPER="xvfb-run -a" -${XVFB_WRAPPER} "${SLICER}" --export-gcode --load "${CONFIG}" --output "${RAW}" "${MODEL}" +${XVFB_WRAPPER} "${SLICER}" --export-gcode --load "${CONFIG}" --output "${RAW}" "${MODEL}" || true [ -s "${RAW}" ] || { echo "FAIL: slicer produced no G-code" >&2; exit 1; } # p2pp/psconfig.py:160 keys off this string; without it p2pp will not recognise From 232dcb45afcf1501e99a46fb9ed1bfb555ca84de Mon Sep 17 00:00:00 2001 From: Mark C Ballew Date: Wed, 26 Aug 2026 19:56:11 -0700 Subject: [PATCH 6/7] fix: Flatpak filesystem access + G-code path fallback --- scripts/e2e_pipeline.sh | 12 ++++++++++++ scripts/install_prusaslicer.sh | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/scripts/e2e_pipeline.sh b/scripts/e2e_pipeline.sh index 97b6f08..adb9b90 100644 --- a/scripts/e2e_pipeline.sh +++ b/scripts/e2e_pipeline.sh @@ -33,6 +33,18 @@ echo "==> [1/4] Slicing $(basename "${MODEL}") with ${SLICER}" XVFB_WRAPPER="" command -v xvfb-run >/dev/null 2>&1 && XVFB_WRAPPER="xvfb-run -a" ${XVFB_WRAPPER} "${SLICER}" --export-gcode --load "${CONFIG}" --output "${RAW}" "${MODEL}" || true + +# Give the filesystem a moment to flush (Flatpak sandbox can be slow) +sleep 2 + +# If the slicer didn't write to the expected path, check /tmp +if [ ! -s "${RAW}" ]; then + echo "WARNING: G-code not at ${RAW}, checking alternatives..." + found=$(find /tmp -name "raw.gcode" -newer "${MODEL}" 2>/dev/null | head -1) + if [ -n "${found}" ]; then + cp "${found}" "${RAW}" + fi +fi [ -s "${RAW}" ] || { echo "FAIL: slicer produced no G-code" >&2; exit 1; } # p2pp/psconfig.py:160 keys off this string; without it p2pp will not recognise diff --git a/scripts/install_prusaslicer.sh b/scripts/install_prusaslicer.sh index 1156657..7c93ca8 100644 --- a/scripts/install_prusaslicer.sh +++ b/scripts/install_prusaslicer.sh @@ -37,8 +37,9 @@ flatpak info "${APP_ID}" | sed -n 's/^ *\(Version\|Commit\|Date\):/\1:/p' # read the model/config out of the workspace and write the G-code back. sudo tee /usr/local/bin/prusa-slicer >/dev/null <<'SHIM' #!/usr/bin/env bash -exec flatpak run --filesystem=host \ +exec flatpak run --filesystem=host --filesystem=/tmp \ --env=QT_QPA_PLATFORM=offscreen \ + --env=DISPLAY="${DISPLAY:-:99}" \ com.prusa3d.PrusaSlicer "$@" SHIM sudo chmod +x /usr/local/bin/prusa-slicer From 76f4efe8c470918662012d284c98ecaf48e4773b Mon Sep 17 00:00:00 2001 From: Mark C Ballew Date: Wed, 26 Aug 2026 20:04:36 -0700 Subject: [PATCH 7/7] fix: mock image_rc module for headless p2pp in CI --- scripts/e2e_pipeline.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/scripts/e2e_pipeline.sh b/scripts/e2e_pipeline.sh index adb9b90..051b431 100644 --- a/scripts/e2e_pipeline.sh +++ b/scripts/e2e_pipeline.sh @@ -64,11 +64,20 @@ echo " tool changes in raw G-code: ${TOOLCHANGES}" # --- stage 2: p2pp ---------------------------------------------------------- # NOTE: P2PP.py takes positional args (p2pp/main.py:100-104). There is no -i flag. echo "==> [2/4] Post-processing with p2pp" -# p2pp imports GUI modules that use Xlib; wrap in xvfb-run in CI +# p2pp imports GUI modules (image_rc, gui) that need Qt/Xlib. +# In headless CI, create a mock image_rc module so p2pp can run without Qt. +MOCK_RC="$(mktemp -d)/image_rc.py" +cat > "${MOCK_RC}" << 'PYEOF' +# Mock Qt resource module for headless p2pp processing +class qInitResources: pass +class qCleanupResources: pass +PYEOF +export PYTHONPATH="${PYTHONPATH:-}:$(dirname "${MOCK_RC}")" +# p2pp.gui also needs to be importable without a display +export QT_QPA_PLATFORM="${QT_QPA_PLATFORM:-offscreen}" XVFB2="" command -v xvfb-run >/dev/null 2>&1 && XVFB2="xvfb-run -a" -QT_QPA_PLATFORM="${QT_QPA_PLATFORM:-offscreen}" \ - ${XVFB2} python3 "${REPO_ROOT}/P2PP.py" "${RAW}" "${PROCESSED}" +${XVFB2} python3 "${REPO_ROOT}/P2PP.py" "${RAW}" "${PROCESSED}" [ -s "${PROCESSED}" ] || { echo "FAIL: p2pp produced no output" >&2; exit 1; } # --- stage 3: lint ----------------------------------------------------------