Skip to content

Commit 7f7890d

Browse files
authored
Merge pull request #652 from BrawlerXull/integration/d1-d2-d5
GSoC 2026: retire CCSync, Rust FFI overhaul, reporting engine (#418), modularization, project website
2 parents f058b4a + 1524fc0 commit 7f7890d

138 files changed

Lines changed: 8249 additions & 5587 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Setup Rust for Android
2+
description: >
3+
Installs the Android NDK, a Rust toolchain with every Android target the app
4+
ships, and cargo-ndk — everything android/app/build.gradle's cargoBuildTcHelper
5+
task needs to compile libtc_helper.so from rust/ during the Gradle build.
6+
7+
Any workflow that builds an APK must use this. Without it the Gradle hook finds
8+
no cargo, prints "using committed jniLibs", and silently produces an APK whose
9+
native library is stale or (once the committed .so files are purged) absent —
10+
an APK that installs cleanly and then crashes at RustLib.init().
11+
12+
inputs:
13+
ndk-version:
14+
description: NDK version to install. Must satisfy the ring/taskchampion build.
15+
required: false
16+
default: "26.1.10909125"
17+
cargo-ndk-version:
18+
description: cargo-ndk version requirement.
19+
required: false
20+
default: "^4"
21+
22+
runs:
23+
using: composite
24+
steps:
25+
- uses: android-actions/setup-android@v3
26+
27+
- name: Install NDK ${{ inputs.ndk-version }}
28+
shell: bash
29+
run: |
30+
sdkmanager "ndk;${{ inputs.ndk-version }}"
31+
# cargo-ndk locates the clang cross-compilers through this variable.
32+
echo "ANDROID_NDK_HOME=$ANDROID_HOME/ndk/${{ inputs.ndk-version }}" >> "$GITHUB_ENV"
33+
34+
# The three targets correspond to the three ABIs Flutter builds
35+
# (arm64-v8a, armeabi-v7a, x86_64) and to the -t flags in
36+
# android/app/build.gradle. Adding an ABI means changing both.
37+
- name: Install Rust toolchain + Android targets
38+
shell: bash
39+
run: |
40+
rustup toolchain install stable --profile minimal
41+
rustup target add \
42+
aarch64-linux-android \
43+
armv7-linux-androideabi \
44+
x86_64-linux-android
45+
46+
# Compiling taskchampion for three targets is the slow part; cache it.
47+
- uses: Swatinem/rust-cache@v2
48+
with:
49+
workspaces: rust
50+
# Distinguishes this cache from any host-only Rust build.
51+
key: android-${{ inputs.ndk-version }}
52+
53+
- name: Install cargo-ndk
54+
shell: bash
55+
run: |
56+
# Note: the binary must be invoked as `cargo ndk`, never as `cargo-ndk` —
57+
# called directly it exits 1 with "This binary may only be called via
58+
# `cargo ndk`". command -v is the safe way to test for its presence.
59+
if command -v cargo-ndk >/dev/null 2>&1; then
60+
echo "cargo-ndk already present: $(cargo ndk --version)"
61+
else
62+
cargo install cargo-ndk --version '${{ inputs.cargo-ndk-version }}' --locked
63+
fi
64+
65+
# Diagnostics only. Guarded with || true so a future CLI change here can never
66+
# be the thing that fails a build — the APK verification is the real gate.
67+
- name: Report toolchain
68+
shell: bash
69+
run: |
70+
cargo --version || true
71+
cargo ndk --version || true
72+
echo "ANDROID_NDK_HOME=$ANDROID_NDK_HOME"
73+
rustup target list --installed | grep android || true
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Nightly Build & Log
2+
3+
# Scheduled canary: builds the signed nightly APK so a break is caught even on a
4+
# day with no commits. It deliberately publishes nothing — the F-Droid deploy and
5+
# the website build log are handled by nightlydepolyci.yml, which runs on push and
6+
# builds the site from the deploy branch where its source now lives.
7+
8+
on:
9+
schedule:
10+
- cron: '0 2 * * *' # 02:00 UTC daily
11+
workflow_dispatch:
12+
13+
permissions:
14+
contents: read # nothing is committed; this only proves the build still works
15+
16+
jobs:
17+
nightly:
18+
name: Build nightly APK and record build log
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Free Disk Space (Ubuntu)
22+
uses: jlumbroso/free-disk-space@main
23+
with:
24+
tool-cache: false
25+
android: false # keep Android SDKs for Flutter
26+
dotnet: true
27+
haskell: true
28+
large-packages: true
29+
docker-images: true
30+
swap-storage: true
31+
32+
- name: Checkout
33+
uses: actions/checkout@v4
34+
with:
35+
fetch-depth: 0
36+
37+
- uses: actions/setup-java@v4
38+
with:
39+
distribution: temurin
40+
java-version: '17.x'
41+
42+
# Rust + NDK + cargo-ndk, so the Gradle hook compiles libtc_helper.so from
43+
# rust/ instead of falling back to a prebuilt binary.
44+
- uses: ./.github/actions/setup-rust-android
45+
46+
- name: Setup Flutter
47+
uses: subosito/flutter-action@v2
48+
with:
49+
flutter-version: '3.29.2'
50+
51+
- name: Get dependencies
52+
run: flutter pub get
53+
54+
- name: Decode signing secrets
55+
env:
56+
NIGHTLY_KEYSTORE_B64: ${{ secrets.NIGHTLY_KEYSTORE_B64 }}
57+
NIGHTLY_PROPERTIES_B64: ${{ secrets.NIGHTLY_PROPERTIES_B64 }}
58+
run: |
59+
echo "$NIGHTLY_KEYSTORE_B64" | base64 --decode > android/nightly.jks
60+
echo "$NIGHTLY_PROPERTIES_B64" | base64 --decode > android/key_nightly.properties
61+
62+
- name: Build nightly APK
63+
id: build
64+
run: flutter build apk --flavor nightly --build-number=${{ github.run_number }} --release
65+
66+
# A missing native library produces an APK that installs and then crashes
67+
# at RustLib.init(), so fail the canary on it.
68+
- name: Verify native libraries are in the APK
69+
run: ./scripts/verify_apk_native_libs.sh build/app/outputs/flutter-apk/app-nightly-release.apk
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Compiles the tc_helper Rust native library from source (instead of relying on
2+
# the pre-built .so committed under android/app/src/main/jniLibs/) and then
3+
# builds the production APK against the freshly-compiled library.
4+
#
5+
# This is the "proper" fix for stale committed binaries: the .so is regenerated
6+
# from rust/ on every run, so it can never drift from the Rust source. Once this
7+
# is green, the committed jniLibs/*.so can be git-ignored and purged from history.
8+
#
9+
# This workflow has run green on CI (ubuntu-latest), so the NDK version and the
10+
# cargo-ndk invocation are known to work on a runner and not just locally. The
11+
# NDK + Rust setup has since moved to .github/actions/setup-rust-android, shared
12+
# with every workflow that builds an APK.
13+
#
14+
# All three ABIs Flutter builds are covered: arm64-v8a, armeabi-v7a and x86_64.
15+
# The list must stay in sync with android/app/build.gradle's cargoBuildTcHelper —
16+
# an ABI missing here ships an APK without libtc_helper.so that installs fine and
17+
# then crashes at RustLib.init(). taskchampion is configured with only
18+
# the server-sync backend (see rust/Cargo.toml), so there's no aws-lc-sys — hence
19+
# no cmake/ninja/bindgen/libclang toolchain needed; ring builds with just the
20+
# Rust + NDK toolchain.
21+
name: Build tc_helper (compile from source)
22+
23+
on:
24+
workflow_dispatch:
25+
pull_request:
26+
branches: [main, reports]
27+
paths:
28+
- "rust/**"
29+
- "android/**"
30+
- ".github/workflows/build-tc-helper.yml"
31+
32+
jobs:
33+
build:
34+
runs-on: ubuntu-latest
35+
steps:
36+
- uses: actions/checkout@v4
37+
38+
- uses: actions/setup-java@v4
39+
with:
40+
distribution: "temurin"
41+
java-version: "17"
42+
43+
# NDK + Rust + Android targets + cargo-ndk. Shared with the APK-building
44+
# workflows so the target list can't drift between them.
45+
- uses: ./.github/actions/setup-rust-android
46+
47+
- name: Compile tc_helper (arm64-v8a + armeabi-v7a + x86_64) from source
48+
working-directory: rust
49+
run: |
50+
cargo ndk -t arm64-v8a -t armeabi-v7a -t x86_64 \
51+
-o ../android/app/src/main/jniLibs \
52+
build --release
53+
54+
- name: Assert every ABI Flutter builds got a library
55+
run: |
56+
for abi in arm64-v8a armeabi-v7a x86_64; do
57+
f="android/app/src/main/jniLibs/$abi/libtc_helper.so"
58+
[ -f "$f" ] || { echo "::error::missing $f — the APK for $abi would crash at RustLib.init()"; exit 1; }
59+
echo "ok: $f"
60+
done
61+
62+
- name: Show freshly-built libs
63+
run: ls -lhR android/app/src/main/jniLibs/
64+
65+
- uses: subosito/flutter-action@v2
66+
with:
67+
flutter-version: "3.44.5"
68+
69+
- run: flutter pub get
70+
- run: flutter build apk --release --flavor production
71+
72+
# The step above asserts the libraries were *built*; this asserts they were
73+
# *packaged*. Both are needed — Gradle can silently drop a library it has.
74+
- name: Verify native libraries are in the APK
75+
run: ./scripts/verify_apk_native_libs.sh build/app/outputs/flutter-apk/app-production-release.apk
76+
77+
- uses: actions/upload-artifact@v4
78+
with:
79+
name: production-apk-from-source
80+
path: build/app/outputs/flutter-apk/app-production-release.apk

‎.github/workflows/flutterci.yml‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ jobs:
2020
distribution: "temurin"
2121
java-version: "17.x"
2222

23+
# Rust + NDK + cargo-ndk, so the Gradle hook compiles libtc_helper.so from
24+
# rust/ instead of falling back to a prebuilt binary. Must come before any
25+
# `flutter build apk`.
26+
- uses: ./.github/actions/setup-rust-android
27+
2328
# Step 3: Setup Flutter with version 3.7.11
2429
- uses: subosito/flutter-action@v1
2530
with:
@@ -40,6 +45,11 @@ jobs:
4045
# Step 8: Build APK using flutter build apk
4146
- run: flutter build apk --release --flavor production
4247

48+
# The APK must carry libtc_helper.so for every ABI, or it installs fine and
49+
# crashes at RustLib.init(). Fails the build rather than uploading a dud.
50+
- name: Verify native libraries are in the APK
51+
run: ./scripts/verify_apk_native_libs.sh build/app/outputs/flutter-apk/app-production-release.apk
52+
4353
# Step 9: Upload the built APK as an artifact
4454
- uses: actions/upload-artifact@v4
4555
with:

‎.github/workflows/nightlydepolyci.yml‎

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ on:
44
push:
55
branches:
66
- main
7+
# The website lives on the deploy branch now, so nothing here needs to be
8+
# excluded to avoid rebuilding the APK for a site-only change.
9+
paths-ignore:
10+
- '.github/workflows/build-nightly.yml'
711

812
jobs:
913
build-and-deploy:
@@ -35,6 +39,10 @@ jobs:
3539
distribution: "temurin"
3640
java-version: "17.x"
3741

42+
# Step 2b: Rust + NDK + cargo-ndk, so the Gradle hook compiles
43+
# libtc_helper.so from rust/ instead of falling back to a prebuilt binary.
44+
- uses: ./.github/actions/setup-rust-android
45+
3846
# Step 3: Setup Flutter
3947
- name: Setup Flutter
4048
uses: subosito/flutter-action@v2
@@ -58,10 +66,26 @@ jobs:
5866
- name: Build APK
5967
run: flutter build apk --flavor nightly --build-number=${{ github.run_number }} --release
6068

69+
# Step 6b: An APK missing its native library installs fine and then crashes
70+
# at RustLib.init() — fail here rather than deploying it to F-Droid.
71+
- name: Verify native libraries are in the APK
72+
run: ./scripts/verify_apk_native_libs.sh build/app/outputs/flutter-apk/app-nightly-release.apk
73+
6174
# Step 7: Verify the APK is signed
6275
- name: Verify sign
6376
run: keytool -printcert -jarfile build/app/outputs/flutter-apk/app-nightly-release.apk
6477

78+
# Step 7b: Capture which commit is being released.
79+
#
80+
# It has to be captured now: the job switches this work tree to the deploy
81+
# branch further down, and from that point git HEAD is that branch's own
82+
# orphan commit rather than the app commit. The site source lives on the
83+
# deploy branch, so the site itself is built after the switch.
84+
- name: Capture the deployed commit
85+
run: |
86+
echo "DEPLOY_SHA=${{ github.sha }}" >> "$GITHUB_ENV"
87+
echo "DEPLOY_MSG=$(git log -1 --pretty=%s)" >> "$GITHUB_ENV"
88+
6589
# Step 8: Configure git, fetch existing repo, and place new APK
6690
# We fetch the repo so we can see existing APKs to prune them in the next step.
6791
- name: Configure and Prepare Files
@@ -109,6 +133,36 @@ jobs:
109133
# Run the update command
110134
fdroid update -c
111135
136+
# Step 10b: Record the deploy and rebuild the site from this branch's own
137+
# source, then place it at the root. Additions only — repo/, metadata/ and
138+
# assets/ are untouched, so F-Droid clients are unaffected.
139+
- name: Record deploy and rebuild the website
140+
run: |
141+
set -e
142+
# website/ and scripts/ live on this branch, so they are on disk now.
143+
python3 scripts/update_build_log.py success \
144+
"https://github.com/${{ github.repository }}/raw/fdroid-repo/repo/nightly.${{ github.run_number }}.apk" \
145+
"${{ github.run_number }}" "$DEPLOY_SHA" "$DEPLOY_MSG"
146+
147+
# Pinned Hugo rather than a floating action, so a site build cannot
148+
# start failing because an upstream default moved.
149+
HUGO_VERSION=0.164.0
150+
curl -sSL -o /tmp/hugo.tar.gz \
151+
"https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz"
152+
tar -xzf /tmp/hugo.tar.gz -C /tmp hugo
153+
154+
/tmp/hugo --source website --destination /tmp/site --gc --minify \
155+
--baseURL "https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/"
156+
157+
# The generated CNAME is dropped on purpose: no custom domain is
158+
# configured, and committing one would make Pages claim a domain with
159+
# no DNS behind it — taking the site down and breaking the F-Droid repo
160+
# URL that clients already poll.
161+
rm -f /tmp/site/CNAME
162+
163+
cp -R /tmp/site/. .
164+
touch .nojekyll
165+
112166
# Step 11: Push a fresh history with NO bloat
113167
# This creates a temporary orphan branch (no parents) containing ONLY
114168
# the files currently on disk, then force pushes it to replace fdroid-repo.

‎android/app/build.gradle‎

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,61 @@ dependencies {
105105
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4'
106106
}
107107

108+
// ---------------------------------------------------------------------------
109+
// Auto-compile the tc_helper Rust native library on every Android build.
110+
//
111+
// When a Rust toolchain is available, this task cross-compiles rust/ with
112+
// cargo-ndk straight into src/main/jniLibs/<abi>/, so `flutter run` /
113+
// `flutter build` always package a library that matches the current Rust
114+
// source instead of a stale pre-built binary. It is wired into `preBuild`, so
115+
// it runs before the APK's native libraries are merged.
116+
//
117+
// If the toolchain is NOT present (rustup/cargo/cargo-ndk missing), the task
118+
// skips with a warning and the build falls back to the committed .so — so a
119+
// checkout without Rust still builds. (Once every build environment, including
120+
// CI, has the toolchain, the committed jniLibs can be git-ignored and removed.)
121+
//
122+
// The Android std targets are added on demand, so a fresh toolchain self-heals.
123+
// ---------------------------------------------------------------------------
124+
def rustCrateDir = file("${projectDir}/../../rust")
125+
def rustJniOut = "${projectDir}/src/main/jniLibs"
126+
def cargoBinDir = "${System.getenv('HOME')}/.cargo/bin"
127+
128+
def resolveNdkDir = {
129+
try {
130+
if (android.ndkDirectory != null) return android.ndkDirectory.absolutePath
131+
} catch (ignored) { /* no ndkVersion configured; fall through */ }
132+
def ndkRoot = new File(android.sdkDirectory, "ndk")
133+
if (ndkRoot.isDirectory()) {
134+
def versions = ndkRoot.listFiles()?.findAll { it.isDirectory() }?.sort { it.name }
135+
if (versions) return versions.last().absolutePath
136+
}
137+
return System.getenv("ANDROID_NDK_HOME")
138+
}
139+
140+
tasks.register("cargoBuildTcHelper", Exec) {
141+
workingDir rustCrateDir
142+
def ndkDir = resolveNdkDir()
143+
def cargoPath = "${cargoBinDir}:/opt/homebrew/bin:/usr/local/bin:${System.getenv('PATH')}"
144+
environment "PATH", cargoPath
145+
if (ndkDir != null) environment "ANDROID_NDK_HOME", ndkDir
146+
doFirst { new File(rustJniOut).mkdirs() }
147+
// If cargo/cargo-ndk aren't on PATH, skip (the committed .so is used as a
148+
// fallback) rather than failing the whole build. When they are present, a
149+
// real compile error DOES fail the build, so problems surface loudly.
150+
commandLine "sh", "-c",
151+
"if ! command -v cargo >/dev/null 2>&1 || ! command -v cargo-ndk >/dev/null 2>&1; then " +
152+
" echo 'cargoBuildTcHelper: Rust toolchain (cargo/cargo-ndk) not found — using committed jniLibs'; exit 0; " +
153+
"fi; " +
154+
"set -e; " +
155+
// Must cover every ABI Flutter builds (arm64-v8a, armeabi-v7a, x86_64),
156+
// or the APK for a missing one ships without libtc_helper.so and dies at
157+
// RustLib.init(). x86_64 is what the standard Android emulator runs.
158+
"rustup target add aarch64-linux-android armv7-linux-androideabi x86_64-linux-android >/dev/null 2>&1 || true; " +
159+
"cargo ndk -t arm64-v8a -t armeabi-v7a -t x86_64 -o \"${rustJniOut}\" build --release"
160+
}
161+
162+
tasks.matching { it.name == "preBuild" }.configureEach {
163+
dependsOn "cargoBuildTcHelper"
164+
}
165+
Binary file not shown.
-22.8 MB
Binary file not shown.
Binary file not shown.
-15.4 MB
Binary file not shown.

0 commit comments

Comments
 (0)