2424 - ' scripts/tests/**'
2525 - ' .github/workflows/kotlin-sdk-build.yml'
2626
27+ permissions :
28+ contents : read
29+
2730concurrency :
2831 group : kotlin-sdk-${{ github.workflow }}-${{ github.head_ref || github.ref }}
2932 cancel-in-progress : true
3033
3134jobs :
3235 kotlin-sdk-build :
3336 name : Kotlin SDK build + tests (x86_64 emulator)
34- runs-on : ubuntu-latest
37+ runs-on : [self-hosted, kotlin-ci]
38+ # Fork PRs must not execute on a persistent runner. Keep this guard in sync
39+ # with tests-rs-workspace.yml.
40+ if : >-
41+ github.event_name != 'pull_request'
42+ || github.event.pull_request.head.repo.full_name == github.repository
43+ || github.event.pull_request.head.repo.owner.login == 'thepastaclaw'
3544 timeout-minutes : 120
3645
3746 steps :
3847 - name : Checkout repository
3948 uses : actions/checkout@v4
49+ with :
50+ # Preserve target/ and other untracked build outputs between runs.
51+ clean : false
52+
53+ - name : Ensure runner dependencies
54+ run : |
55+ set -euo pipefail
56+
57+ MISSING=()
58+ for pkg in build-essential cmake curl jq libgmp-dev libpulse0 libssl-dev libx11-xcb1 pkg-config python3 unzip zip; do
59+ dpkg -s "$pkg" >/dev/null 2>&1 || MISSING+=("$pkg")
60+ done
61+ if [ ${#MISSING[@]} -gt 0 ]; then
62+ echo "Installing: ${MISSING[*]}"
63+ sudo apt-get update -qq
64+ sudo apt-get install -qq --yes "${MISSING[@]}"
65+ fi
66+
67+ if [ ! -x "$HOME/.cargo/bin/rustup" ]; then
68+ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
69+ | sh -s -- -y --no-modify-path --default-toolchain none
70+ fi
71+ echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
4072
4173 - name : Validate executable SDK parity manifest
4274 run : |
4375 python3 scripts/check_sdk_parity_manifest.py
4476 python3 -m unittest discover -s scripts/tests -p 'test_*.py'
4577
46- - name : Free disk space
78+ - name : Verify JDK 17
4779 run : |
48- # The API-35 x86_64 system image + the shielded .so's cargo target
49- # dir (halo2/Orchard) + gradle outputs overflow the ~21 GB free on
50- # the runner root fs, surfacing as "No space left on device" during
51- # system-image install (the emulator then never boots). Reclaim the
52- # large preinstalled toolchains we don't use before building. None of
53- # these are needed by this job (JDK via setup-java, Android SDK via
54- # setup-android, Rust via rustup, NDK reinstalled below).
55- echo "Before:"; df -h /
56- sudo rm -rf \
57- /usr/share/dotnet \
58- /usr/local/.ghcup \
59- /opt/ghc \
60- /opt/hostedtoolcache/CodeQL \
61- /usr/local/lib/android/sdk/ndk \
62- /usr/local/share/powershell \
63- /usr/share/swift \
64- /opt/microsoft 2>/dev/null || true
65- sudo docker image prune --all --force 2>/dev/null || true
66- echo "After:"; df -h /
67-
68- - name : Set up JDK 17
69- uses : actions/setup-java@v4
70- with :
71- distribution : temurin
72- java-version : ' 17'
80+ JAVA_HOME_RESOLVED=$(dirname "$(dirname "$(readlink -f "$(command -v java)")")")
81+ JAVA_VERSION_OUTPUT=$("$JAVA_HOME_RESOLVED/bin/java" -version 2>&1)
82+ printf '%s\n' "$JAVA_VERSION_OUTPUT"
83+ printf '%s\n' "$JAVA_VERSION_OUTPUT" | grep -Eq 'version "17([.]|\")'
84+ echo "JAVA_HOME=$JAVA_HOME_RESOLVED" >> "$GITHUB_ENV"
85+ echo "$JAVA_HOME_RESOLVED/bin" >> "$GITHUB_PATH"
7386
7487 - name : Set up Android SDK
7588 uses : android-actions/setup-android@v3
@@ -85,25 +98,30 @@ jobs:
8598 with :
8699 targets : x86_64-linux-android
87100
88- - name : Restore cargo cache
89- uses : actions/cache@v4
90- with :
91- path : |
92- ~/.cargo/registry
93- ~/.cargo/git
94- target
95- key : kotlin-sdk-cargo-${{ hashFiles('**/Cargo.lock') }}
96- restore-keys : |
97- kotlin-sdk-cargo-
98-
99- - name : Install cargo-ndk
100- run : cargo install cargo-ndk --locked
101-
102- - name : Install protoc v32.0 (repo-standard; apt's 3.21 breaks tenderdash-proto)
101+ # Pinned: this runner is persistent, so an unpinned `cargo install`
102+ # leaves whatever version happened to be current on the day it first ran,
103+ # and every later job silently builds with it. Assert after installing so
104+ # a drifted host fails here instead of somewhere in the NDK build.
105+ - name : Ensure cargo-ndk v4.1.2 is installed
106+ run : |
107+ set -euo pipefail
108+ if ! cargo ndk --version 2>/dev/null | grep -qx 'cargo-ndk 4.1.2'; then
109+ cargo install cargo-ndk --version 4.1.2 --locked --force
110+ fi
111+ cargo ndk --version
112+ cargo ndk --version | grep -qx 'cargo-ndk 4.1.2'
113+
114+ - name : Ensure protoc v32.0 is installed (repo-standard; apt's 3.21 breaks tenderdash-proto)
103115 run : |
104- curl -fsSL -o /tmp/protoc.zip https://github.com/protocolbuffers/protobuf/releases/download/v32.0/protoc-32.0-linux-x86_64.zip
105- sudo unzip -o /tmp/protoc.zip -d /usr/local 'bin/protoc' 'include/*'
116+ set -euo pipefail
117+ if ! protoc --version 2>/dev/null | grep -qx 'libprotoc 32.0'; then
118+ curl -fsSL -o /tmp/protoc.zip https://github.com/protocolbuffers/protobuf/releases/download/v32.0/protoc-32.0-linux-x86_64.zip
119+ sudo unzip -o /tmp/protoc.zip -d /usr/local 'bin/protoc' 'include/*'
120+ fi
106121 protoc --version
122+ # A stale protoc earlier on PATH would shadow the one just unpacked
123+ # into /usr/local; catch that here rather than in a codegen failure.
124+ protoc --version | grep -qx 'libprotoc 32.0'
107125
108126 - name : Build native library (x86_64, dev profile)
109127 working-directory : packages/kotlin-sdk
@@ -126,12 +144,12 @@ jobs:
126144 working-directory : packages/kotlin-sdk
127145 run : ./gradlew :sdk:compileDebugAndroidTestKotlin --stacktrace
128146
129- - name : Enable KVM for emulator
147+ - name : Verify KVM access
130148 run : |
131- echo 'KERNEL=="kvm", GROUP=" kvm", MODE="0666", OPTIONS+="static_node=kvm"' \
132- | sudo tee /etc/udev/rules.d/99-kvm4all.rules
133- sudo udevadm control --reload-rules
134- sudo udevadm trigger --name-match= kvm
149+ test -c /dev/ kvm
150+ test -r /dev/kvm
151+ test -w /dev/kvm
152+ ls -l /dev/ kvm
135153
136154 - name : Run instrumented FFI smoke test (API 35 emulator)
137155 uses : reactivecircus/android-emulator-runner@v2
0 commit comments