Skip to content

CI - reducing duplication #40

CI - reducing duplication

CI - reducing duplication #40

Workflow file for this run

name: Android CI-CD

Check failure on line 1 in .github/workflows/android.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/android.yml

Invalid workflow file

Cannot define both `uses` and `steps` at the same time for the following jobs: build, generate-apk, generate-apk-test, lint-check, unit-tests
on: push
# push:
# branches: [ main ]
# pull_request:
# branches: [ main ]
jobs:
build: # build app
name: 🔨 Build
runs-on: ubuntu-latest # machine the job is going to run inside
uses: ./.github/workflows/setup_java.yml
steps: # each job has a series of steps
- name: Checkout code
uses: actions/checkout@v3
- name: Access RAPID_API_KEY
env:
RAPID_API_KEY: $
run: echo RAPID_API_KEY=\"$RAPID_API_KEY\" > ./local.properties
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build # Execute gradle script to perform lint check
lint-check: # Run lint checks
name: 🔍 Lint
needs: [ build ]
runs-on: ubuntu-latest
uses: ./.github/workflows/setup_java.yml
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Lint check
run: ./gradlew lint
- name: Generate lint report
uses: actions/upload-artifact@v3
with: # Define extra parameters
name: lint_report.html # Name of the artifact to be uploaded
path: app/build/reports/lint-results-debug.html
unit-tests: # Run unit tests
name: 🧪 Unit Tests
needs: [ build ]
runs-on: ubuntu-latest
uses: ./.github/workflows/setup_java.yml
steps:
- name: Checkout code
uses: actions/checkout@v3
- run: echo "Execute unit tests."
- name: Unit Test
run: ./gradlew testDebugUnitTest
- name: Android Test Report
uses: asadmansr/android-test-report-action@v1.2.0
if: ${{ always() }}
generate-apk: # Generate debug apk
name: ⚙️ Generate APK
needs: [ build, unit-tests, lint-check ]
uses: ./.github/workflows/setup_java.yml
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Build debug apk
run: ./gradlew assembleDebug --stacktrace
- name: Upload debug apk
uses: actions/upload-artifact@v3
with:
name: Android-APP-APK
path: app/build/outputs/apk/debug/app-debug.apk
generate-apk-test: # Generate test apk
name: ⚙️ Generate Test APK
needs: [ build, unit-tests, lint-check ]
if: github.ref == 'refs/heads/main' # run only on main branch
runs-on: ubuntu-latest
uses: ./.github/workflows/setup_java.yml
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Build debug apk
run: ./gradlew assembleDebugAndroidTest --stacktrace
- name: Upload debug apk
uses: actions/upload-artifact@v3
with:
name: Android-APP-TEST-APK
path: app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk
firebase-deploy: # Deploy app to firebase app distribution
name: 📨 Deploy to Firebase App Distribution
needs: [ generate-apk ]
if: github.ref == 'refs/heads/main' # run only on main branch
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Download APK from build
uses: actions/download-artifact@v1
with:
name: Android-APP-APK
- name: Upload Artifact to Firebase App Distribution
uses: wzieba/Firebase-Distribution-Github-Action@v1
with:
appId: ${{secrets.FIREBASE_APP_ID}}
serviceCredentialsFileContent: ${{ secrets.CREDENTIAL_FILE_CONTENT }}
groups: testers
file: Android-APP-APK/app-debug.apk
releaseNotesFile: app/release_notes/release-notes.txt
firebase-lab-test: # Test APK with Firebase Test Labs
name: 🔬 Test APK with Firebase Test Lab
needs: [ generate-apk, generate-apk-test ]
if: github.ref == 'refs/heads/main' # run only on main branch
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
api: [ 30, 31, 32, 33 ]
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Download APK
uses: actions/download-artifact@v1
with:
name: Android-APP-APK
- name: Download TEST APK
uses: actions/download-artifact@v1
with:
name: Android-APP-TEST-APK
- name: Run tests on Firebase Test Lab for API ${{ matrix.api }}
uses: vacxe/firebase-test-lab-action@0.0.5
with:
app: Android-APP-APK/app-debug.apk
test: Android-APP-TEST-APK/app-debug-androidTest.apk
device-id: MediumPhone.arm
os-version-id: ${{ matrix.api }}
num-flaky-test-attempts: 4
env:
SERVICE_ACCOUNT: ${{ secrets.FIREBASE_TEST_LAB_JSON }}