mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 21:03:54 +01:00
Update android.yml
This commit is contained in:
parent
876ca037d8
commit
f584e44110
1 changed files with 14 additions and 21 deletions
35
.github/workflows/android.yml
vendored
35
.github/workflows/android.yml
vendored
|
|
@ -19,14 +19,15 @@ concurrency:
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-upload:
|
build:
|
||||||
name: Run tests and generate APK
|
name: Run tests and generate APK
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
# Run this job for push, pull_request, and workflow_dispatch (not pull_request_target)
|
|
||||||
if: github.event_name == 'push' || github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch'
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
# Use base_ref for pull_request_target to avoid untrusted fork code
|
||||||
|
ref: ${{ github.event_name == 'pull_request_target' && github.base_ref || github.ref }}
|
||||||
|
|
||||||
- name: Set up JDK
|
- name: Set up JDK
|
||||||
uses: actions/setup-java@v3
|
uses: actions/setup-java@v3
|
||||||
|
|
@ -45,12 +46,14 @@ jobs:
|
||||||
restore-keys: gradle-packages-${{ runner.os }}
|
restore-keys: gradle-packages-${{ runner.os }}
|
||||||
|
|
||||||
- name: Access test login credentials
|
- name: Access test login credentials
|
||||||
|
# Skip secrets for pull_request_target to avoid exposing them to fork code
|
||||||
|
if: github.event_name != 'pull_request_target'
|
||||||
run: |
|
run: |
|
||||||
echo "TEST_USER_NAME=${{ secrets.TEST_USER_NAME }}" >> local.properties
|
echo "TEST_USER_NAME=${{ secrets.TEST_USER_NAME }}" >> local.properties
|
||||||
echo "TEST_USER_PASSWORD=${{ secrets.TEST_USER_PASSWORD }}" >> local.properties
|
echo "TEST_USER_PASSWORD=${{ secrets.TEST_USER_PASSWORD }}" >> local.properties
|
||||||
|
|
||||||
- name: AVD cache
|
- name: AVD cache
|
||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request' && github.event_name != 'pull_request_target'
|
||||||
uses: actions/cache@v3
|
uses: actions/cache@v3
|
||||||
id: avd-cache
|
id: avd-cache
|
||||||
with:
|
with:
|
||||||
|
|
@ -60,7 +63,7 @@ jobs:
|
||||||
key: avd-tablet-api-24
|
key: avd-tablet-api-24
|
||||||
|
|
||||||
- name: Create AVD and generate snapshot for caching
|
- name: Create AVD and generate snapshot for caching
|
||||||
if: steps.avd-cache.outputs.cache-hit != 'true' && github.event_name != 'pull_request'
|
if: steps.avd-cache.outputs.cache-hit != 'true' && github.event_name != 'pull_request' && github.event_name != 'pull_request_target'
|
||||||
uses: reactivecircus/android-emulator-runner@v2
|
uses: reactivecircus/android-emulator-runner@v2
|
||||||
with:
|
with:
|
||||||
api-level: 24
|
api-level: 24
|
||||||
|
|
@ -70,7 +73,7 @@ jobs:
|
||||||
script: echo "Generated AVD snapshot for caching."
|
script: echo "Generated AVD snapshot for caching."
|
||||||
|
|
||||||
- name: Run Instrumentation tests
|
- name: Run Instrumentation tests
|
||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request' && github.event_name != 'pull_request_target'
|
||||||
uses: reactivecircus/android-emulator-runner@v2
|
uses: reactivecircus/android-emulator-runner@v2
|
||||||
with:
|
with:
|
||||||
api-level: 24
|
api-level: 24
|
||||||
|
|
@ -85,15 +88,15 @@ jobs:
|
||||||
./gradlew connectedBetaDebugAndroidTest --stacktrace
|
./gradlew connectedBetaDebugAndroidTest --stacktrace
|
||||||
|
|
||||||
- name: Run Unit tests with unified coverage
|
- name: Run Unit tests with unified coverage
|
||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request' && github.event_name != 'pull_request_target'
|
||||||
run: ./gradlew -Pcoverage testBetaDebugUnitTestUnifiedCoverage --stacktrace
|
run: ./gradlew -Pcoverage testBetaDebugUnitTestUnifiedCoverage --stacktrace
|
||||||
|
|
||||||
- name: Run Unit tests without unified coverage
|
- name: Run Unit tests without unified coverage
|
||||||
if: github.event_name == 'pull_request'
|
if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
|
||||||
run: ./gradlew -Pcoverage testBetaDebugUnitTestCoverage --stacktrace
|
run: ./gradlew -Pcoverage testBetaDebugUnitTestCoverage --stacktrace
|
||||||
|
|
||||||
- name: Upload Test Report to Codecov
|
- name: Upload Test Report to Codecov
|
||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request' && github.event_name != 'pull_request_target'
|
||||||
run: |
|
run: |
|
||||||
curl -Os https://uploader.codecov.io/latest/linux/codecov
|
curl -Os https://uploader.codecov.io/latest/linux/codecov
|
||||||
chmod +x codecov
|
chmod +x codecov
|
||||||
|
|
@ -117,20 +120,10 @@ jobs:
|
||||||
name: prodDebugAPK
|
name: prodDebugAPK
|
||||||
path: app/build/outputs/apk/prod/debug/app-*.apk
|
path: app/build/outputs/apk/prod/debug/app-*.apk
|
||||||
|
|
||||||
comment-on-pr:
|
|
||||||
name: Comment on PR with APK links
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
if: github.event_name == 'pull_request_target'
|
|
||||||
needs: build-and-upload
|
|
||||||
steps:
|
|
||||||
- name: Checkout base branch
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
ref: ${{ github.base_ref }}
|
|
||||||
|
|
||||||
- name: Comment on PR with APK download links
|
- name: Comment on PR with APK download links
|
||||||
|
if: github.event_name == 'pull_request_target' # Only run for pull_request_target to ensure write permissions
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # GITHUB_TOKEN has write permissions in pull_request_target
|
||||||
uses: actions/github-script@v6
|
uses: actions/github-script@v6
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue