ci: 增强 CI workflow——测试报告上传 + lint + Release APK 完整性验证
- 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 天
This commit is contained in:
parent
b7639a733e
commit
246f5dece3
98
.github/workflows/ci.yml
vendored
98
.github/workflows/ci.yml
vendored
@ -6,7 +6,8 @@ on:
|
|||||||
pull_request:
|
pull_request:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
test:
|
||||||
|
name: Unit Tests & Lint
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
@ -17,9 +18,96 @@ jobs:
|
|||||||
- uses: android-actions/setup-android@v3
|
- uses: android-actions/setup-android@v3
|
||||||
with:
|
with:
|
||||||
packages: 'platforms;android-35 build-tools;35.0.0'
|
packages: 'platforms;android-35 build-tools;35.0.0'
|
||||||
|
|
||||||
|
- name: Grant execute permission for gradlew
|
||||||
|
run: chmod +x gradlew
|
||||||
|
|
||||||
- name: Run unit tests
|
- name: Run unit tests
|
||||||
run: |
|
run: ./gradlew testDebugUnitTest
|
||||||
chmod +x gradlew
|
|
||||||
./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
|
- name: Assemble Debug
|
||||||
run: ./gradlew assembleDebug
|
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
|
||||||
Loading…
Reference in New Issue
Block a user