Repository navigation
build(deps): bump gradle-wrapper from 9.8.2 to 9.9.1 in the gradle-deps group across 1 directory #47
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ============================================================================= | |
| # Snishaper-Droid · Android CI | |
| # | |
| # 流程: | |
| # checkout → setup-java 17(需求对齐)→ setup-java 25(实际构建 JDK)→ | |
| # Android SDK/NDK(使用 runner 预装 SDK + sdkmanager 直装)→ setup-go 1.27 → | |
| # gcc → 安装 gomobile/gobind(固定版本)→ CI 切官方 Maven/Gradle 源 → | |
| # gomobile bind 生成 AAR(含 certmanager CA 支持)→ verify_aar.py 契约校验 → | |
| # gradlew lint test assembleDebug → 上传 APK/AAR artifacts | |
| # | |
| # PR 流程(与桌面版 build.yml 相同的 bot 状态机): | |
| # pull_request(opened/synchronize/reopened) → CLA gate → mark-running → | |
| # build → ci 汇总 → bot-report(失败诊断评论 / 状态标签) | |
| # 签署协议后 cla.yml rerun 本 workflow 的 pull_request run。 | |
| # | |
| # 说明: | |
| # * 不再使用 android-actions/setup-android@v3:该 action 在当前 ubuntu | |
| # 镜像上会执行 legacy `sdkmanager "tools"` 并失败。runner 镜像本身已预装 | |
| # Android SDK + cmdline-tools,直接调用 sdkmanager 安装组件即可。 | |
| # * 仓库默认使用华为云镜像(本机中国网络友好);CI 在海外 runner 上切回 | |
| # 官方 Maven / Gradle 源,避免镜像跨境慢或不可用。 | |
| # * 版本依据:Gradle 9.8.0 / AGP 9.4.1 / JDK 25 / compileSdk 36 / minSdk 24 / | |
| # NDK 30.0.16248370 / Go 1.27 / gomobile x/mobile v0.0.0-20260803200217-62cee1672c8e | |
| # ============================================================================= | |
| name: Android CI | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| workflow_dispatch: | |
| concurrency: | |
| group: android-ci-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| pull-requests: read | |
| env: | |
| # CI runner 在海外:优先官方 Go proxy / checksum DB(本机开发环境用 goproxy.cn)。 | |
| GOPROXY: https://proxy.golang.org,direct | |
| GOSUMDB: sum.golang.org | |
| # AndroidX dependencies require compileSdk >= 37; the released platform is android-37.2. | |
| COMPILE_SDK: "37" | |
| COMPILE_SDK_MINOR: "2" | |
| BUILD_TOOLS: "37.0.0" | |
| NDK_VERSION: "30.0.16248370" | |
| GOMOBILE_VERSION: "v0.0.0-20260803200217-62cee1672c8e" | |
| # ubuntu 预装 SDK 的固定位置(cache 路径与安装步骤共用) | |
| ANDROID_SDK_ROOT: /usr/local/lib/android/sdk | |
| jobs: | |
| # ------------------------------------------------------------------ | |
| # CLA gate — only for pull requests. Direct pushes to main and | |
| # manual dispatches skip it entirely. | |
| # ------------------------------------------------------------------ | |
| gate: | |
| name: gate | |
| if: github.event_name == 'pull_request' | |
| runs-on: ubuntu-26.04 | |
| outputs: | |
| proceed: ${{ steps.decide.outputs.proceed }} | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - name: Decide CLA gate | |
| id: decide | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| PR_NUMBER: ${{ github.event.pull_request.number }} | |
| AUTHOR: ${{ github.event.pull_request.user.login }} | |
| run: | | |
| set -euo pipefail | |
| source .github/scripts/bots/common.sh | |
| proceed=false | |
| if [ -n "${AUTHOR:-}" ] && is_exempt "$AUTHOR"; then | |
| proceed=true | |
| fi | |
| labels="$(gh_retry gh api "repos/${GH_REPO}/issues/${PR_NUMBER}/labels" --jq '.[].name')" | |
| if grep -qx 'cla-signed' <<<"$labels"; then | |
| proceed=true | |
| fi | |
| echo "proceed=$proceed" >> "$GITHUB_OUTPUT" | |
| # ------------------------------------------------------------------ | |
| # Mark the CI round as running as soon as the gate passes. | |
| # ------------------------------------------------------------------ | |
| mark-running: | |
| name: mark CI running | |
| needs: gate | |
| # Dependabot-triggered runs receive no repo secrets, so the syntax-bot | |
| # identity is unavailable there; skip the label state machine for those | |
| # PRs (gate still lets the build through). | |
| if: >- | |
| needs.gate.outputs.proceed == 'true' && | |
| github.actor != 'dependabot[bot]' | |
| runs-on: ubuntu-26.04 | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - uses: actions/create-github-app-token@v3 | |
| id: syntax_token | |
| with: | |
| app-id: ${{ secrets.SYNTAX_BOT_APP_ID }} | |
| private-key: ${{ secrets.SYNTAX_BOT_PRIVATE_KEY }} | |
| - name: Add ci-running label | |
| env: | |
| GH_TOKEN: ${{ steps.syntax_token.outputs.token }} | |
| PR_NUMBER: ${{ github.event.pull_request.number }} | |
| run: | | |
| set -euo pipefail | |
| source .github/scripts/bots/common.sh | |
| # sync_labels clears ci-failed/ci-passed (mutual-exclusion group) | |
| # plus syntax-review, changes-requested and approved (new round) | |
| # automatically. | |
| sync_labels "$PR_NUMBER" "ci-running" "" | |
| # ------------------------------------------------------------------ | |
| # Full Android build. Runs unconditionally for direct pushes / manual | |
| # dispatches; for pull requests only when the gate passed. | |
| # ------------------------------------------------------------------ | |
| build: | |
| name: AAR + APK/AAB | |
| needs: gate | |
| if: >- | |
| always() && !cancelled() && | |
| (github.event_name != 'pull_request' || needs.gate.outputs.proceed == 'true') | |
| runs-on: ubuntu-26.04 | |
| timeout-minutes: 90 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v7 | |
| with: | |
| fetch-depth: 0 | |
| # ----- JDK ------------------------------------------------------------- | |
| # 需求要求保留 JDK 17 步骤(与桌面端基线对齐);实际构建 JDK 为 25。 | |
| - name: Setup JDK 17 (requirement alignment; not used for the build) | |
| id: jdk17 | |
| uses: actions/setup-java@v6 | |
| with: | |
| distribution: temurin | |
| java-version: "17" | |
| - name: Setup JDK 25 (actual build JDK) | |
| id: jdk25 | |
| uses: actions/setup-java@v6 | |
| with: | |
| distribution: temurin | |
| java-version: "25" | |
| - name: Use JDK 25 as JAVA_HOME | |
| run: echo "JAVA_HOME=${{ steps.jdk25.outputs.java-home }}" >> "$GITHUB_ENV" | |
| # ----- Caches ---------------------------------------------------------- | |
| # Gradle wrapper 发行版 + 依赖缓存 + build cache(官方 action 维护) | |
| - name: Setup Gradle (dependency + build cache) | |
| uses: gradle/actions/setup-gradle@v6 | |
| # Android SDK 组件缓存:NDK ~1GB,跨 run 复用可省数分钟下载 | |
| - name: Cache Android SDK components (NDK / platform / build-tools) | |
| uses: actions/cache@v6 | |
| with: | |
| path: | | |
| ${{ env.ANDROID_SDK_ROOT }}/ndk/${{ env.NDK_VERSION }} | |
| ${{ env.ANDROID_SDK_ROOT }}/platforms/android-${{ env.COMPILE_SDK }}.${{ env.COMPILE_SDK_MINOR }} | |
| ${{ env.ANDROID_SDK_ROOT }}/build-tools/${{ env.BUILD_TOOLS }} | |
| # v3 namespace: the v2 cache entries are corrupt ( ar exits with 2 on restore) | |
| key: android-sdk-v3-${{ runner.os }}-api${{ env.COMPILE_SDK }}.${{ env.COMPILE_SDK_MINOR }}-bt${{ env.BUILD_TOOLS }}-ndk${{ env.NDK_VERSION }} | |
| restore-keys: | | |
| android-sdk-v3-${{ runner.os }}- | |
| # gomobile / gobind 二进制缓存(固定版本) | |
| - name: Cache gomobile toolchain | |
| uses: actions/cache@v6 | |
| with: | |
| path: | | |
| ~/go/bin/gomobile | |
| ~/go/bin/gobind | |
| key: gomobile-${{ runner.os }}-${{ env.GOMOBILE_VERSION }} | |
| restore-keys: | | |
| gomobile-${{ runner.os }}- | |
| # Go build cache:gomobile bind 的 cgo 编译产物跨 run 复用 | |
| - name: Cache Go build cache | |
| uses: actions/cache@v6 | |
| with: | |
| path: ~/.cache/go-build | |
| key: go-build-${{ runner.os }}-${{ hashFiles('gomobile/go.sum') }} | |
| restore-keys: | | |
| go-build-${{ runner.os }}- | |
| # ----- Android SDK / NDK ---------------------------------------------- | |
| - name: Install Android SDK components (preinstalled SDK on the runner) | |
| run: | | |
| set -euo pipefail | |
| SDK_ROOT="${ANDROID_SDK_ROOT:-/usr/local/lib/android/sdk}" | |
| echo "ANDROID_SDK_ROOT=${SDK_ROOT}" >> "$GITHUB_ENV" | |
| echo "ANDROID_HOME=${SDK_ROOT}" >> "$GITHUB_ENV" | |
| SDKMANAGER="${SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager" | |
| if [ ! -x "$SDKMANAGER" ]; then | |
| SDKMANAGER="$(command -v sdkmanager)" || { | |
| echo "::error::sdkmanager not found on the runner"; exit 1; | |
| } | |
| fi | |
| echo "Using sdkmanager: ${SDKMANAGER}" | |
| yes | "$SDKMANAGER" --licenses > /dev/null 2>&1 || true | |
| "$SDKMANAGER" --install \ | |
| "platform-tools" \ | |
| "platforms;android-${COMPILE_SDK}.${COMPILE_SDK_MINOR}" \ | |
| "build-tools;${BUILD_TOOLS}" \ | |
| "ndk;${NDK_VERSION}" | |
| echo "ANDROID_NDK_HOME=${SDK_ROOT}/ndk/${NDK_VERSION}" >> "$GITHUB_ENV" | |
| echo "ANDROID_NDK_ROOT=${SDK_ROOT}/ndk/${NDK_VERSION}" >> "$GITHUB_ENV" | |
| # ----- Go / gomobile / C toolchain ------------------------------------ | |
| - name: Setup Go 1.27 | |
| uses: actions/setup-go@v7 | |
| with: | |
| go-version: "1.27.x" | |
| cache-dependency-path: gomobile/go.sum | |
| - name: Check gcc (cgo toolchain) | |
| run: gcc --version | |
| - name: Install gomobile + gobind (pinned version) | |
| run: | | |
| set -euo pipefail | |
| go install "golang.org/x/mobile/cmd/gomobile@${GOMOBILE_VERSION}" | |
| go install "golang.org/x/mobile/cmd/gobind@${GOMOBILE_VERSION}" | |
| echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH" | |
| # ----- CI uses the official registries (runner is outside China) ------- | |
| - name: Use official Maven / Gradle repositories in CI | |
| run: | | |
| set -euo pipefail | |
| sed -i '/repo\.huaweicloud\.com/d' settings.gradle.kts | |
| sed -i 's#repo\.huaweicloud\.com/gradle#services.gradle.org/distributions#g' \ | |
| gradle/wrapper/gradle-wrapper.properties | |
| echo "--- settings.gradle.kts repositories ---" | |
| grep -E 'google\(\)|mavenCentral\(\)|gradlePluginPortal\(\)|maven\("' settings.gradle.kts || true | |
| echo "--- gradle-wrapper.properties ---" | |
| grep -E '^distributionUrl' gradle/wrapper/gradle-wrapper.properties | |
| # ----- AAR (gomobile bind, certmanager CA included) -------------------- | |
| - name: Build AAR | |
| run: | | |
| set -euo pipefail | |
| mkdir -p app/libs | |
| cd gomobile | |
| gomobile bind \ | |
| -target=android/arm64,android/arm,android/amd64 \ | |
| -androidapi 24 \ | |
| -tags with_gvisor \ | |
| -trimpath \ | |
| -ldflags="-s -w" \ | |
| -javapkg com.snishaper.core \ | |
| -o ../app/libs/snishaper-core.aar \ | |
| ./mobile | |
| cd .. | |
| ls -lh app/libs/snishaper-core.aar | |
| - name: Verify AAR contract (ABI / minSdk / 16KB) | |
| run: python3 scripts/verify_aar.py | |
| # ----- Frontend (reused desktop React bundle) -------------------------- | |
| # The Android UI is the desktop React frontend (React 19 + MUI 9) reused | |
| # verbatim: frontend-android/ builds with vite straight into | |
| # app/src/main/assets/frontend/ (APK assets). | |
| - name: Setup Node (frontend build) | |
| uses: actions/setup-node@v7 | |
| with: | |
| node-version: "20" | |
| cache: npm | |
| cache-dependency-path: frontend-android/package-lock.json | |
| - name: Build frontend bundle | |
| run: | | |
| set -euo pipefail | |
| cd frontend-android | |
| npm install --no-audit --no-fund | |
| npx vite build | |
| cd .. | |
| # relative-path guard (same check as scripts/build-frontend.ps1) | |
| test -f app/src/main/assets/frontend/index.html | |
| echo "--- frontend bundle ---" | |
| du -sh app/src/main/assets/frontend/assets | |
| # ----- Build ----------------------------------------------------------- | |
| # Regular CI builds a single-ABI debug APK (arm64) only; the full | |
| # multi-ABI release build lives in the release pipeline (tag-triggered). | |
| - name: Build (lint / test / assembleDebug arm64) | |
| run: | | |
| set -euo pipefail | |
| chmod +x gradlew | |
| # gradle.properties pins a Windows-only org.gradle.java.home; drop it in CI | |
| # so Gradle uses the JAVA_HOME set above. | |
| sed -i '/^org\.gradle\.java\.home=/d' gradle.properties | |
| ./gradlew --no-daemon --stacktrace lint test assembleDebug -PdebugAbi=arm64-v8a | |
| # ----- Artifacts ------------------------------------------------------- | |
| - name: Upload APK/AAR | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: snishaper-droid-${{ github.run_number }} | |
| path: | | |
| app/build/outputs/apk/debug/*.apk | |
| app/libs/snishaper-core.aar | |
| if-no-files-found: error | |
| retention-days: 14 | |
| - name: Upload lint/test reports on failure | |
| if: failure() | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: failure-reports-${{ github.run_number }} | |
| path: | | |
| app/build/reports/lint-results*.html | |
| app/build/reports/lint-results*.txt | |
| app/build/test-results/** | |
| app/build/reports/tests/** | |
| if-no-files-found: ignore | |
| retention-days: 7 | |
| # ------------------------------------------------------------------ | |
| # Stable single-point summary used as the required status check in | |
| # branch protection ("ci"). Succeeds when every build job succeeded | |
| # or was skipped; fails on any real failure so a red build blocks | |
| # the merge. | |
| # ------------------------------------------------------------------ | |
| ci: | |
| name: ci | |
| needs: [gate, build] | |
| if: always() && !cancelled() | |
| runs-on: ubuntu-26.04 | |
| steps: | |
| - name: Assert build outcome | |
| env: | |
| RESULTS: ${{ toJSON(needs) }} | |
| run: | | |
| failed="$(jq '[.[] | select(.result != "success" and .result != "skipped")] | length' <<<"$RESULTS")" | |
| if [ "$failed" -ne 0 ]; then | |
| echo "::error::one or more required CI jobs did not succeed" | |
| exit 1 | |
| fi | |
| echo "all required CI jobs succeeded (or were skipped)" | |
| # ------------------------------------------------------------------ | |
| # Bots — invoked directly from the build (no separate listener | |
| # workflow). Only for pull-request rounds that passed the gate; label | |
| # writes never re-trigger this workflow, so there is no feedback loop. | |
| # ------------------------------------------------------------------ | |
| bot-report: | |
| name: Report CI result (syntax-bot) | |
| needs: [gate, ci] | |
| if: >- | |
| always() && !cancelled() && | |
| needs.gate.outputs.proceed == 'true' && | |
| github.actor != 'dependabot[bot]' | |
| runs-on: ubuntu-26.04 | |
| permissions: | |
| # GITHUB_TOKEN grants for the diagnostic log download; comment and | |
| # label writes go through the syntax-bot App token instead. | |
| actions: read | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - uses: actions/create-github-app-token@v3 | |
| id: syntax_token | |
| with: | |
| app-id: ${{ secrets.SYNTAX_BOT_APP_ID }} | |
| private-key: ${{ secrets.SYNTAX_BOT_PRIVATE_KEY }} | |
| - name: Diagnose failure and mark changes requested | |
| if: needs.ci.result == 'failure' | |
| env: | |
| GH_TOKEN: ${{ steps.syntax_token.outputs.token }} | |
| LOG_GH_TOKEN: ${{ github.token }} | |
| PR_NUMBER: ${{ github.event.pull_request.number }} | |
| RUN_ID: ${{ github.run_id }} | |
| run: | | |
| set -euo pipefail | |
| source .github/scripts/bots/common.sh | |
| # Fresh comment per CI round (per-run anchor, no upsert): each | |
| # round shows up in the PR timeline with a notification instead | |
| # of silently editing an old comment. | |
| body="<!-- snishaper-bot:ci-diagnostic:${RUN_ID} --> | |
| $(.github/scripts/bots/ci-diagnose.sh "$PR_NUMBER" "$RUN_ID")" | |
| gh_retry gh api -X POST "repos/${GH_REPO}/issues/${PR_NUMBER}/comments" \ | |
| -f body="$body" >/dev/null | |
| # CI failure is itself a bot review verdict: mark the PR as | |
| # changes-requested so the state machine reaches its terminal | |
| # state without waiting for a human review. | |
| sync_labels "$PR_NUMBER" "ci-failed,changes-requested" "" | |
| - name: Mark CI passed and complete syntax review | |
| if: needs.ci.result == 'success' | |
| env: | |
| GH_TOKEN: ${{ steps.syntax_token.outputs.token }} | |
| PR_NUMBER: ${{ github.event.pull_request.number }} | |
| run: | | |
| set -euo pipefail | |
| source .github/scripts/bots/common.sh | |
| sync_labels "$PR_NUMBER" "ci-passed,syntax-review" "" |