diff --git a/.bazelrc b/.bazelrc index 823f608..9aba675 100644 --- a/.bazelrc +++ b/.bazelrc @@ -137,6 +137,24 @@ build:apple_on_linux --action_env=PATH=external/rules_applecross++apple_cross_to build:apple_on_linux --action_env=RULES_APPLECROSS_RESOURCE_OUTPUT_MODE=relaxed build:apple_on_linux --action_env=RULES_APPLECROSS_RELAX_ACTOOL_ICON_COMPOSER=1 +# BuildBuddy's remote cache and build results (--config=buildbuddy): no key +# here. CI's runs on main and its releases turn it on with the key, in a +# file of the job's own (tools/ci/ci_bazel.sh, from the BUILDBUDDY_API_KEY +# secret), and only main's builds and the release jobs upload to it; pull +# requests don't use it (GitHub's cache alone). A builder with a key of +# their own puts the same lines in .bazelrc.user. What a job downloads is Bazel's +# default, the top-level outputs (what the scripts copy, run and test); the +# writers download every output (--remote_download_all), so the disk cache +# GitHub's cache keeps for runs without a key stays whole. Compressed +# (zstd), and the build event stream without the legacy list of each +# target's outputs, which BuildBuddy doesn't read. +build:buildbuddy --bes_results_url=https://app.buildbuddy.io/invocation/ +build:buildbuddy --bes_backend=grpcs://remote.buildbuddy.io +build:buildbuddy --remote_cache=grpcs://remote.buildbuddy.io +build:buildbuddy --remote_timeout=10m +build:buildbuddy --remote_cache_compression +build:buildbuddy --nolegacy_important_outputs + # Per-machine settings (untracked): e.g. --override_module for a fork # checked out beside isomer. try-import %workspace%/.bazelrc.user diff --git a/.github/actions/bazel_cache/action.yml b/.github/actions/bazel_cache/action.yml index d9e123b..329a55c 100644 --- a/.github/actions/bazel_cache/action.yml +++ b/.github/actions/bazel_cache/action.yml @@ -1,21 +1,31 @@ # Bazel's caches for a CI job, from GitHub's cache (actions/cache), and its # settings (tools/ci/ci_bazel.sh setup): the repository cache (downloads) -# and the disk cache (actions' outputs) of the job's group, linux, android or -# apple (where it builds, so what it caches is of use to it), keyed by +# and the disk cache (actions' outputs) of the job's group, ubuntu (the web, +# Linux and Android, built together on x86_64 Ubuntu), apple or windows +# (where it builds, so what it caches is of use to it), keyed by # MODULE.bazel and the SwiftPM graphs, the disk cache by commit too, the # newest of the group's restored when this commit's isn't there. Only main's # builds write them (.github/actions/bazel_cache_save); every other job reads them. -# They live in the home directory, outside the checkout: Bazel 9 refuses a -# repository contents cache inside the main repository. +# They live in the home directory, outside the checkout (Bazel 9 refuses a +# repository contents cache inside the main repository), or where the job's +# ISOMER_BAZEL_CACHE says (a runner's second disk). +# BuildBuddy's remote cache too, when the job hands this its key +# (buildbuddy-api-key, the repository's BUILDBUDDY_API_KEY secret, which +# the workflow passes only in runs on main and a published release's): +# given to tools/ci/ci_bazel.sh's setup step alone, which keeps it out of +# the checkout and the log. name: Bazel's cache description: Restores the job group's Bazel caches and writes Bazel's settings inputs: group: - description: linux, android or apple + description: ubuntu, apple or windows required: true disk: description: Whether to restore the disk cache too ("false" for the repository cache alone) default: "true" + buildbuddy-api-key: + description: BuildBuddy's API key (empty, as on a fork's pull request, for GitHub's cache alone) + default: "" outputs: repository-hit: description: Whether the repository cache's own key was found @@ -26,17 +36,19 @@ runs: - id: repository uses: actions/cache/restore@v4 with: - path: ~/.cache/isomer-bazel/repository + path: ${{ env.ISOMER_BAZEL_CACHE || '~/.cache/isomer-bazel' }}/repository key: bazel-repository-${{ inputs.group }}-${{ hashFiles('MODULE.bazel', 'examples/MODULE.bazel', '**/Package.resolved') }} restore-keys: bazel-repository-${{ inputs.group }}- - if: inputs.disk != 'false' uses: actions/cache/restore@v4 with: - path: ~/.cache/isomer-bazel/disk + path: ${{ env.ISOMER_BAZEL_CACHE || '~/.cache/isomer-bazel' }}/disk key: bazel-disk-${{ inputs.group }}-${{ hashFiles('MODULE.bazel', 'examples/MODULE.bazel', '**/Package.resolved') }}-${{ github.sha }} restore-keys: | bazel-disk-${{ inputs.group }}-${{ hashFiles('MODULE.bazel', 'examples/MODULE.bazel', '**/Package.resolved') }}- bazel-disk-${{ inputs.group }}- - name: Bazel's settings shell: bash - run: tools/ci/ci_bazel.sh setup "$HOME/.cache/isomer-bazel" + env: + BUILDBUDDY_API_KEY: ${{ inputs.buildbuddy-api-key }} + run: tools/ci/ci_bazel.sh setup "${ISOMER_BAZEL_CACHE:-$HOME/.cache/isomer-bazel}" diff --git a/.github/actions/bazel_cache_save/action.yml b/.github/actions/bazel_cache_save/action.yml index d0dd92d..721d2e4 100644 --- a/.github/actions/bazel_cache_save/action.yml +++ b/.github/actions/bazel_cache_save/action.yml @@ -7,7 +7,7 @@ name: Bazel's cache, saved description: Trims and saves the job group's Bazel caches inputs: group: - description: linux, android or apple + description: ubuntu, apple or windows required: true gigabytes: description: The disk cache's size at most, in GB @@ -20,13 +20,13 @@ runs: steps: - name: The disk cache, trimmed shell: bash - run: tools/ci/ci_bazel.sh trim "$HOME/.cache/isomer-bazel" "${{ inputs.gigabytes }}" + run: tools/ci/ci_bazel.sh trim "${ISOMER_BAZEL_CACHE:-$HOME/.cache/isomer-bazel}" "${{ inputs.gigabytes }}" - uses: actions/cache/save@v4 with: - path: ~/.cache/isomer-bazel/disk + path: ${{ env.ISOMER_BAZEL_CACHE || '~/.cache/isomer-bazel' }}/disk key: bazel-disk-${{ inputs.group }}-${{ hashFiles('MODULE.bazel', 'examples/MODULE.bazel', '**/Package.resolved') }}-${{ github.sha }} - if: inputs.repository-hit != 'true' uses: actions/cache/save@v4 with: - path: ~/.cache/isomer-bazel/repository + path: ${{ env.ISOMER_BAZEL_CACHE || '~/.cache/isomer-bazel' }}/repository key: bazel-repository-${{ inputs.group }}-${{ hashFiles('MODULE.bazel', 'examples/MODULE.bazel', '**/Package.resolved') }} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5c3e7c6..73337e3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,23 +4,31 @@ # one, the GUI tests by hand, and the screenshot proof only ahead of a # release (run: release, or run: proof by hand). Since # 2026-11-15 on GitHub's own standard runners alone (a fork runs it as it -# is; AGENTS.md, "The release proof" and "Signing"): the web and Linux in -# the project's image (by digest) on arm64 Ubuntu; Android in Swift's image -# on x86_64 Ubuntu (its SDK's tools are x86_64); the Apple targets on +# is; AGENTS.md, "The release proof" and "Signing"): the web, Linux and +# Android together, one job and one Bazel output base, in Swift's image (by +# digest) on x86_64 Ubuntu, with the Linux apps' libraries added +# (tools/ci/job_tools.sh; Android's SDK tools are x86_64, and the project's +# own image is arm64 alone); the Apple targets on # `xcode-27` Macs with their own Xcode (Apple's SDKs may not be # redistributed); Windows on windows-11-arm with swift.org's Swift and the # image's own Visual Studio, built only (tier 2). Bazel's # caches are GitHub's (.github/actions/bazel_cache), written by main's -# builds alone. +# builds alone, and BuildBuddy's remote cache, its key the +# BUILDBUDDY_API_KEY secret (read and write), handed to the cache action's +# setup alone and only in runs on main and a published release's: never to +# a pull request or a branch's run, whose scripts could upload with it +# (tools/ci/ci_bazel.sh: main's push builds and the release jobs write; +# main's other runs by hand read). Pull requests build on GitHub's cache +# alone until a read-only key (BUILDBUDDY_READ_KEY) is theirs. # -# - pull requests: container (web, Linux; the required check), -# container-android, container-apple, container-windows: every target +# - pull requests: container (web, Linux, Android; the required check), +# container-apple, container-windows: every target # built, then every test that draws nothing (container_build.sh pr). -# - main's commits: populate, populate-android, populate-apple, +# - main's commits: populate, populate-apple, # populate-windows (the same, and what a release builds, into the cache; # never a proof); bazel8, bazel8-apple. # - by hand (`run:`): verify (the builds and tests, no proof: verify, -# verify-android, verify-apple, verify-windows, container-verify, apple, +# verify-apple, verify-windows, container-verify, apple, # android); proof (the screenshot proof alone: proof, proof-apple, # proof-android, proof-shoot, proof-compare); prerelease (main: the # Alphas, alpha-apple and alpha, signed with the `release` environment's @@ -29,7 +37,9 @@ # the one run that proves and verifies at once, which tools/ci/verified.sh # asks for); # experiment (any branch but a release branch: the Storybook Lab drafted -# unsigned, as no environment's keys reach a branch). There is no adhoc +# unsigned, as no environment's keys reach a branch); waydroid-probe (a +# probe: whether Waydroid's Android boots on GitHub's hosted x86_64 +# Ubuntu, tools/ci/waydroid_probe.sh; nothing depends on it). There is no adhoc # run: a branch's builds are experiments only (the owner, 2026-11-12). # Drafts are CI's: no agent publishes one or makes a tag. # - a published release (its v* tag, made in Reviews): verified @@ -48,9 +58,9 @@ on: workflow_dispatch: inputs: run: - description: "What to run: verify (the tests, no proof), prerelease or release on main (verify on a branch to bisect); proof (the screenshot proof alone); experiment on any but a release branch" + description: "What to run: verify (the tests, no proof), prerelease or release on main (verify on a branch to bisect); proof (the screenshot proof alone); experiment on any but a release branch; waydroid-probe (a probe of Waydroid on the hosted runner) on any" type: choice - options: [verify, proof, prerelease, release, experiment] + options: [verify, proof, prerelease, release, experiment, waydroid-probe] default: verify kind: description: The proof's kind @@ -84,20 +94,28 @@ env: jobs: # --- Pull requests: every platform built, the tests that draw nothing --- + # The web, Linux and Android in one job, one Bazel output base on the + # runner's second disk: Swift's image on x86_64 (Android's SDK tools are + # x86_64), the Linux apps' libraries added by job_tools.sh. container: if: github.event_name == 'pull_request' - runs-on: ubuntu-24.04-arm - container: ghcr.io/attilathefun/visor-agent@sha256:849dcf6aeb16119e3b769b4f0c410b93ac58ed1e3b3ef2801f7534def3fbaaf0 + runs-on: ubuntu-24.04 + container: + image: swift:6.4.2-noble@sha256:23d9b28ad97fb1cf1999edc3a0cb265ee915ed42299a9344e7173d5a6d2b05f4 + # Bazel's tree on the runner's second disk (ISOMER_BAZEL_ROOT). + volumes: ["/mnt:/mnt"] timeout-minutes: 180 env: - ISOMER_PLATFORMS: web linux + ISOMER_PLATFORMS: web linux android + ISOMER_ANDROID_X86_64: "1" + ISOMER_BAZEL_ROOT: /mnt/bazel steps: - uses: actions/checkout@v5 - name: The job's tools run: tools/ci/job_tools.sh - uses: ./.github/actions/bazel_cache with: - group: linux + group: ubuntu - name: Every target built, and the tests that draw nothing env: ISOMER_EXECUTION_LOGS: ${{ runner.temp }}/execution-logs @@ -110,28 +128,6 @@ jobs: path: ${{ runner.temp }}/execution-logs retention-days: 7 - container-android: - if: github.event_name == 'pull_request' - runs-on: ubuntu-24.04 - container: - image: swift:6.4.2-noble@sha256:23d9b28ad97fb1cf1999edc3a0cb265ee915ed42299a9344e7173d5a6d2b05f4 - # Bazel's tree on the runner's second disk (ISOMER_BAZEL_ROOT). - volumes: ["/mnt:/mnt"] - timeout-minutes: 180 - env: - ISOMER_PLATFORMS: android - ISOMER_ANDROID_X86_64: "1" - ISOMER_BAZEL_ROOT: /mnt/bazel - steps: - - uses: actions/checkout@v5 - - name: The job's tools - run: tools/ci/job_tools.sh - - uses: ./.github/actions/bazel_cache - with: - group: android - - name: The Android targets built, and the Android build tests - run: exec tools/ci/container_build.sh pr - container-apple: if: github.event_name == 'pull_request' runs-on: xcode-27 @@ -175,38 +171,6 @@ jobs: # --- main: the merged tree built into GitHub's cache --------------------- populate: - if: github.event_name == 'push' - runs-on: ubuntu-24.04-arm - container: ghcr.io/attilathefun/visor-agent@sha256:849dcf6aeb16119e3b769b4f0c410b93ac58ed1e3b3ef2801f7534def3fbaaf0 - timeout-minutes: 180 - env: - ISOMER_PLATFORMS: web linux - steps: - - uses: actions/checkout@v5 - - name: The job's tools - run: tools/ci/job_tools.sh - - id: cache - uses: ./.github/actions/bazel_cache - with: - group: linux - - name: The merged tree, built into the cache - env: - ISOMER_EXECUTION_LOGS: ${{ runner.temp }}/execution-logs - run: exec tools/ci/container_build.sh all - - uses: ./.github/actions/bazel_cache_save - if: ${{ !cancelled() }} - with: - group: linux - gigabytes: 3 - repository-hit: ${{ steps.cache.outputs.repository-hit }} - - uses: actions/upload-artifact@v4 - if: ${{ !cancelled() }} - with: - name: execution-logs - path: ${{ runner.temp }}/execution-logs - retention-days: 7 - - populate-android: if: github.event_name == 'push' runs-on: ubuntu-24.04 container: @@ -214,7 +178,7 @@ jobs: volumes: ["/mnt:/mnt"] timeout-minutes: 180 env: - ISOMER_PLATFORMS: android + ISOMER_PLATFORMS: web linux android ISOMER_ANDROID_X86_64: "1" ISOMER_BAZEL_ROOT: /mnt/bazel steps: @@ -224,19 +188,30 @@ jobs: - id: cache uses: ./.github/actions/bazel_cache with: - group: android - - name: The merged tree's Android targets, built into the cache + group: ubuntu + buildbuddy-api-key: ${{ (github.event_name == 'release' || (github.event_name != 'pull_request' && github.ref == 'refs/heads/main')) && secrets.BUILDBUDDY_API_KEY || '' }} + - name: The merged tree, built into the cache + env: + ISOMER_EXECUTION_LOGS: ${{ runner.temp }}/execution-logs run: exec tools/ci/container_build.sh all # And what a release builds here: the Android app and the site as # alpha builds them (never the proof's apps: no proof on a push). - name: The published Android app and site, built into the cache run: exec tools/ci/container_build.sh package .ci/packages --config=alpha $PUBLISHED_LINUX + # The web, Linux and Android's share of GitHub's 10 GB: what the two + # groups (linux 3, android 2) had. - uses: ./.github/actions/bazel_cache_save if: ${{ !cancelled() }} with: - group: android - gigabytes: 2 + group: ubuntu + gigabytes: 5 repository-hit: ${{ steps.cache.outputs.repository-hit }} + - uses: actions/upload-artifact@v4 + if: ${{ !cancelled() }} + with: + name: execution-logs + path: ${{ runner.temp }}/execution-logs + retention-days: 7 populate-apple: if: github.event_name == 'push' @@ -250,6 +225,7 @@ jobs: uses: ./.github/actions/bazel_cache with: group: apple + buildbuddy-api-key: ${{ (github.event_name == 'release' || (github.event_name != 'pull_request' && github.ref == 'refs/heads/main')) && secrets.BUILDBUDDY_API_KEY || '' }} - name: The merged tree's Apple targets, built into the cache run: exec tools/ci/container_build.sh all - name: The published Apple apps, built into the cache @@ -293,43 +269,34 @@ jobs: repository-hit: ${{ steps.cache.outputs.repository-hit }} bazel8: - # The Storybooks built with the oldest Bazel isomer supports. + # The Storybooks built with the oldest Bazel isomer supports: the web, + # Linux and Android together, as container builds them. if: github.event_name == 'push' - strategy: - fail-fast: false - matrix: - include: - - group: linux - runner: ubuntu-24.04-arm - image: ghcr.io/attilathefun/visor-agent@sha256:849dcf6aeb16119e3b769b4f0c410b93ac58ed1e3b3ef2801f7534def3fbaaf0 - targets: >- - //web/storybook_web_application:storybook_web_application - //linux/storybook_linux_application:storybook_linux_application - - group: android - runner: ubuntu-24.04 - image: swift:6.4.2-noble@sha256:23d9b28ad97fb1cf1999edc3a0cb265ee915ed42299a9344e7173d5a6d2b05f4 - targets: //android/storybook_android_application:storybook_android_application_apk - runs-on: ${{ matrix.runner }} + runs-on: ubuntu-24.04 container: - image: ${{ matrix.image }} + image: swift:6.4.2-noble@sha256:23d9b28ad97fb1cf1999edc3a0cb265ee915ed42299a9344e7173d5a6d2b05f4 volumes: ["/mnt:/mnt"] timeout-minutes: 180 env: USE_BAZEL_VERSION: 8.5.0 - ISOMER_PLATFORMS: ${{ matrix.group == 'linux' && 'web linux' || 'android' }} + ISOMER_PLATFORMS: web linux android + ISOMER_BAZEL_ROOT: /mnt/bazel steps: - uses: actions/checkout@v5 - name: The job's tools run: tools/ci/job_tools.sh - uses: ./.github/actions/bazel_cache with: - group: ${{ matrix.group }} + group: ubuntu disk: "false" + buildbuddy-api-key: ${{ (github.event_name == 'release' || (github.event_name != 'pull_request' && github.ref == 'refs/heads/main')) && secrets.BUILDBUDDY_API_KEY || '' }} # Built only (container_build.sh's checks take Bazel 9's test flags). - name: The Storybooks with Bazel 8.5.0 - env: - TARGETS: ${{ matrix.targets }} - run: exec tools/ci/container_build.sh $TARGETS + run: >- + exec tools/ci/container_build.sh + //web/storybook_web_application:storybook_web_application + //linux/storybook_linux_application:storybook_linux_application + //android/storybook_android_application:storybook_android_application_apk bazel8-apple: if: github.event_name == 'push' @@ -343,6 +310,7 @@ jobs: - uses: ./.github/actions/bazel_cache with: group: apple + buildbuddy-api-key: ${{ (github.event_name == 'release' || (github.event_name != 'pull_request' && github.ref == 'refs/heads/main')) && secrets.BUILDBUDDY_API_KEY || '' }} disk: "false" - name: The Apple Storybooks with Bazel 8.5.0 run: >- @@ -354,23 +322,6 @@ jobs: # --- By hand: verify (the GUI tests) ------------------------------------ verify: - if: github.event_name == 'workflow_dispatch' && (inputs.run == 'verify' || inputs.run == 'release') - runs-on: ubuntu-24.04-arm - container: ghcr.io/attilathefun/visor-agent@sha256:849dcf6aeb16119e3b769b4f0c410b93ac58ed1e3b3ef2801f7534def3fbaaf0 - timeout-minutes: 180 - env: - ISOMER_PLATFORMS: web linux - steps: - - uses: actions/checkout@v5 - - name: The job's tools - run: tools/ci/job_tools.sh - - uses: ./.github/actions/bazel_cache - with: - group: linux - - name: Build, and the tests in the build container - run: exec tools/ci/container_build.sh - - verify-android: if: github.event_name == 'workflow_dispatch' && (inputs.run == 'verify' || inputs.run == 'release') runs-on: ubuntu-24.04 container: @@ -378,7 +329,7 @@ jobs: volumes: ["/mnt:/mnt"] timeout-minutes: 180 env: - ISOMER_PLATFORMS: android + ISOMER_PLATFORMS: web linux android ISOMER_BAZEL_ROOT: /mnt/bazel steps: - uses: actions/checkout@v5 @@ -386,8 +337,9 @@ jobs: run: tools/ci/job_tools.sh - uses: ./.github/actions/bazel_cache with: - group: android - - name: Build, and the Android build tests + group: ubuntu + buildbuddy-api-key: ${{ (github.event_name == 'release' || (github.event_name != 'pull_request' && github.ref == 'refs/heads/main')) && secrets.BUILDBUDDY_API_KEY || '' }} + - name: Build, and the tests in the build container run: exec tools/ci/container_build.sh - uses: actions/upload-artifact@v4 with: @@ -411,6 +363,7 @@ jobs: - uses: ./.github/actions/bazel_cache with: group: apple + buildbuddy-api-key: ${{ (github.event_name == 'release' || (github.event_name != 'pull_request' && github.ref == 'refs/heads/main')) && secrets.BUILDBUDDY_API_KEY || '' }} - name: Build, with this Mac's Xcode run: exec tools/ci/container_build.sh - uses: actions/upload-artifact@v4 @@ -458,18 +411,22 @@ jobs: # and the Linux app under Xvfb, driven as apple drives the iPhone's and # the Mac's (tools/ci/container_build.sh headful). A release needs it. if: github.event_name == 'workflow_dispatch' && (inputs.run == 'verify' || inputs.run == 'release') - runs-on: ubuntu-24.04-arm - container: ghcr.io/attilathefun/visor-agent@sha256:849dcf6aeb16119e3b769b4f0c410b93ac58ed1e3b3ef2801f7534def3fbaaf0 + runs-on: ubuntu-24.04 + container: + image: swift:6.4.2-noble@sha256:23d9b28ad97fb1cf1999edc3a0cb265ee915ed42299a9344e7173d5a6d2b05f4 + volumes: ["/mnt:/mnt"] timeout-minutes: 120 env: ISOMER_PLATFORMS: web linux + ISOMER_BAZEL_ROOT: /mnt/bazel steps: - uses: actions/checkout@v5 - name: The job's tools run: tools/ci/job_tools.sh - uses: ./.github/actions/bazel_cache with: - group: linux + group: ubuntu + buildbuddy-api-key: ${{ (github.event_name == 'release' || (github.event_name != 'pull_request' && github.ref == 'refs/heads/main')) && secrets.BUILDBUDDY_API_KEY || '' }} - name: The tests that draw env: ISOMER_EXECUTION_LOGS: ${{ runner.temp }}/execution-logs @@ -534,7 +491,7 @@ jobs: android: # The Android Storybook's tests on GitHub's own Ubuntu runner, the # emulator on its KVM (tools/ci/hosted_android_test.sh). - needs: verify-android + needs: verify if: ${{ !cancelled() && github.event_name == 'workflow_dispatch' && (inputs.run == 'verify' || inputs.run == 'release') }} runs-on: ubuntu-24.04 timeout-minutes: 90 @@ -571,14 +528,18 @@ jobs: proof: if: github.event_name == 'workflow_dispatch' && (inputs.run == 'release' || inputs.run == 'proof') - runs-on: ubuntu-24.04-arm - container: ghcr.io/attilathefun/visor-agent@sha256:849dcf6aeb16119e3b769b4f0c410b93ac58ed1e3b3ef2801f7534def3fbaaf0 + runs-on: ubuntu-24.04 + container: + image: swift:6.4.2-noble@sha256:23d9b28ad97fb1cf1999edc3a0cb265ee915ed42299a9344e7173d5a6d2b05f4 + volumes: ["/mnt:/mnt"] concurrency: group: isomer-proof-${{ github.ref }} cancel-in-progress: false timeout-minutes: 180 env: PROOF_KIND: ${{ inputs.kind || 'full' }} + ISOMER_PLATFORMS: web + ISOMER_BAZEL_ROOT: /mnt/bazel steps: - uses: actions/checkout@v5 with: @@ -587,7 +548,8 @@ jobs: run: tools/ci/job_tools.sh - uses: ./.github/actions/bazel_cache with: - group: linux + group: ubuntu + buildbuddy-api-key: ${{ (github.event_name == 'release' || (github.event_name != 'pull_request' && github.ref == 'refs/heads/main')) && secrets.BUILDBUDDY_API_KEY || '' }} - name: The web app built run: exec tools/ci/proof.sh --stage build --platform web --kind "$PROOF_KIND" --apps "$RUNNER_TEMP/proof-apps" --review "$RUNNER_TEMP/proof-review" - uses: actions/upload-artifact@v4 @@ -615,6 +577,7 @@ jobs: - uses: ./.github/actions/bazel_cache with: group: apple + buildbuddy-api-key: ${{ (github.event_name == 'release' || (github.event_name != 'pull_request' && github.ref == 'refs/heads/main')) && secrets.BUILDBUDDY_API_KEY || '' }} - name: The iPhone and Mac apps built, with this Mac's Xcode run: exec tools/ci/proof.sh --stage build --platform ios,macos --kind "$PROOF_KIND" --apps "$RUNNER_TEMP/proof-apps" --review "$RUNNER_TEMP/proof-review" - uses: actions/upload-artifact@v4 @@ -652,7 +615,8 @@ jobs: run: tools/ci/job_tools.sh - uses: ./.github/actions/bazel_cache with: - group: android + group: ubuntu + buildbuddy-api-key: ${{ (github.event_name == 'release' || (github.event_name != 'pull_request' && github.ref == 'refs/heads/main')) && secrets.BUILDBUDDY_API_KEY || '' }} - name: The Android app built, for x86_64 run: exec tools/ci/proof.sh --stage build --platform android --kind "$PROOF_KIND" --apps "$RUNNER_TEMP/proof-apps" --review "$RUNNER_TEMP/proof-review" - uses: actions/upload-artifact@v4 @@ -763,11 +727,11 @@ jobs: alpha-apple: # The Apple Alphas, built unsigned (alpha signs them); the version found # here and handed to alpha. - needs: [verify, verify-android, verify-apple, container-verify, apple, android, proof-compare] + needs: [verify, verify-apple, container-verify, apple, android, proof-compare] if: >- always() && github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main' && (inputs.run == 'prerelease' || (inputs.run == 'release' && - needs.verify.result == 'success' && needs.verify-android.result == 'success' && + needs.verify.result == 'success' && needs.verify-apple.result == 'success' && needs.container-verify.result == 'success' && needs.apple.result == 'success' && needs.android.result == 'success' && needs.proof-compare.result == 'success')) @@ -788,6 +752,7 @@ jobs: - uses: ./.github/actions/bazel_cache with: group: apple + buildbuddy-api-key: ${{ (github.event_name == 'release' || (github.event_name != 'pull_request' && github.ref == 'refs/heads/main')) && secrets.BUILDBUDDY_API_KEY || '' }} - name: Build env: ISOMER_PLATFORMS: apple @@ -842,7 +807,8 @@ jobs: run: tools/ci/check_version_line.sh "$VERSION" - uses: ./.github/actions/bazel_cache with: - group: android + group: ubuntu + buildbuddy-api-key: ${{ (github.event_name == 'release' || (github.event_name != 'pull_request' && github.ref == 'refs/heads/main')) && secrets.BUILDBUDDY_API_KEY || '' }} # exec: the runner's cancel reaches the build. - name: Build run: exec tools/ci/container_build.sh package .ci/packages --config=alpha $PUBLISHED_LINUX @@ -918,6 +884,7 @@ jobs: - uses: ./.github/actions/bazel_cache with: group: apple + buildbuddy-api-key: ${{ (github.event_name == 'release' || (github.event_name != 'pull_request' && github.ref == 'refs/heads/main')) && secrets.BUILDBUDDY_API_KEY || '' }} disk: "false" - name: Build env: @@ -937,6 +904,33 @@ jobs: "The Storybook as an experiment: the publishing path for experiments, before the whole wasm apps" "$RUNNER_TEMP/assets" "$RUNNER_TEMP/notes.md" + # --- By hand: a probe ------------------------------------------------- + + waydroid-probe: + # Whether Waydroid (Android in a container on the host's own kernel, + # binder and all) boots on GitHub's hosted x86_64 Ubuntu, so the Android + # GUI tests could run in the same job as everything else + # (tools/ci/waydroid_probe.sh: the kernel, binder, Waydroid from its + # repository, its container and a session, Android's boot and adb; the + # findings in the run's summary). On the runner itself, not in a + # container. Nothing depends on it, and it never fails the run. + if: github.event_name == 'workflow_dispatch' && inputs.run == 'waydroid-probe' + runs-on: ubuntu-24.04 + timeout-minutes: 20 + continue-on-error: true + steps: + - uses: actions/checkout@v5 + - name: Waydroid, probed + continue-on-error: true + run: tools/ci/waydroid_probe.sh "$RUNNER_TEMP/waydroid-probe" + - uses: actions/upload-artifact@v4 + if: ${{ !cancelled() }} + continue-on-error: true + with: + name: waydroid-probe + path: ${{ runner.temp }}/waydroid-probe + retention-days: 1 + # --- A published release: nothing Apple rebuilt ----------------------- release-apple: @@ -953,6 +947,7 @@ jobs: - uses: ./.github/actions/bazel_cache with: group: apple + buildbuddy-api-key: ${{ (github.event_name == 'release' || (github.event_name != 'pull_request' && github.ref == 'refs/heads/main')) && secrets.BUILDBUDDY_API_KEY || '' }} - name: The iPhone's, for the simulator env: ISOMER_PLATFORMS: apple @@ -1011,7 +1006,8 @@ jobs: run: tools/ci/stamp_apps.sh - uses: ./.github/actions/bazel_cache with: - group: android + group: ubuntu + buildbuddy-api-key: ${{ (github.event_name == 'release' || (github.event_name != 'pull_request' && github.ref == 'refs/heads/main')) && secrets.BUILDBUDDY_API_KEY || '' }} - name: Android's, for production run: >- tools/ci/container_build.sh package .ci/android --config=prod --compilation_mode=opt diff --git a/AGENTS.md b/AGENTS.md index 05a5326..3127e92 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -326,19 +326,21 @@ alone since 2026-11-15 (nothing of Shireworks at run time: no lease, no cache, no signing service, so a contributor's fork runs it as it is), in stages (proof.sh --stage build|shoot|compare, proof.py --build-to/--from/--here): built where each platform builds (`proof`: the -web in the project's image, ghcr.io/attilathefun/visor-agent pinned by -digest, on GitHub's arm64 Ubuntu; `proof-apple`: the iPhone and the Mac on -an `xcode-27` Mac with its own Xcode; `proof-android`: Android for x86_64 -in Swift's image on GitHub's x86_64 Ubuntu), then pictured: the iPhone (a +web, and `proof-android`: Android for x86_64, in Swift's image on GitHub's +x86_64 Ubuntu; `proof-apple`: the iPhone and the Mac on an `xcode-27` Mac +with its own Xcode), then pictured: the iPhone (a simulator made for the run) and the Mac on `xcode-27` runners, the Android Storybook on an emulator under Ubuntu's KVM (tools/ci/hosted_android_emulator.sh: API 35, 1080Ă—2400, 420 dpi, gesture navigation) and the web in Ubuntu's Chrome (the `proof-shoot` jobs), then written in the container (`proof-compare`). Where each platform builds -(tools/ci/container_build.sh's ISOMER_PLATFORMS): the web and Linux in the -project's image on arm64; Android on x86_64 (Google's SDK and NDK tools and -the hermetic JDK for Linux are x86_64, and GitHub's arm64 runners have no -Rosetta); the Apple targets on `xcode-27` Macs with their own Xcode (the +(tools/ci/container_build.sh's ISOMER_PLATFORMS): the web, Linux and +Android together, in one job and one Bazel output base, on GitHub's x86_64 +Ubuntu, in Swift's image (swift:6.4.2-noble, by digest) with the Linux apps' +libraries added (tools/ci/job_tools.sh: SDL2, GTK 3, WebKitGTK, GL and EGL, +as the project's image, ghcr.io/attilathefun/visor-agent, has them; that +image is arm64 alone, and Google's SDK and NDK tools and the hermetic JDK +for Linux are x86_64, which GitHub's arm64 runners can't run); the Apple targets on `xcode-27` Macs with their own Xcode (the owner, 2026-11-15: Apple's SDKs may not be redistributed, so CI never takes the SDK archive rules_applecross builds them with on Linux); Windows on GitHub's windows-11-arm, natively, with swift.org's Swift at the pinned @@ -347,24 +349,29 @@ only (tier 2; tools/ci/windows_build.ps1, the recipe of tools/proof/proof.py: vcvarsall arm64, BAZEL_SH Git's bash, `--output_user_root=C:/b`, `--repo_env` for SDKROOT, PATH and MSVC's variables), as Microsoft's sysroot may not be redistributed for a build on Linux. Bazel keeps its disk and -repository caches in GitHub's cache (actions/cache, by group, linux, -android, apple or windows, and MODULE.bazel; tools/ci/ci_bazel.sh: -written by main's builds alone, trimmed to stay within GitHub's 10 GB a -repository). CI follows the owner's policy for protected repositories +repository caches in GitHub's cache (actions/cache, by group, ubuntu, +apple or windows, and MODULE.bazel; tools/ci/ci_bazel.sh: written by +main's builds alone, trimmed to stay within GitHub's 10 GB a repository), +and, on this repository's own runs, in BuildBuddy's remote cache +(.bazelrc's `--config=buildbuddy`, its key the BUILDBUDDY_API_KEY secret, +read and write, which the workflow hands ci_bazel.sh's setup alone and only +in runs on main and a published release's: written by main's builds and +the release jobs, read by main's runs by hand; pull requests, whose +scripts could upload with it, build on GitHub's cache alone until a +read-only key, BUILDBUDDY_READ_KEY, is theirs). CI follows the owner's policy for protected repositories (AttilaTheFun/reviews' docs/CI_POLICY.md) and the shape the owner set on 2026-11-08 (build.yml's header): the tests without a GUI before a merge, every build after one, the GUI tests by hand, and the screenshot proof only ad hoc, ahead of a release (the owner, 2026-11-15). A pull request -gets `container` (the web and Linux targets built, then the tests that draw -nothing: the core's, the WASI checks, and the Storybook's headless and -remote-driving tests; the required check), `container-android` (the Android -targets and their build tests), `container-apple` (the Apple targets) and -`container-windows` (not required), each commit on main `populate`, -`populate-android`, `populate-apple` and `populate-windows` (the same -builds, then the published apps under --config=alpha; the cache's only -writers; never the proof's) and `bazel8`. +gets `container` (the web, Linux and Android targets built, then the +tests that draw nothing: the core's, the WASI checks, the Android build +tests, and the Storybook's headless and remote-driving tests; the required +check), `container-apple` (the Apple targets) and `container-windows` (not +required), each commit on main `populate`, `populate-apple` and +`populate-windows` (the same builds, then the published apps under +--config=alpha; the cache's only writers; never the proof's) and `bazel8`. The GUI tests run only by hand: `run: verify` (each -platform's build, `verify`, `verify-android`, `verify-apple`, +platform's build, `verify` (the web, Linux and Android), `verify-apple`, `verify-windows`; the tests that draw in a container, `container-verify`: the web Storybook in headless Chrome, and the Storybook's tests run headful on the web and on Linux under @@ -376,7 +383,10 @@ Xvfb; the Storybook's test stories, the iPhone's simulator and the Mac on release, tools/ci/draft_release.sh: the one run with both, which tools/ci/verified.sh asks for before a release is signed), `run: experiment` (the Storybook Lab, drafted unsigned: the signing keys are the `release` environment's, main's and v* -tags' alone). Drafts are CI's; an agent proposes by running the workflow on +tags' alone), `run: waydroid-probe` (a probe, nothing depends on it: +whether Waydroid's Android boots on GitHub's hosted x86_64 Ubuntu, its +binder and all, tools/ci/waydroid_probe.sh, reported in the run's summary). +Drafts are CI's; an agent proposes by running the workflow on main, never by making a draft or a tag. The proof is the full set by default (every story; `quick` the core set: a story from each area). The proof is in Reviews' format 2 (the private AttilaTheFun/reviews' diff --git a/examples/.bazelrc b/examples/.bazelrc index 601ccbd..220ff60 100644 --- a/examples/.bazelrc +++ b/examples/.bazelrc @@ -225,6 +225,24 @@ build:adhoc --//tools/variant:variant=adhoc build:ci_device --ios_multi_cpus=arm64 build:ci_device --ios_signing_cert_name=- +# BuildBuddy's remote cache and build results (--config=buildbuddy): no key +# here. CI's runs on main and its releases turn it on with the key, in a +# file of the job's own (tools/ci/ci_bazel.sh, from the BUILDBUDDY_API_KEY +# secret), and only main's builds and the release jobs upload to it; pull +# requests don't use it (GitHub's cache alone). A builder with a key of +# their own puts the same lines in .bazelrc.user. What a job downloads is Bazel's +# default, the top-level outputs (what the scripts copy, run and test); the +# writers download every output (--remote_download_all), so the disk cache +# GitHub's cache keeps for runs without a key stays whole. Compressed +# (zstd), and the build event stream without the legacy list of each +# target's outputs, which BuildBuddy doesn't read. +build:buildbuddy --bes_results_url=https://app.buildbuddy.io/invocation/ +build:buildbuddy --bes_backend=grpcs://remote.buildbuddy.io +build:buildbuddy --remote_cache=grpcs://remote.buildbuddy.io +build:buildbuddy --remote_timeout=10m +build:buildbuddy --remote_cache_compression +build:buildbuddy --nolegacy_important_outputs + # Per-machine settings (untracked), e.g. --override_module for a fork checked # out beside isomer. try-import %workspace%/.bazelrc.user diff --git a/tools/ci/ci_bazel.sh b/tools/ci/ci_bazel.sh index 229d777..588b8ff 100755 --- a/tools/ci/ci_bazel.sh +++ b/tools/ci/ci_bazel.sh @@ -25,6 +25,20 @@ # Microsoft's may not be redistributed, so nothing public serves it, and # CI names none: CI builds Windows on Windows itself # (tools/ci/windows_build.ps1, the runner image's Visual Studio). +# - BuildBuddy's remote cache (.bazelrc's --config=buildbuddy), when +# BUILDBUDDY_API_KEY is set: the config and the key's headers in a file of +# the job's own outside the checkout (mode 600), which .bazelrc.user +# imports by its path, the key never on a command line nor in the log. +# The key reads and writes, so the workflow hands it to this step only in +# runs on main and a published release's, never to a pull request's or a +# branch's (whose copy of this script could upload with it): those build +# on GitHub's cache alone. Of the runs that have it, main's builds (a +# push to main: populate, bazel8) and the release jobs (alpha and +# alpha-apple on main, a published release's) upload; main's other runs +# by hand read (--noremote_upload_local_results). A reader downloads only the +# top-level outputs (Bazel's default, the files the jobs copy and run); a +# writer downloads them all, so the disk cache GitHub's cache keeps +# (above) stays whole for the runs that have no key. # Never the Apple targets on Linux (.bazelrc's apple_on_linux, which takes # Xcode's SDK archive): Apple's SDKs may not be redistributed, so CI builds # the Apple targets on GitHub's Macs with their own Xcode (the owner, @@ -65,6 +79,46 @@ setup) echo "::warning::ci_bazel: $ISOMER_BAZEL_ROOT can't be made: Bazel's tree stays in its default place" fi fi + # BuildBuddy, with the key: never traced, never echoed. + if [ -n "${BUILDBUDDY_API_KEY:-}" ]; then + set +x + writer=0 + case "${GITHUB_EVENT_NAME:-}:${GITHUB_REF:-}" in + push:refs/heads/main | release:*) writer=1 ;; + workflow_dispatch:refs/heads/main) + case "${GITHUB_JOB:-}" in alpha | alpha-apple) writer=1 ;; esac ;; + esac + secret_dir="$HOME/.config/isomer-ci" + (umask 077 && mkdir -p "$secret_dir") + chmod 700 "$secret_dir" + secret_rc="$secret_dir/buildbuddy.bazelrc" + (umask 077 && : > "$secret_rc") + chmod 600 "$secret_rc" + { + echo "common --config=buildbuddy" + printf 'common --remote_header=x-buildbuddy-api-key=%s\n' "$BUILDBUDDY_API_KEY" + printf 'common --bes_header=x-buildbuddy-api-key=%s\n' "$BUILDBUDDY_API_KEY" + if [ $writer -eq 1 ]; then + echo "common --remote_download_all" + else + echo "common --noremote_upload_local_results" + fi + } >> "$secret_rc" + unset BUILDBUDDY_API_KEY + secret_rc="$(cd "$secret_dir" && here)/buildbuddy.bazelrc" + lines+=("try-import $secret_rc") + if [ $writer -eq 1 ]; then + echo "ci_bazel: BuildBuddy's remote cache, read and written (${GITHUB_EVENT_NAME:-}, ${GITHUB_REF:-}, ${GITHUB_JOB:-})" + else + echo "ci_bazel: BuildBuddy's remote cache, read only (${GITHUB_EVENT_NAME:-}, ${GITHUB_REF:-}, ${GITHUB_JOB:-})" + fi + else + # A read-only key for pull requests (BUILDBUDDY_READ_KEY, a secret of + # its own once there is one) would go here: the same file with its + # headers and --noremote_upload_local_results, its key unable to + # write whatever a pull request's scripts ask. + echo "ci_bazel: no BUILDBUDDY_API_KEY: no remote cache, GitHub's cache alone" + fi if [ -n "$cache" ]; then mkdir -p "$cache/disk" "$cache/repository" cache="$(cd "$cache" && here)" diff --git a/tools/ci/container_build.sh b/tools/ci/container_build.sh index 74599f5..3291897 100755 --- a/tools/ci/container_build.sh +++ b/tools/ci/container_build.sh @@ -1,12 +1,13 @@ #!/bin/bash # CI's build of every platform, on GitHub's own runners, each platform where # its tools run (ISOMER_PLATFORMS): -# - web and linux: in the project's Linux container (the image a Visor -# session works in, ghcr.io/attilathefun/visor-agent, by digest) on -# GitHub's arm64 Ubuntu runner; -# - android: on GitHub's x86_64 Ubuntu runner, in Swift's own image: -# Google's Android SDK and NDK tools, and the hermetic JDK for Linux, are -# x86_64 programs, and GitHub's arm64 runners have nothing to run them on; +# - web, linux and android: together, in one job and one Bazel output base, +# on GitHub's x86_64 Ubuntu runner, in Swift's own image with the Linux +# apps' libraries added (tools/ci/job_tools.sh): Google's Android SDK and +# NDK tools, and the hermetic JDK for Linux, are x86_64 programs, which +# GitHub's arm64 runners have nothing to run (no Rosetta), and the +# project's own image (ghcr.io/attilathefun/visor-agent, which an agent's +# arm64 container runs this in) is built for arm64 alone; # - apple: on GitHub's `xcode-27` Macs (a standard runner, free for a public # repository), with their own Xcode (the owner, 2026-11-15): Apple's SDKs # may not be redistributed, so CI never takes the SDK archive the Apple @@ -361,6 +362,7 @@ if [ "$mode" = all ] || [ "$mode" = pr ]; then //android/storybook_android_application:storybook_android_application_apk results+=($?) fi + df -h / /mnt 2> /dev/null || df -h / for result in "${results[@]}"; do [ "$result" -ne 0 ] && exit "$result"; done exit 0 fi @@ -471,6 +473,7 @@ if has windows; then fi chmod -R a+rwX "$platforms_out" ls -lR "$platforms_out" | head -80 +df -h / /mnt 2> /dev/null || df -h / for result in "${results[@]}"; do [ "$result" -ne 0 ] && exit "$result"; done exit 0 ' diff --git a/tools/ci/job_tools.sh b/tools/ci/job_tools.sh index ca2f8bf..6f6d5ba 100755 --- a/tools/ci/job_tools.sh +++ b/tools/ci/job_tools.sh @@ -1,10 +1,14 @@ #!/bin/bash # What a CI job's Linux container needs beyond its image, installed when -# missing: the project's own image (ghcr.io/attilathefun/visor-agent) has it -# all; Swift's (the x86_64 jobs': Android's tools are x86_64) has Swift and -# clang, and is given Bazel (Bazelisk, pinned by SHA-256, honouring -# .bazelversion), git, Python, zip and the rest the scripts call. As root, -# or by sudo. +# missing: the project's own image (ghcr.io/attilathefun/visor-agent, arm64 +# alone) has it all; Swift's (the x86_64 jobs', where the web, Linux and +# Android build together: Android's tools are x86_64) has Swift and clang, +# and is given Bazel (Bazelisk, pinned by SHA-256, honouring .bazelversion), +# git, Python, zip and the rest the scripts call, and, when the job builds +# Linux (ISOMER_PLATFORMS names linux, or names nothing), what Isomer's Linux +# apps link, as the project's image has it (visor's +# tools/containers/visor-agent/Dockerfile): SDL2 and SDL2_ttf, GL and EGL, +# GTK 3 and WebKitGTK, lld. As root, or by sudo. # # tools/ci/job_tools.sh set -euo pipefail @@ -23,6 +27,14 @@ packages=(ca-certificates) for pair in "${wanted[@]}"; do command -v "${pair%%:*}" > /dev/null || packages+=("${pair#*:}") done +# Isomer's Linux apps' libraries (linux/libraries/swift_ui), by pkg-config. +platforms=" ${ISOMER_PLATFORMS:-linux} " +if [[ $platforms == *" linux "* ]] && + ! { command -v pkg-config > /dev/null && pkg-config --exists sdl2 SDL2_ttf gl egl gtk+-3.0 webkit2gtk-4.1 && + command -v ld.lld > /dev/null; }; then + packages+=(pkg-config lld libsdl2-dev libsdl2-ttf-dev libgl-dev libegl-dev libglvnd-dev libgtk-3-dev + libwebkit2gtk-4.1-dev libcurl4-openssl-dev libsqlite3-dev libnss3) +fi if [ ${#packages[@]} -gt 1 ]; then root_do apt-get update -qq > /dev/null root_do env DEBIAN_FRONTEND=noninteractive apt-get install -y -q --no-install-recommends "${packages[@]}" > /dev/null @@ -36,4 +48,7 @@ if ! command -v bazel > /dev/null; then fi # The checkout belongs to the runner's user, not the container's. git config --global --add safe.directory "${GITHUB_WORKSPACE:-$PWD}" -echo "job_tools: $(bazel --version 2> /dev/null || echo bazel), $(git --version)" +echo "job_tools: $(bazel --version 2> /dev/null || echo bazel), $(git --version), $(uname -m)" +# The room Bazel has: its tree and its caches (the x86_64 runner's second +# disk at /mnt, where the job mounts it). +df -h / /mnt 2> /dev/null || df -h / diff --git a/tools/ci/verified.sh b/tools/ci/verified.sh index 27692a7..1d312ae 100755 --- a/tools/ci/verified.sh +++ b/tools/ci/verified.sh @@ -1,7 +1,8 @@ #!/bin/bash # Whether a commit was verified: a run of the Build workflow by hand on it # whose every test passed, on GitHub's own runners: each platform's build -# and its tests there (verify, verify-android, verify-apple), the tests that +# and its tests there (verify: the web, Linux and Android together; +# verify-apple), the tests that # draw in a container (container-verify), the iPhone's, the Mac's and # Android's tests (apple, android: a matrix job passes when every part did), # and its screenshot proof (proof-compare). Only `run: release` runs both @@ -28,7 +29,7 @@ for run in $(gh api "repos/$repo/actions/runs?head_sha=$sha&event=workflow_dispa if gh api "repos/$repo/actions/runs/$run/jobs?per_page=100" --jq '.jobs as $jobs | def named(name): [$jobs[] | select(.name == name or (.name | startswith(name + " (")))]; def passed(name): named(name) as $all | ($all | length) > 0 and ($all | all(.conclusion == "success")); - passed("verify") and passed("verify-android") and passed("verify-apple") and passed("container-verify") + passed("verify") and passed("verify-apple") and passed("container-verify") and passed("apple") and passed("android") and passed("proof-compare")' | grep -qx true; then echo "$run" diff --git a/tools/ci/waydroid_probe.sh b/tools/ci/waydroid_probe.sh new file mode 100755 index 0000000..c366606 --- /dev/null +++ b/tools/ci/waydroid_probe.sh @@ -0,0 +1,183 @@ +#!/bin/bash +# A probe, by hand only (the Build workflow's `run: waydroid-probe`): whether +# Waydroid (Android in an LXC container on the host's own kernel) can run on +# GitHub's hosted x86_64 Ubuntu runner, so that the Android GUI tests could +# run in the same job as everything else, as they do on a kernel the owner +# controls. Nothing depends on it, and it never fails: every step is tried, +# time-limited, and what happened is written to the job's summary +# ($GITHUB_STEP_SUMMARY) and its log. +# +# tools/ci/waydroid_probe.sh [] +# +# What it tries, in order (each later step only if the one it needs worked): +# 1. the kernel: uname -a, binder and ashmem in its config, /dev/binder*, +# /dev/binderfs, binder in /proc/filesystems; +# 2. binder: modprobe binder_linux (devices=binder,hwbinder,vndbinder), +# with the kernel's linux-modules-extra package installed if the module +# isn't there, and binderfs mounted; ashmem (Waydroid uses memfd where +# ashmem is missing); +# 3. Waydroid from its official apt repository (repo.waydro.id), and +# `waydroid init` (the LineageOS system and vendor images); +# 4. the container (waydroid-container's service), then a session under a +# headless Weston (Waydroid draws into a Wayland compositor); +# 5. Android booted: `waydroid status`, sys.boot_completed, and adb over +# Waydroid's IP (`adb connect :5555`, `adb devices`). +# Run on the runner itself (not in a job container), with sudo. +set -u +LOGS="${1:-${RUNNER_TEMP:-/tmp}/waydroid-probe}" +mkdir -p "$LOGS" +SUMMARY="${GITHUB_STEP_SUMMARY:-$LOGS/summary.md}" +rows=() +# row +row() { rows+=("| $1 | $2 | ${3//|/\\|} |"); echo "waydroid_probe: $1: $2${3:+ ($3)}"; } +# run : the command's output kept and shown. +run() { + local seconds=$1 name=$2; shift 2 + echo "::group::$name: $*" + timeout --kill-after=10 "$seconds" "$@" > "$LOGS/$name.log" 2>&1 + local status=$? + tail -60 "$LOGS/$name.log" + echo "exit $status" + echo "::endgroup::" + return $status +} +finish() { + { + echo "## Waydroid on GitHub's hosted Ubuntu" + echo + echo "\`$(uname -a)\`" + echo + echo "| Step | Result | Detail |" + echo "| --- | --- | --- |" + printf '%s\n' "${rows[@]}" + echo + echo "Verdict: $verdict" + echo + echo "Logs: the run's \`waydroid-probe\` artifact." + } >> "$SUMMARY" + cat "$SUMMARY" 2> /dev/null | tail -40 + exit 0 +} +verdict="Android did not boot (see the first failing step)" +trap finish EXIT + +# 1. The kernel. +kernel="$(uname -r)" +uname -a | tee "$LOGS/uname.log" +row kernel ok "$kernel" +config="" +for candidate in "/boot/config-$kernel" /proc/config.gz; do [ -r "$candidate" ] && { config=$candidate; break; }; done +if [ -n "$config" ]; then + case "$config" in *.gz) zcat "$config" ;; *) cat "$config" ;; esac | grep -E "CONFIG_ANDROID|BINDER|ASHMEM" > "$LOGS/kernel-config.log" + row "kernel config" ok "$(tr '\n' ' ' < "$LOGS/kernel-config.log" | cut -c1-300)" +else + row "kernel config" "not readable" "" +fi +ls -la /dev/binder* /dev/binderfs /dev/ashmem > "$LOGS/dev-before.log" 2>&1 +row "/dev/binder*, /dev/binderfs, /dev/ashmem before" info "$(tr '\n' ' ' < "$LOGS/dev-before.log" | cut -c1-300)" +filesystems="$(grep binder /proc/filesystems)" +row "binder in /proc/filesystems before" "${filesystems:+yes}${filesystems:-no}" "$filesystems" + +# 2. Binder (and ashmem). +modprobe_binder() { sudo modprobe binder_linux devices=binder,hwbinder,vndbinder; } +if run 60 modprobe-binder modprobe_binder; then + row "modprobe binder_linux" ok "" +else + row "modprobe binder_linux" failed "$(tail -2 "$LOGS/modprobe-binder.log" | tr '\n' ' ')" + # The module ships in the kernel's extra modules, which the runner's + # image may leave out. + if run 300 modules-extra sudo env DEBIAN_FRONTEND=noninteractive apt-get install -y -q "linux-modules-extra-$kernel"; then + row "linux-modules-extra-$kernel" installed "" + if run 60 modprobe-binder-again modprobe_binder; then + row "modprobe binder_linux, again" ok "" + else + row "modprobe binder_linux, again" failed "$(tail -2 "$LOGS/modprobe-binder-again.log" | tr '\n' ' ')" + fi + else + row "linux-modules-extra-$kernel" "not installed" "$(tail -2 "$LOGS/modules-extra.log" | tr '\n' ' ')" + fi +fi +if grep -q binder /proc/filesystems && ! mountpoint -q /dev/binderfs; then + sudo mkdir -p /dev/binderfs + if run 30 binderfs sudo mount -t binder binder /dev/binderfs; then + row "binderfs mounted" ok "$(ls /dev/binderfs | tr '\n' ' ')" + else + row "binderfs mounted" failed "$(tail -2 "$LOGS/binderfs.log" | tr '\n' ' ')" + fi +fi +run 30 modprobe-ashmem sudo modprobe ashmem_linux +row "ashmem" "$([ -e /dev/ashmem ] && echo present || echo absent)" "Waydroid uses memfd without it" +lsmod | grep -E "binder|ashmem" > "$LOGS/lsmod.log" +ls -la /dev/binder* /dev/binderfs /dev/ashmem > "$LOGS/dev-after.log" 2>&1 +binder=no +{ [ -e /dev/binder ] || [ -e /dev/binderfs/binder ] || grep -q binder /proc/filesystems; } && binder=yes +row "binder available" "$binder" "$(tr '\n' ' ' < "$LOGS/lsmod.log" | cut -c1-200)" +[ "$binder" = yes ] || { verdict="no binder in this kernel: Waydroid cannot run here"; } + +# 3. Waydroid, from its official repository, and its images. +add_repository() { curl -fsSL --retry 3 https://repo.waydro.id | sudo bash; } +if run 180 repository add_repository && run 300 install sudo env DEBIAN_FRONTEND=noninteractive apt-get install -y -q waydroid weston adb; then + row "waydroid installed" ok "$(dpkg-query -W -f '${Version}' waydroid 2> /dev/null)" +else + row "waydroid installed" failed "$(tail -2 "$LOGS/install.log" 2> /dev/null | tr '\n' ' ')" + exit 0 +fi +[ "$binder" = yes ] || exit 0 +if run 600 init sudo waydroid init; then + row "waydroid init" ok "$(grep -iE "system|vendor" "$LOGS/init.log" | tail -2 | tr '\n' ' ' | cut -c1-200)" +else + row "waydroid init" failed "$(tail -3 "$LOGS/init.log" | tr '\n' ' ')" + exit 0 +fi + +# 4. The container, and a session under a headless Weston. +if run 90 container sudo systemctl restart waydroid-container; then + sleep 5 + row "container" "$(systemctl is-active waydroid-container)" "$(sudo waydroid status 2> /dev/null | tr '\n' ' ')" +else + row "container" failed "$(sudo journalctl -u waydroid-container --no-pager 2> /dev/null | tail -3 | tr '\n' ' ')" +fi +export XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR:-/run/user/$(id -u)}" +[ -d "$XDG_RUNTIME_DIR" ] || { sudo mkdir -p "$XDG_RUNTIME_DIR" && sudo chown "$(id -u)" "$XDG_RUNTIME_DIR" && chmod 700 "$XDG_RUNTIME_DIR"; } +weston --backend=headless --socket=wayland-probe --width=1080 --height=1920 > "$LOGS/weston.log" 2>&1 & +weston_pid=$! +sleep 5 +if kill -0 "$weston_pid" 2> /dev/null; then + row "weston (headless)" ok "" +else + row "weston (headless)" failed "$(tail -2 "$LOGS/weston.log" | tr '\n' ' ')" +fi +WAYLAND_DISPLAY=wayland-probe waydroid session start > "$LOGS/session.log" 2>&1 & +session_pid=$! + +# 5. Android booted, and adb. +booted=no +deadline=$((SECONDS + 300)) +while [ $SECONDS -lt $deadline ]; do + if [ "$(sudo timeout 20 waydroid shell getprop sys.boot_completed 2> /dev/null | tr -d '\r\n')" = 1 ]; then booted=yes; break; fi + kill -0 "$session_pid" 2> /dev/null || break + sleep 10 +done +status="$(sudo waydroid status 2> /dev/null)" +echo "$status" > "$LOGS/status.log" +row "waydroid status" info "$(tr '\n' ' ' <<< "$status")" +row "sys.boot_completed" "$booted" "after $((SECONDS - deadline + 300)) s" +ip="$(awk '/IP address/ {print $NF}' <<< "$status")" +if [ -n "$ip" ] && [ "$ip" != UNKNOWN ]; then + timeout 30 adb connect "$ip:5555" > "$LOGS/adb.log" 2>&1 + timeout 30 adb devices -l >> "$LOGS/adb.log" 2>&1 + model="$(timeout 20 adb -s "$ip:5555" shell getprop ro.product.model 2> /dev/null | tr -d '\r')" + release="$(timeout 20 adb -s "$ip:5555" shell getprop ro.build.version.release 2> /dev/null | tr -d '\r')" + row "adb devices" "$(grep -q "$ip:5555.*device" "$LOGS/adb.log" && echo connected || echo "not connected")" "$(tr '\n' ' ' < "$LOGS/adb.log" | cut -c1-200)" + [ -n "$release" ] && row "Android" ok "$model, Android $release" +else + row "adb devices" skipped "no IP from waydroid status" +fi +[ "$booted" = yes ] && verdict="Android booted under Waydroid on the hosted runner: GUI tests could run in the same job" +sudo waydroid log > "$LOGS/waydroid.log" 2>&1 +sudo dmesg 2> /dev/null | tail -200 > "$LOGS/dmesg.log" +# Stopped by their own PIDs and the service. +timeout 30 waydroid session stop > /dev/null 2>&1 +kill "$session_pid" "$weston_pid" 2> /dev/null +sudo systemctl stop waydroid-container > /dev/null 2>&1 +exit 0