Skip to content
Merged
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
8 changes: 8 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,11 @@ docker run --rm -it \
-v unittesting-home:/root \
unittesting-local run_tests --tests-dir tests --pattern 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.
32 changes: 32 additions & 0 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash

echo PACKAGE = $PACKAGE
echo ARCHITECTURE = $(uname -m)

set -e

Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion docker/ut-run-tests
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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" "$@"
9 changes: 6 additions & 3 deletions sbin/install_sublime_text.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')
Expand Down
Loading