name: CI on: push: branches: [ main ] pull_request: branches: [ main ] # Nightly broad net: full lint, the R8 smoke, and an all-ABI build — the # slow/low-per-commit-signal work pulled off every main push (below) still # runs within 24h, so a lint regression or an x64/armv7-specific breakage # the arm64-only per-push build would miss is caught daily. schedule: - cron: '0 3 * * *' # 03:00 UTC daily workflow_dispatch: concurrency: # Event-scoped so a main push doesn't cancel an in-flight nightly (both # resolve github.ref to refs/heads/main and would otherwise collide). group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} cancel-in-progress: true # Least-privilege floor. Every job here only reads the repo and uploads # artifacts (which use the Actions runtime token, not GITHUB_TOKEN), so a # read-only token is sufficient. Jobs needing more would declare their own. permissions: contents: read jobs: # Fast supply-chain guards — no toolchain, runs in parallel with the build # jobs and fails the run early if hardening regresses. supply-chain: runs-on: ubuntu-latest timeout-minutes: 5 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: submodules: false # Every external action must be pinned to a 40-char commit SHA. A bare # `@v1`/`@main`/`@master` ref is mutable and re-pointable (tj-actions # CVE-2025-30066 class). Local `./.github/actions/*` refs are exempt. - name: Assert external actions are SHA-pinned run: | if grep -rEn 'uses: [^.].+@(v[0-9]|main|master)' .github/workflows .github/actions; then echo "::error::Unpinned external action ref(s) above — pin to a 40-char SHA (# vX.Y.Z)." exit 1 fi # A submodule here is not vendored data. settings.gradle.kts pulls # several in with includeBuild(), so their own build.gradle.kts files are # EXECUTED on this runner — the URL in .gitmodules decides whose build # logic runs with CI's privileges. # # Not hypothetical: PR #589 repointed termlib at a contributor's fork so # CI could fetch a review SHA, and every job went green while building # it. The checkmarks vouching for that PR were produced by executing the # unreviewed code they were vouching for. Pinning the SHA keeps the # content honest — git is content-addressed, so nobody can swap what is # at a given commit — but it does not make the source ours. # # The registration is also sticky: `git submodule init` will not # overwrite a URL a checkout already has, so a repoint outlives the # commit that introduced it. That is how #525 froze F-Droid's build # channel for a day while every build of ours stayed green. - name: Assert submodules point at first-party repos run: | foreign=$(git config -f .gitmodules --get-regexp '\.url$' \ | grep -vE ' https://github\.com/GlassOnTin/' || true) if [ -n "$foreign" ]; then echo "$foreign" echo "::error::Submodule URL(s) above are not under github.com/GlassOnTin. A submodule's build scripts execute on this runner; merge the commit into our fork and point at that SHA instead." exit 1 fi # Validate the gradle-wrapper.jar that CI actually executes against # Gradle's published checksums (wrapper-attack class). Submodule wrappers # aren't executed by CI, so the root jar is the one that matters. - name: Validate Gradle wrapper uses: gradle/actions/wrapper-validation@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0 # rdp-kotlin's Rust suite had no CI step at all, so it was gated by whoever # last remembered to run it by hand. Not hypothetical: the #422 test # asserting an under-declared totalLength must *not* decode kept asserting it # after the IronRDP pin moved to make it decode, and stayed green-by-absence # until someone ran it locally. # # Its own job rather than a step in `test`: that job already runs 14-30m # against a 45m cap and has been stamped `cancelled` once for finishing two # seconds late (see its comment), so it is the wrong place to add minutes. # This needs no submodules, no NDK and no Gradle, so standalone it is cheap # and runs in parallel. rdp-rust-test: runs-on: ubuntu-latest timeout-minutes: 20 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: submodules: false # No toolchain setup step: rdp-kotlin/rust/rust-toolchain.toml pins the # channel and rustup installs it on first use. That file is also why this # runs from the crate directory rather than with --manifest-path from the # root — rustup resolves the toolchain from the working directory, so the # root would silently get the runner's default rustc, which IronRDP's # rust-version then rejects. - name: Run RDP transport Rust tests working-directory: rdp-kotlin/rust run: cargo test # Prns C-ABI capsule tests on the host toolchain. Scoped to the detached # abi/c workspace (its own committed Cargo.lock) — the full upstream # workspace carries embedded targets this runner can't build. prns-rust-test: runs-on: ubuntu-latest timeout-minutes: 20 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: submodules: false - name: Checkout prns submodule run: git submodule update --init prns - name: Run Prns capsule tests working-directory: prns/prns-host/abi/c run: cargo test # Host-built proot exercising the link2symlink emulation: refcounts, # PROOT_L2S_DIR payload relocation (the Nix/libgit2 tarball-cache # durability fix, discussion #536), and broken-chain fail-soft. Runs on # the host kernel — ptrace works on GitHub runners; no Android needed. proot-l2s-test: runs-on: ubuntu-latest timeout-minutes: 15 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: submodules: false - name: Checkout proot submodule run: git submodule update --init build-proot/proot-termux - name: Install talloc, busybox, and lld # gcc-multilib: the x86_64 build also compiles a 32-bit loader # (HAS_LOADER_32BIT) and needs the i386 libc headers. # # Bounded like setup-toolchain's apt step: apt has no default # network timeout, and this exact step sat stalled until the # 15-minute job cap killed it TWICE on 2026-08-19 (runs # 32233158153, 32236122541) — the second time WITH Acquire # timeouts in place and zero output, so a hard timeout(1) wall # per attempt is what actually bounds it. run: | 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 # Fail over to the canonical archive when the azure mirror # stalls (see setup-toolchain for the incident detail). 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 -qq libtalloc-dev busybox-static clang lld gcc-multilib # clang+lld, not gcc+GNU-ld: the loader's hardcoded --rosegment is an # LLD flag (the production NDK toolchain is clang+lld too) and older # GNU ld rejects it. - name: Build host proot run: make -C build-proot/proot-termux/src proot CC="clang -fuse-ld=lld" - name: Run link2symlink tests run: | cd build-proot/proot-termux/tests for t in test-l2s-refcount.sh test-l2s-dir.sh test-l2s-broken-chain.sh test-l2s-guest-dir.sh; do echo "=== $t" env PROOT="$PWD/../src/proot" sh -e "$t" done # Three independent Gradle entry-points run as parallel jobs instead of # sequentially in one. Each restores the shared toolchain + caches from # the composite action; the second run of each job type reuses the cache # populated by the first, so the duplicated cache-restore cost is minimal. test: runs-on: ubuntu-latest # 45, not 30: on 4e06876c this job did 30m07s of real work against a 30m # cap and was stamped `cancelled` two seconds into cleanup — with every # step green and "BUILD SUCCESSFUL in 15m 14s" already in the log. That # reads as a red main for a run that actually passed. The spend is # genuine, not a hang: ~10.5m initialising submodules (the wayland tree # alone is a dozen nested repos), ~3.5m toolchain, ~15m tests. Observed # totals range 14m-30m depending on Gradle cache hits, so the cap has to # clear the top of that spread, not sit on it. Cutting the submodule cost # is the real fix; this stops it failing releases meanwhile. timeout-minutes: 45 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: submodules: false - uses: ./.github/actions/init-submodules-with-retry - uses: ./.github/actions/setup-toolchain - name: Run unit tests # :app uses ABI product flavors, so the unqualified `testDebugUnitTest` # matches no :app task and silently skips the agent/MCP unit tests. # Name the flavor task explicitly (arm64 only — unit tests are # flavor-agnostic) so they actually run in CI. # # The sshlib contract tests are excluded here and run in their own # non-gating step below. They exercise the opt-in preview SSH engine # against an upstream race in sshlib 0.4.1 — its output pump is # cancelled on CHANNEL_CLOSE and drops whatever it is still holding, so # a command's stdout or stderr comes back empty or truncated at random # (connectbot/cbssh#245, tracked in #448). Haven narrows the window but # cannot close it from outside the library, and 0.4.1 is the latest # release. Three failures in one day, on three different assertions, # blocked a release that changed nothing in core/ssh — so this engine's # known flakiness no longer gates shipping for the default JSch engine. # Restore it here the moment a fixed sshlib is out. run: >- ./gradlew testDebugUnitTest :app:testArm64FullDebugUnitTest -PexcludeSshlibContractTests=true -PskipWaylandNatives=true -PskipFfmpegNatives=true - name: Run sshlib contract tests (non-gating, connectbot/cbssh#245) # Reported, never silent: a failure here is visible in the job summary # and the uploaded results, it just does not fail the build. If these # start failing *every* run rather than intermittently, that is a real # regression and not the upstream race — check before dismissing it. # # That last sentence used to be the reader's job. Since #475 the # test-retry plugin gives SshlibExecContractTest three attempts (and # only that class — verified by making a test in another core:ssh class # fail and watching it run once), so a red step here already means # "failed three times in a row" rather than "flaked once". The signal # is now worth acting on instead of squinting at. continue-on-error: true run: ./gradlew :core:ssh:testDebugUnitTest --tests 'sh.haven.core.ssh.sshlib.*' -PskipWaylandNatives=true -PskipFfmpegNatives=true - name: Upload test results if: always() uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 with: name: test-results path: '**/build/reports/tests/' retention-days: 14 # Fast source-level gates — no Android toolchain, no submodules, ~30s. Split # out of the lint job so they keep running on EVERY push (a version bump # without CHANGELOG notes, a hardcoded string, or stale i18n export must fail # fast) even though the slow lintDebug moved to PR + nightly. checks: runs-on: ubuntu-latest timeout-minutes: 5 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: submodules: false - name: Check CHANGELOG has notes for the current version run: ./scripts/check-changelog.sh - name: Check for hardcoded UI strings (#210) run: ./scripts/check-i18n-hardcoded.sh - name: Check every English key exists in all 11 locales # Android's MissingTranslation lint is downgraded to a warning in # build.gradle.kts and lintDebug only runs on PRs, so direct pushes to # main used to ship untranslated keys silently — 37 keys had drifted out # of all 11 locales at once. This runs per-push instead. run: python3 scripts/check-i18n-coverage.py # check-native-libs.sh is NOT here: this job does not build, and since # #493 stopped committing the wayland .so there is nothing for it to read # at this point. It printed "does not exist; nothing to check" on every # run — a gate reporting success for doing nothing. It now runs in `build`, # after the binaries exist. - name: Check no new binaries are committed # Binaries are unauditable in review and go stale silently (#469). # Blocks any NEW one; the pre-existing set is grandfathered in the # script and that list can only shrink. run: ./scripts/check-no-committed-binaries.sh - name: Check translation export is current # docs/i18n/strings.json feeds the Pages translation page. Regenerate # and fail if it drifted from the strings.xml sources (rerun # scripts/i18n_export.py and commit the result). run: | python3 scripts/i18n_export.py git diff --exit-code docs/i18n/strings.json # Full Android lint is slow (~13 min) and rarely catches a per-commit # regression the tests don't — so it runs on PRs and the nightly schedule, # not on every direct main push. The fast source gates above still run # per-push. github.event_name is 'push' only for direct main pushes. lint: if: github.event_name != 'push' runs-on: ubuntu-latest timeout-minutes: 30 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: submodules: false - uses: ./.github/actions/init-submodules-with-retry - uses: ./.github/actions/setup-toolchain - name: Run lint # Skip the from-source native builds. Android lint analyses sources, # resources and the manifest — it never opens a .so. Since #493 wired # those builds into preBuild they were costing this job ~20 minutes it # had no use for, and lint died on its own 30-minute timeout three # nights running without ever reaching the lint step (the log ends # inside clang++). A job killed by a timeout reports `cancelled`, which # reads as "superseded" — so the nightly lint gate stopped producing a # verdict and nothing said so. run: ./gradlew lintDebug -PskipWaylandNatives=true -PskipFfmpegNatives=true - name: Upload lint results if: always() uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 with: name: lint-results path: | **/build/reports/lint-results-debug.html **/build/reports/lint-results-debug.xml if-no-files-found: ignore retention-days: 14 build: runs-on: ubuntu-latest timeout-minutes: 60 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: submodules: false - uses: ./.github/actions/init-submodules-with-retry - uses: ./.github/actions/setup-toolchain # Build arm64 only in CI — the x64 flavor exists for emulator support # and Play Store fat distribution, not smoke-testing main. Cuts build # work roughly in half vs :app:assembleDebug (which expands to both). - name: Build arm64 debug APK # -PtargetAbi drives core/wayland's buildWaylandNatives, which builds the # five arm64-only wayland binaries from the submodule instead of shipping # committed copies. This job is what proves they still compile (#493). run: ./gradlew :app:assembleArm64FullDebug -PtargetAbi=arm64 # Runs here rather than in `checks` because it reads the built binaries, # and nothing builds them there. #469 was a wayland library linked without # gen-stubs.sh's weak stubs: 51 undefined symbols, dlopen refused it, and # every cage/app-window feature died on-device with a green build. Source # now, rather than a committed copy, does not make that unlinkable-output # case impossible — only unobservable until someone runs it. - name: Assert native libs resolve their stubs (#469) run: ./scripts/check-native-libs.sh - name: Upload debug APK if: success() uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 with: name: app-debug path: app/build/outputs/apk/arm64Full/debug/haven-*-arm64-debug.apk retention-days: 7 # Nightly-only: build the ABIs the per-push `build` job skips (x64, armv7) # so an x64/armv7-specific compile or native-cross break surfaces within 24h # instead of only at release. arm64 is already covered per-push by `build` # (which also runs on the schedule), so it's not repeated here. nightly-abi: if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' runs-on: ubuntu-latest timeout-minutes: 60 strategy: fail-fast: false matrix: include: - { abi: x64, variant: X64 } - { abi: armv7, variant: Armv7 } steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: submodules: false - uses: ./.github/actions/init-submodules-with-retry - uses: ./.github/actions/setup-toolchain - name: Build ${{ matrix.abi }} debug APK run: ./gradlew :app:assemble${{ matrix.variant }}FullDebug -PtargetAbi=${{ matrix.abi }} # Debug builds don't run R8, so an R8 rename of a reflectively-loaded class # can ship a feature 100% broken in release while every debug check stays # green — exactly how the email feature broke once (R8 renamed # com.sun.mail.imap.IMAPSSLStore → getStore("imaps") threw, fixed v5.59.45). # This runs R8 on the release variant and asserts the by-name-loaded classes # survive (no keystore — minify precedes signing). # # Every published release is already R8-checked in release.yml (the assert # moved there), so this job is early-feedback only: PRs (catch a -keep # regression before merge) + the nightly schedule (the direct-main-push # safety net), skipping direct main pushes where it paced every run ~16 min. # github.event_name is 'push' only for direct main pushes. release-r8-smoke: if: github.event_name != 'push' runs-on: ubuntu-latest timeout-minutes: 30 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: submodules: false - uses: ./.github/actions/init-submodules-with-retry - uses: ./.github/actions/setup-toolchain - name: R8 the release variant # Same skip as lint, same reason: R8 shrinks bytecode and never reads # jniLibs, but it sits downstream of preBuild and was paying for the # native builds anyway. This job hit its 30-minute timeout on the same # three nights, so the R8-keep assertion below has not actually run # since the from-source work landed. run: ./gradlew :app:minifyArm64FullReleaseWithR8 -PskipWaylandNatives=true -PskipFfmpegNatives=true - name: Assert reflectively-loaded classes survived R8 run: ./scripts/check-r8-kept-classes.sh