ProCraft for Android: An Android native painting app written in Rust
Rust
ci: format, clippy, tests, lint, unit tests and the 16 KB check on every push
Joshc849841dab13
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlnew file mode 100644index 0000000..848b7db--- /dev/null+++ b/.github/workflows/ci.yml@@ -0,0 +1,83 @@+name: CI++on:+ push:+ branches: [main]+ pull_request:++permissions:+ contents: read++concurrency:+ group: ci-${{ github.ref }}+ cancel-in-progress: true++env:+ CARGO_TERM_COLOR: always+ RUST_VERSION: "1.99.0"+ NDK_VERSION: "29.0.14206865"++jobs:+ rust:+ name: Rust (format, clippy, tests)+ runs-on: ubuntu-24.04+ steps:+ - uses: actions/checkout@v4+ - uses: dtolnay/rust-toolchain@master+ with:+ toolchain: ${{ env.RUST_VERSION }}+ components: rustfmt, clippy+ - uses: Swatinem/rust-cache@v2+ - run: cargo fmt --all --check+ - run: cargo clippy --workspace --all-targets -- -D warnings+ # the GPU tests skip themselves: the runner has no GPU+ - run: cargo test --workspace++ android:+ name: Android (clippy, lint, unit tests, release APK)+ runs-on: ubuntu-24.04+ steps:+ - uses: actions/checkout@v4+ - uses: actions/setup-java@v4+ with:+ distribution: temurin+ java-version: "17"+ - uses: dtolnay/rust-toolchain@master+ with:+ toolchain: ${{ env.RUST_VERSION }}+ targets: aarch64-linux-android, x86_64-linux-android+ components: clippy+ - uses: Swatinem/rust-cache@v2+ - name: cargo-ndk+ run: cargo install cargo-ndk --version "^4" --locked+ - name: NDK+ run: |+ yes | "$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" --install "ndk;$NDK_VERSION" > /dev/null+ echo "ANDROID_NDK_HOME=$ANDROID_HOME/ndk/$NDK_VERSION" >> "$GITHUB_ENV"+ # the code only Android builds (the surface and the render thread)+ - name: Clippy for Android+ run: cargo ndk -t arm64-v8a --platform 29 clippy -p procraft-android --lib -- -D warnings+ - uses: gradle/actions/setup-gradle@v4+ - name: Release APK and lint+ working-directory: apps/procraft-android/android+ run: ./gradlew --no-daemon :app:assembleRelease :app:lintRelease+ - name: Unit tests+ working-directory: apps/procraft-android/android+ run: ./gradlew --no-daemon :app:testDebugUnitTest -Pprocraft.abis=x86_64+ - name: 16 KB pages+ run: |+ apk=apps/procraft-android/android/app/build/outputs/apk/release/app-release.apk+ tools="$ANDROID_HOME/build-tools/$(ls "$ANDROID_HOME/build-tools" | sort -V | tail -1)"+ "$tools/zipalign" -c -P 16 -v 4 "$apk" > /dev/null+ readelf="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-readelf"+ dir=$(mktemp -d)+ unzip -q "$apk" 'lib/*' -d "$dir"+ for so in "$dir"/lib/*/*.so; do+ for align in $("$readelf" -lW "$so" | awk '$1 == "LOAD" { print $NF }'); do+ if [ $((align)) -lt 16384 ]; then+ echo "$so: a segment aligned to $align"+ exit 1+ fi+ done+ done+ echo "every library's segments are aligned to 16 KB"diff --git a/apps/procraft-android/android/gradlew b/apps/procraft-android/android/gradlewold mode 100644new mode 100755