From 89c63d222bc71efd9d1396183a54cdb979af5f54 Mon Sep 17 00:00:00 2001 From: Rafal Chlodnicki Date: Sat, 26 Sep 2026 18:01:03 +0200 Subject: [PATCH 1/2] Run native ST build on arm64 host when using docker --- docker/README.md | 14 +++++++++----- docker/entrypoint.sh | 32 ++++++++++++++++++++++++++++++++ docker/ut-run-tests | 3 ++- sbin/install_sublime_text.sh | 9 ++++++--- 4 files changed, 49 insertions(+), 9 deletions(-) mode change 100644 => 100755 docker/ut-run-tests diff --git a/docker/README.md b/docker/README.md index c55e549b..c623c7ed 100644 --- a/docker/README.md +++ b/docker/README.md @@ -123,9 +123,13 @@ ut-run-tests . --color always ## Run a single test file ```sh -docker run --rm -it \ - -e PACKAGE=$PACKAGE \ - -v $PWD:/project \ - -v unittesting-home:/root \ - unittesting-local run_tests --tests-dir tests --pattern test_example.py +ut-run-tests . --file tests/test_example.py ``` + +## ARM hosts (Apple Silicon, arm64 Linux) + +On an ARM host, the launcher builds and runs a native arm64 image. The +container installs the arm64 build of Sublime Text 4. + +Runs under amd64 emulation (for example `DOCKER_DEFAULT_PLATFORM=linux/amd64`) +are not supported. diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 05dfa2d6..9dabaf2b 100644 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -1,6 +1,7 @@ #!/bin/bash echo PACKAGE = $PACKAGE +echo ARCHITECTURE = $(uname -m) set -e @@ -84,6 +85,37 @@ write_package_dependency_marker() { printf '%s\n' "$dependency_fingerprint" > "$DEPENDENCY_MARKER_DIR/$PACKAGE.sha256" } +ensure_sublime_text_arch_matches() { + # A cache volume created on a different architecture holds a Sublime Text + # binary that cannot run here, and the bootstrap marker skips reinstall. + local binary="$HOME/sublime_text/sublime_text" + [ -f "$binary" ] || return 0 + + local expected + case "$(uname -m)" in + x86_64) expected=3e ;; + aarch64) expected=b7 ;; + *) return 0 ;; + esac + + # e_machine field of the ELF header (low byte, little-endian). + local actual + actual=$(od -An -tx1 -j18 -N1 "$binary" | tr -d ' \n') + if [ "$actual" != "$expected" ]; then + local found + case "$actual" in + 3e) found=x86_64 ;; + b7) found=aarch64 ;; + *) found="unknown (ELF machine 0x$actual)" ;; + esac + echo "Error: the cache volume has a Sublime Text build for $found," >&2 + echo "but this container runs on $(uname -m)." >&2 + echo "Run ut-run-tests with --refresh-cache, or use a different cache volume." >&2 + exit 1 + fi +} + +ensure_sublime_text_arch_matches sudo sh -e /etc/init.d/xvfb start ensure_git_identity ensure_ci_platform_compat diff --git a/docker/ut-run-tests b/docker/ut-run-tests old mode 100644 new mode 100755 index 6a857f7f..eb467e75 --- a/docker/ut-run-tests +++ b/docker/ut-run-tests @@ -2,4 +2,5 @@ set -euo pipefail SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" -exec python "$SCRIPT_DIR/run_tests.py" "$@" +PYTHON="$(command -v python3 || command -v python)" +exec "$PYTHON" "$SCRIPT_DIR/run_tests.py" "$@" diff --git a/sbin/install_sublime_text.sh b/sbin/install_sublime_text.sh index 604786b1..5341a718 100644 --- a/sbin/install_sublime_text.sh +++ b/sbin/install_sublime_text.sh @@ -28,10 +28,13 @@ if [ -z $SUBLIME_TEXT_VERSION ]; then fi if [ -z $SUBLIME_TEXT_ARCH ]; then - SUBLIME_TEXT_ARCH=x64 + case "$(uname -m)" in + aarch64|arm64) SUBLIME_TEXT_ARCH=arm64 ;; + *) SUBLIME_TEXT_ARCH=x64 ;; + esac fi -if [ $SUBLIME_TEXT_VERSION -ge 4 ] && [ "$SUBLIME_TEXT_ARCH" != "x64" ]; then +if [ $SUBLIME_TEXT_VERSION -ge 4 ] && [ "$SUBLIME_TEXT_ARCH" != "x64" ] && [ "$SUBLIME_TEXT_ARCH" != "arm64" ]; then echo "wrong value of $SUBLIME_TEXT_ARCH for Sublime Text version $SUBLIME_TEXT_VERSION" exit 1 fi @@ -132,7 +135,7 @@ else echo "installing sublime text $SUBLIME_TEXT_VERSION" for i in {1..20}; do if [ $SUBLIME_TEXT_VERSION -ge 4 ]; then - URL=$(curl -s "$STWEB" | sed -n 's/.*href="\([^"]*_x64\.tar\.xz\)".*/\1/p') + URL=$(curl -s "$STWEB" | sed -n "s/.*href=\"\([^\"]*_${SUBLIME_TEXT_ARCH}\.tar\.xz\)\".*/\1/p") else if [ "$SUBLIME_TEXT_ARCH" = "x64" ]; then URL=$(curl -s "$STWEB" | sed -n 's/.*href="\([^"]*x64\.tar\.bz2\)".*/\1/p') From aad45584646a3fa350b0d58872ceddab38511e19 Mon Sep 17 00:00:00 2001 From: Rafal Chlodnicki Date: Sat, 26 Sep 2026 18:58:08 +0200 Subject: [PATCH 2/2] revert manual testing docs --- docker/README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docker/README.md b/docker/README.md index 7513becf..733d930b 100644 --- a/docker/README.md +++ b/docker/README.md @@ -148,7 +148,11 @@ docker run --rm -it \ Run a single test file ```sh -ut-run-tests . --file tests/test_example.py +docker run --rm -it \ + -e PACKAGE=$PACKAGE \ + -v $PWD:/project \ + -v unittesting-home:/root \ + unittesting-local run_tests --tests-dir tests --pattern test_example.py ``` ## ARM hosts (Apple Silicon, arm64 Linux)