generated from ali/HarmonyTemplate
244 lines
12 KiB
YAML
244 lines
12 KiB
YAML
name: Set up Haven toolchain
|
|
description: >
|
|
Install and cache the full build toolchain — JDK 17, Android SDK/NDK/CMake,
|
|
Go + gomobile, Rust + cargo-ndk — shared by the CI and Release workflows.
|
|
Everything downloadable is cached; only the toolchain install steps that
|
|
can't be cached (setup-java, setup-android, setup-go) re-run each time,
|
|
but those complete in seconds off the runner image.
|
|
|
|
runs:
|
|
using: composite
|
|
steps:
|
|
# Free ~25GB of preinstalled software we don't use so Android SDK + NDK +
|
|
# Go + Rust + gradle caches fit on the runner disk.
|
|
- name: Free disk space
|
|
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1
|
|
with:
|
|
tool-cache: false
|
|
android: false
|
|
dotnet: true
|
|
haskell: true
|
|
large-packages: true
|
|
docker-images: true
|
|
swap-storage: true
|
|
|
|
- name: Install glibc cross-compilers for wayvnc shim
|
|
shell: bash
|
|
# core/local's buildWayvncShim Gradle task needs glibc-targeted
|
|
# aarch64 + x86_64 C compilers — the wayvnc capture-fallback shim
|
|
# runs inside the proot rootfs alongside glibc-based wayvnc, not
|
|
# on Android. The NDK's bionic libc is incompatible. Same package
|
|
# the F-Droid recipe installs at `sudo apt: gcc-aarch64-linux-gnu`.
|
|
#
|
|
# `libc6-dev-arm64-cross` and `libc6-dev-amd64-cross` ship the
|
|
# multi-arch glibc headers (e.g. bits/wordsize.h that pulls in
|
|
# via features-time64.h on Debian trixie) — the GHA Ubuntu image
|
|
# only has the native-arch libc6-dev, and `jlumbroso/free-disk-space`
|
|
# below strips even more. Without these, the cross gcc fails at
|
|
# compile time with "bits/wordsize.h: No such file or directory".
|
|
run: |
|
|
# The runner image ships packages.microsoft.com apt sources
|
|
# (azure-cli + microsoft-prod) that intermittently serve corrupt
|
|
# InRelease files ("Clearsigned file isn't valid, got 'NOSPLIT'"),
|
|
# failing this unwrapped apt-get update with exit 100 — two CI runs
|
|
# on 2026-07-07 alone. The cross-compilers below come from the
|
|
# Ubuntu archive, so drop the third-party sources instead of
|
|
# letting them flake the build.
|
|
sudo rm -f /etc/apt/sources.list.d/*microsoft* /etc/apt/sources.list.d/azure-cli*
|
|
# apt has NO default network timeout: stalled archive connections
|
|
# hung five jobs 15-30+ min each on 2026-08-19 (the job-level
|
|
# timeout-minutes didn't fire either). Acquire timeouts alone did
|
|
# NOT unstick it — a job hung with them in place, zero output —
|
|
# so every apt call gets a hard timeout(1) wall: a stall becomes
|
|
# a fast, retryable failure instead of a job-cap kill.
|
|
APT_OPTS="-o Acquire::Retries=3 -o Acquire::http::Timeout=30 -o Acquire::https::Timeout=30"
|
|
apt_run() {
|
|
wall="$1"; shift
|
|
for attempt in 1 2 3; do
|
|
sudo timeout -k 30 "$wall" apt-get $APT_OPTS "$@" && return 0
|
|
echo "apt-get $1 failed or timed out (attempt $attempt)"
|
|
pgrep -a 'apt|dpkg' || true
|
|
# The azure mirror stalls mid-download from some runners
|
|
# (2026-08-19: an x64 release job burned 3x600s on it). The
|
|
# runner's ubuntu.sources point at this mirrorlist file, so
|
|
# overwriting it fails over every later fetch to the
|
|
# canonical archive; the bounded update refreshes indexes.
|
|
echo 'http://archive.ubuntu.com/ubuntu/ priority:1' | sudo tee /etc/apt/apt-mirrors.txt
|
|
sudo timeout -k 30 180 apt-get $APT_OPTS update -qq || true
|
|
sleep 5
|
|
done
|
|
echo "apt-get $1 failed after 3 attempts"
|
|
return 1
|
|
}
|
|
apt_run 180 update -qq
|
|
apt_run 600 install -y --no-install-recommends \
|
|
gcc-aarch64-linux-gnu libc6-dev-arm64-cross \
|
|
gcc-x86-64-linux-gnu libc6-dev-amd64-cross \
|
|
gcc-arm-linux-gnueabihf libc6-dev-armhf-cross \
|
|
meson ninja-build pkg-config bison \
|
|
autoconf automake libtool libtool-bin libltdl-dev \
|
|
libexpat1-dev libffi-dev xutils-dev python3-xcbgen \
|
|
nasm yasm gperf
|
|
|
|
# The second group above is what core/wayland's buildWaylandNatives needs
|
|
# (#493). Those five binaries are cross-compiled from the wayland-android
|
|
# submodule through meson/ninja, with wayland-scanner, xcb-proto and
|
|
# libxcb's autotools chain in the middle — none of which the GHA runner
|
|
# image carries. F-Droid's recipe installs the same set in its `sudo:`
|
|
# block, which is why their builds worked while ours had never tried.
|
|
#
|
|
# nasm/yasm are for x264 inside core/ffmpeg's buildFfmpegNatives, and are
|
|
# needed by the x86_64 ABI only — aarch64 and armv7 assemble through the
|
|
# NDK's own toolchain, x86_64 does not. That asymmetry is why this was
|
|
# missed: `ci.yml` builds arm64 alone, so the first thing ever to compile
|
|
# x264 for x86_64 was the v5.86.36 release matrix, which failed with
|
|
# "Found no assembler / Minimum version is nasm-2.13". F-Droid's `sudo:`
|
|
# list had both all along — treat that list as the spec.
|
|
#
|
|
# Kept in one apt-get with the cross-compilers on purpose: a second
|
|
# `apt-get update` is another chance to hit the flaky third-party sources
|
|
# dropped above.
|
|
|
|
- name: Set up JDK 17
|
|
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
|
|
with:
|
|
java-version: '21'
|
|
distribution: 'temurin'
|
|
|
|
- name: Set up Android SDK
|
|
uses: android-actions/setup-android@40fd30fb8d7440372e1316f5d1809ec01dcd3699 # v4.0.1
|
|
with:
|
|
# Default is "tools platform-tools"; the legacy `tools` package pulls
|
|
# the Android Emulator, whose CDN zip served corrupt twice on
|
|
# 2026-07-07 ("Error reading Zip content from a SeekableByteChannel"),
|
|
# failing setup before any code ran. Nothing in CI or Release uses the
|
|
# emulator or legacy tools — Gradle provisions build-tools/platforms
|
|
# itself via the accepted licenses.
|
|
packages: platform-tools
|
|
|
|
# Only install the NDK we pin in per-module ndkVersion
|
|
# (core/local + termlib/lib: 29.0.14206865, r29 stable). F-Droid's
|
|
# buildserver no longer pre-installs NDKs in the Docker image —
|
|
# fdroidserver.common.auto_install_ndk fetches whatever the
|
|
# manifest's ndk: field requests via sdkmanager on demand. Bumped
|
|
# off r28c (28.2.13676358) once Google moved that to the
|
|
# unsupported list (GlassHaven/Haven#77).
|
|
- name: Install SDK platforms 36+37, CMake, and NDK
|
|
shell: bash
|
|
run: sdkmanager "platforms;android-36" "platforms;android-37.0" "cmake;3.31.6" "ndk;29.0.14206865"
|
|
|
|
- name: Set up Go toolchain
|
|
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
|
|
with:
|
|
go-version: '1.26'
|
|
cache-dependency-path: rclone-android/go/go.sum
|
|
|
|
# gomobile + gobind get re-downloaded + recompiled on every clean run
|
|
# (~1m). Cache the installed binaries in ~/go/bin keyed on the Go
|
|
# version so repeat runs skip the `go install`.
|
|
- name: Cache gomobile binaries
|
|
id: gomobile-cache
|
|
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
|
|
with:
|
|
path: |
|
|
~/go/bin/gomobile
|
|
~/go/bin/gobind
|
|
key: gomobile-${{ runner.os }}-go1.26-mobile20251021151156
|
|
|
|
- name: Install gomobile
|
|
if: steps.gomobile-cache.outputs.cache-hit != 'true'
|
|
shell: bash
|
|
# Pin gomobile/gobind to the golang.org/x/mobile pseudo-version recorded
|
|
# in rclone-android/go/go.sum so the binding generator that produces the
|
|
# shipped libgojni.so can't drift on a `@latest` resolve. Bump this in
|
|
# lockstep with the go.sum entry (and the gomobile-cache key above).
|
|
run: |
|
|
go install golang.org/x/mobile/cmd/gomobile@v0.0.0-20251021151156-188f512ec823
|
|
go install golang.org/x/mobile/cmd/gobind@v0.0.0-20251021151156-188f512ec823
|
|
|
|
# fetchTessdata pulls ~4 MB from GitHub raw on every clean run, and
|
|
# shared runner IPs get rate-limited there (HTTP 429 killed a CI run).
|
|
# Restore the file from cache so the task's checksum check short-circuits
|
|
# the download; keyed on the build script so a version/SHA bump refetches.
|
|
- name: Cache tessdata
|
|
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
|
|
with:
|
|
path: core/scan/src/main/assets/tessdata
|
|
key: tessdata-${{ hashFiles('core/scan/build.gradle.kts') }}
|
|
|
|
# Tool-version pins below match fdroiddata's sh.haven.app.yml recipe —
|
|
# the F-Droid buildserver is the authoritative environment (failing
|
|
# there blocks the public release), so our CI mirrors its versions
|
|
# rather than drifting ahead on `stable`. Update both places together.
|
|
#
|
|
# Rust note: the rdp-kotlin/rust build is governed by that crate's
|
|
# rust-toolchain.toml (channel 1.94.1), which overrides the rustup default
|
|
# below. We set the same version here so the global default and the
|
|
# crate-scoped toolchain agree. 1.94 is a hard floor, not a preference:
|
|
# the IronRDP crates are pinned to git and upstream's workspace
|
|
# `rust-version` is 1.94 (Devolutions/IronRDP#1495), so cargo refuses to
|
|
# build them on anything older. F-Droid's recipe still does
|
|
# `rustup default 1.85.0`, but its rdp build also obeys the toml — align
|
|
# it to 1.94.1 in a follow-up for clarity.
|
|
- name: Cache cargo-ndk
|
|
id: cargo-ndk-cache
|
|
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
|
|
with:
|
|
path: ~/.cargo/bin/cargo-ndk
|
|
key: cargo-ndk-${{ runner.os }}-3.5.4
|
|
|
|
- name: Set up Rust toolchain + cargo-ndk
|
|
shell: bash
|
|
run: |
|
|
rustup default 1.94.1
|
|
# Install every Android target up front (single-threaded). Leaving armv7
|
|
# to the crates' rust-toolchain.toml `targets` auto-install let the
|
|
# parallel rdp+spice cargo builds race to install rust-std-armv7 and hit
|
|
# `detected conflict: …/rustlib/armv7-linux-androideabi/lib/…rlib`.
|
|
rustup target add aarch64-linux-android x86_64-linux-android armv7-linux-androideabi
|
|
if [ ! -x ~/.cargo/bin/cargo-ndk ]; then
|
|
cargo install cargo-ndk --locked --version 3.5.4
|
|
fi
|
|
|
|
- name: Cache Gradle packages
|
|
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
|
|
with:
|
|
path: |
|
|
~/.gradle/caches
|
|
~/.gradle/wrapper
|
|
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', '**/libs.versions.toml') }}
|
|
restore-keys: gradle-${{ runner.os }}-
|
|
|
|
# Gradle build cache (org.gradle.caching) — the task-output store that lets
|
|
# test/lint/build/r8 stop each recompiling the whole tree. It MUST have a
|
|
# rolling key: the dependency cache above is keyed on hashFiles, which is
|
|
# stable across the many commits that don't touch build files, so its
|
|
# snapshot of build-cache-1 freezes at first-populate and never picks up
|
|
# later Kotlin changes. A run_id-suffixed key saves a fresh entry every run
|
|
# and restore-keys falls back to the newest prior one — so it accumulates.
|
|
# Restored after (and so wins over) the frozen copy inside the dep cache.
|
|
- name: Cache Gradle build cache (task outputs)
|
|
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
|
|
with:
|
|
path: ~/.gradle/caches/build-cache-1
|
|
# v2 prefix bumped 2026-08-29: a corrupted task-output entry (mangled
|
|
# values-fr intermediate -> aapt2 "Invalid unicode escape sequence")
|
|
# was being restored by the old prefix on every run.
|
|
key: gradle-buildcache-v2-${{ runner.os }}-${{ github.run_id }}
|
|
restore-keys: gradle-buildcache-v2-${{ runner.os }}-
|
|
|
|
- name: Cache Cargo registry + rdp-kotlin target
|
|
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
|
|
with:
|
|
path: |
|
|
~/.cargo/registry
|
|
~/.cargo/git
|
|
rdp-kotlin/rust/target
|
|
prns/prns-host/abi/c/target
|
|
key: cargo-${{ runner.os }}-${{ hashFiles('rdp-kotlin/rust/Cargo.lock', 'prns/prns-host/abi/c/Cargo.lock') }}
|
|
restore-keys: cargo-${{ runner.os }}-
|
|
|
|
- name: Grant execute permission for gradlew
|
|
shell: bash
|
|
run: chmod +x gradlew
|