Created
May 2, 2021 12:37
-
-
Save mostafa-elabady/0dddb02dff039b6f8b899d98b46dca89 to your computer and use it in GitHub Desktop.
PR Github Actions workflow for Android
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
name: Check PR | |
on: | |
# Triggers the workflow on every pull request to master branch | |
pull_request: | |
branches: | |
- master | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the code | |
uses: actions/checkout@v2 | |
- name: Load API Token from secrets | |
env: | |
API_TOKEN: ${{ secrets.API_OTKEN }} | |
run: echo API_TOKEN=\"$API_TOKEN\" > ./local.properties | |
- uses: actions/cache@v2 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/buildSrc/**/*.kt') }} | |
- name: Copy gradle properties file | |
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties | |
- name: Set up JDK 1.8 | |
uses: actions/setup-java@v1 | |
with: | |
java-version: 1.8 | |
- name: Build the app | |
run: ./gradlew assembleDebug | |
- name: Upload apk | |
uses: actions/upload-artifact@v2 | |
with: | |
name: debug apk | |
path: app/build/outputs/apk/debug/app-debug.apk | |
test: | |
runs-on: macos-latest | |
needs: build | |
strategy: | |
matrix: | |
api-level: [21, 23, 29] | |
target: [default] | |
steps: | |
- name: Checkout the code | |
uses: actions/checkout@v2 | |
- name: Load API Token from secrets | |
env: | |
API_TOKEN: ${{ secrets.API_OTKEN }} | |
run: echo API_TOKEN=\"$API_TOKEN\" > ./local.properties | |
- uses: actions/cache@v2 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/buildSrc/**/*.kt') }} | |
- name: Copy gradle properties file | |
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties | |
- name: Set up JDK 1.8 | |
uses: actions/setup-java@v1 | |
with: | |
java-version: 1.8 | |
- name: Run detekt | |
run: ./gradlew detektCheck | |
- name: Run unit tests | |
run: ./gradlew test --stacktrace | |
- name: Instrumentation Tests | |
uses: reactivecircus/android-emulator-runner@v2 | |
with: | |
api-level: ${{ matrix.api-level }} | |
target: ${{ matrix.target }} | |
arch: x86 | |
profile: Nexus 6 | |
script: ./gradlew connectedCheck --stacktrace | |
- name: Upload Reports | |
uses: actions/upload-artifact@v2 | |
with: | |
name: Test-Reports | |
path: app/build/reports | |
if: always() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment