diff --git a/.github/workflows/baseline-profile.yml b/.github/workflows/baseline-profile.yml deleted file mode 100644 index 67e25c1..0000000 --- a/.github/workflows/baseline-profile.yml +++ /dev/null @@ -1,67 +0,0 @@ -name: Baseline profile - -# Records a fresh app/src/main/baseline-prof.txt on an emulator and pushes it to the -# ci/baseline-profile branch for review. Run it from the Actions tab or push to profile/. -on: - workflow_dispatch: - push: - branches: ["profile/**"] - -permissions: - contents: write - -jobs: - profile: - if: github.server_url == 'https://github.com' - runs-on: ubuntu-latest - timeout-minutes: 90 - steps: - - uses: actions/checkout@v4 - - - uses: actions/setup-java@v4 - with: - distribution: temurin - java-version: 21 - - - uses: gradle/actions/setup-gradle@v4 - - # Rules must use the names from the source, so the profile is recorded on a build without R8 - - name: Build a non-minified release APK - run: | - sed -i 's/isMinifyEnabled = true/isMinifyEnabled = false/; s/isShrinkResources = true/isShrinkResources = false/' app/build.gradle.kts - ./gradlew :app:assembleRelease -q - keytool -genkeypair -keystore "$RUNNER_TEMP/p.jks" -storepass profile -keypass profile -alias p \ - -keyalg RSA -keysize 2048 -validity 365 -dname "CN=profile" >/dev/null 2>&1 - apksigner="$(ls -d "$ANDROID_HOME"/build-tools/*/ | sort -V | tail -n 1)apksigner" - "$apksigner" sign --ks "$RUNNER_TEMP/p.jks" --ks-pass pass:profile --out "$RUNNER_TEMP/app.apk" \ - app/build/outputs/apk/release/app-release-unsigned.apk - git checkout app/build.gradle.kts - - - name: Enable KVM - run: | - echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules - sudo udevadm control --reload-rules - sudo udevadm trigger --name-match=kvm - - - name: Record the profile - uses: reactivecircus/android-emulator-runner@v2 - with: - api-level: 34 - target: google_apis - arch: x86_64 - profile: pixel_6 - emulator-options: -no-snapshot -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none - script: bash scripts/baseline-profile.sh "$RUNNER_TEMP/app.apk" "$RUNNER_TEMP/baseline-prof.txt" - - - name: Push it for review - run: | - sort -u "$RUNNER_TEMP/baseline-prof.txt" > "$RUNNER_TEMP/sorted.txt" - git config user.name "github-actions[bot]" - git config user.email "41898282+github-actions[bot]@users.noreply.github.com" - git checkout --orphan profile-output - git rm -rq --cached . - cp "$RUNNER_TEMP/sorted.txt" baseline-prof.txt - git add baseline-prof.txt - git commit -qm "Baseline profile recorded from ${GITHUB_SHA::7}" - git push -f origin HEAD:refs/heads/ci/baseline-profile - echo "::notice title=Baseline profile::$(wc -l < baseline-prof.txt) rules pushed to ci/baseline-profile" diff --git a/.github/workflows/bench.yml b/.github/workflows/bench.yml deleted file mode 100644 index 6e17eb9..0000000 --- a/.github/workflows/bench.yml +++ /dev/null @@ -1,64 +0,0 @@ -name: Benchmark - -# Compares two revisions on one emulator: cold start, memory, background CPU, scroll jank, APK size. -# Run it from the Actions tab, or push the commit to measure to a bench/ branch. -on: - workflow_dispatch: - inputs: - base: - description: Baseline revision - default: origin/main - rounds: - description: Rounds per APK (each has 10 cold starts) - default: "3" - push: - branches: ["bench/**"] - -permissions: - contents: read - -jobs: - bench: - if: github.server_url == 'https://github.com' - runs-on: ubuntu-latest - timeout-minutes: 150 - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - uses: actions/setup-java@v4 - with: - distribution: temurin - java-version: 21 - - - uses: gradle/actions/setup-gradle@v4 - - - name: Build base and head APKs - run: bash scripts/bench-build.sh "${{ inputs.base || 'origin/main' }}" "${{ github.sha }}" "$RUNNER_TEMP/bench" - - - name: Enable KVM - run: | - echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules - sudo udevadm control --reload-rules - sudo udevadm trigger --name-match=kvm - - - name: Measure on the emulator - uses: reactivecircus/android-emulator-runner@v2 - with: - api-level: 34 - target: google_apis - arch: x86_64 - profile: pixel_6 - disable-animations: false - emulator-options: -no-snapshot -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none - script: bash scripts/bench.sh "$RUNNER_TEMP/bench/base.apk" "$RUNNER_TEMP/bench/head.apk" "${{ inputs.rounds || '3' }}" - - - uses: actions/upload-artifact@v4 - if: always() - with: - name: bench-results - path: | - ${{ runner.temp }}/bench/*.csv - ${{ runner.temp }}/bench/*.md - if-no-files-found: ignore diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 90e018b..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,53 +0,0 @@ -name: CI - -on: - push: - pull_request: - workflow_dispatch: - -permissions: - contents: read - -jobs: - build: - # The Gitea instance has no Android SDK on its runners; this only runs on the GitHub mirror - if: github.server_url == 'https://github.com' - runs-on: ubuntu-latest - timeout-minutes: 90 - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - uses: actions/setup-java@v4 - with: - distribution: temurin - java-version: 21 - - - uses: gradle/actions/setup-gradle@v4 - - - name: Build and unit-test every pushed commit - run: bash scripts/ci-check.sh "${{ github.event.before }}" "${{ github.sha }}" - - - name: Release build (R8) - run: ./gradlew :app:assembleRelease --stacktrace - - - name: APK size and key dependencies - run: | - apk=$(ls app/build/outputs/apk/release/*.apk | head -n 1) - echo "::notice title=Release APK::$(stat -c %s "$apk") bytes ($(basename "$apk"))" - prof=$(unzip -l "$apk" assets/dexopt/baseline.prof | awk '/baseline.prof/ {print $1}') - echo "::notice title=Baseline profile in APK::${prof:-missing} bytes" - deps=$(./gradlew -q :app:dependencies --configuration releaseRuntimeClasspath \ - | grep -oE '(androidx\.lifecycle:lifecycle-runtime-compose|androidx\.profileinstaller:profileinstaller|com\.squareup\.okhttp3:okhttp):[^ ]+( -> [^ ]+)?' \ - | sort -u | paste -sd ';' -) - echo "::notice title=Dependencies::$deps" - - - uses: actions/upload-artifact@v4 - if: always() - with: - name: apk - path: | - app/build/outputs/apk/**/*.apk - app/build/outputs/mapping/release/mapping.txt - if-no-files-found: ignore diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 44dbb5e..3faf44b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -89,7 +89,7 @@ If your code adds new strings, add them to `values/strings.xml`. Translations fo 1. Fork the repository and create a branch from `main`. 2. Keep one topic per pull request. 3. Follow the existing Kotlin and Jetpack Compose style; keep comments short and in English; don't reformat unrelated code. -4. Make sure `./gradlew assembleDebug testDebugUnitTest` passes, and test on a device or emulator. The GitHub mirror runs the same checks for every commit; for changes that may affect speed or memory, the Benchmark workflow there compares your branch with `main` on an emulator (`scripts/bench.sh` does the same on your own rooted device or emulator). +4. Make sure `./gradlew assembleDebug testDebugUnitTest` passes, and test on a device or emulator. For changes that may affect speed or memory, `scripts/bench.sh` compares two APKs on a rooted device or emulator (`scripts/bench-build.sh` builds them from two revisions). 5. Write short, plain commit messages in English (for example `Fix tunnel restart after server switch`). 6. Add screenshots for UI changes. diff --git a/scripts/ci-check.sh b/scripts/ci-check.sh deleted file mode 100755 index 37b2e07..0000000 --- a/scripts/ci-check.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env bash -# Builds and unit-tests every commit of a push, so each step of the history stays green. -# Usage: scripts/ci-check.sh -set -uo pipefail - -before="${1:-}" -head="$(git rev-parse "${2:-HEAD}")" -tasks=(:app:assembleDebug :app:testDebugUnitTest) - -commits=() -if [[ -n "$before" && ! "$before" =~ ^0+$ ]] \ - && git cat-file -e "$before^{commit}" 2>/dev/null \ - && git merge-base --is-ancestor "$before" "$head"; then - mapfile -t commits < <(git rev-list --reverse --max-count=30 "$before..$head") -fi -[[ ${#commits[@]} -eq 0 ]] && commits=("$head") - -# Turns the interesting part of a Gradle log into one annotation readable from the run page -report() { - local title="$1" log="$2" msg - msg="$(grep -E -A4 "^e: |FAILED|What went wrong|Exception|error:|AssertionError" "$log" | head -n 120)" - [[ -z "$msg" ]] && msg="$(tail -n 60 "$log")" - msg="${msg//'%'/'%25'}" - msg="${msg//$'\r'/}" - msg="${msg//$'\n'/'%0A'}" - echo "::error title=$title::$msg" -} - -status=0 -for c in "${commits[@]}"; do - subject="$(git log -1 --format='%h %s' "$c")" - echo "::group::$subject" - git checkout -q "$c" - if ! ./gradlew "${tasks[@]}" 2>&1 | tee build.log; then - report "Failed at ${c:0:7}" build.log - status=1 - fi - echo "::endgroup::" - [[ $status -ne 0 ]] && break -done - -git checkout -q "$head" -exit $status