From 246f5dece3d5cdc63df48a97b17d355ed0bdef98 Mon Sep 17 00:00:00 2001 From: WaterRain <109326062+CATMIAOZHI@users.noreply.github.com> Date: Mon, 20 Jul 2026 09:10:35 +0000 Subject: [PATCH] =?UTF-8?q?ci:=20=E5=A2=9E=E5=BC=BA=20CI=20workflow?= =?UTF-8?q?=E2=80=94=E2=80=94=E6=B5=8B=E8=AF=95=E6=8A=A5=E5=91=8A=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=20+=20lint=20+=20Release=20APK=20=E5=AE=8C=E6=95=B4?= =?UTF-8?q?=E6=80=A7=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - test job: testDebugUnitTest + lintDebug,上传 XML 测试报告和 lint 报告 - build-debug job: assembleDebug,上传 Debug APK artifact - build-release job: assembleRelease + APK 完整性验证(manifest/arsc/res/),上传 Release APK artifact - test 通过后才构建,三个 job 串行依赖 - 所有 artifact 保留 14 天 --- .github/workflows/ci.yml | 98 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 93 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8f27e18..f57b3ad 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,7 +6,8 @@ on: pull_request: jobs: - build: + test: + name: Unit Tests & Lint runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -17,9 +18,96 @@ jobs: - uses: android-actions/setup-android@v3 with: packages: 'platforms;android-35 build-tools;35.0.0' + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Run unit tests - run: | - chmod +x gradlew - ./gradlew testDebugUnitTest + run: ./gradlew testDebugUnitTest + + - name: Upload test results + if: always() + uses: actions/upload-artifact@v4 + with: + name: unit-test-results + path: app/build/test-results/testDebugUnitTest/*.xml + retention-days: 14 + + - name: Run lint + run: ./gradlew lintDebug + + - name: Upload lint results + if: always() + uses: actions/upload-artifact@v4 + with: + name: lint-results + path: app/build/reports/lint-results-debug.* + retention-days: 14 + + build-debug: + name: Debug APK + runs-on: ubuntu-latest + needs: test + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + - uses: android-actions/setup-android@v3 + with: + packages: 'platforms;android-35 build-tools;35.0.0' + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Assemble Debug - run: ./gradlew assembleDebug \ No newline at end of file + run: ./gradlew assembleDebug + + - name: Upload Debug APK + uses: actions/upload-artifact@v4 + with: + name: debug-apk + path: app/build/outputs/apk/debug/app-debug.apk + retention-days: 14 + + build-release: + name: Release APK (no signing) + runs-on: ubuntu-latest + needs: test + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + - uses: android-actions/setup-android@v3 + with: + packages: 'platforms;android-35 build-tools;35.0.0' + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Assemble Release + run: ./gradlew assembleRelease + + - name: Verify Release APK + run: | + APK=app/build/outputs/apk/release/app-release.apk + if [ ! -f "$APK" ]; then + echo "❌ Release APK not found" + exit 1 + fi + echo "✅ Release APK size: $(du -h "$APK" | cut -f1)" + # Verify APK contains essential resources + unzip -l "$APK" | grep -q "AndroidManifest.xml" || { echo "❌ AndroidManifest.xml missing"; exit 1; } + unzip -l "$APK" | grep -q "resources.arsc" || { echo "❌ resources.arsc missing"; exit 1; } + unzip -l "$APK" | grep -q "res/" || { echo "❌ res/ directory missing"; exit 1; } + echo "✅ APK integrity verified: manifest + arsc + res/ all present" + + - name: Upload Release APK + uses: actions/upload-artifact@v4 + with: + name: release-apk + path: app/build/outputs/apk/release/app-release.apk + retention-days: 14 \ No newline at end of file