Add files via upload #2
This file contains 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: Build | |
on: | |
# Trigger this workflow on push to the included branches | |
push: | |
branches: [main] | |
# Trigger this workflow on pull request against the included branches | |
pull_request: | |
branches: [main] | |
# Allows running this workflow manually from the actions tab | |
workflow_dispatch: | |
#Run the following jobs below | |
jobs: | |
#Job 1: Unit test | |
unit_test: | |
runs-on: ubuntu-latest | |
#Define the steps for this job | |
steps: | |
#Check out the code to the runner | |
- name: Checkout the code | |
uses: actions/checkout@v2 | |
#Cache Gradle | |
- name: Gradle cache | |
uses: actions/cache@v2 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/buildSrc/**/*.kt') }} | |
#Setup JDK on the runner | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v1 | |
with: | |
java-version: 11 | |
#Run the unit test | |
- name: Run unit test | |
run: ./gradlew testDebugUnitTest --stacktrace | |
#Upload generated test report to artifacts | |
- name: Upload Unit Test Report | |
uses: actions/upload-artifact@v2 | |
with: | |
name: Local Unit Test report | |
path: app/build/reports/tests | |
if-no-files-found: ignore | |
#Job 2: Build apk | |
build: | |
#this job is dependent on the success of other jobs listed below | |
needs: [unit_test] #depending job | |
runs-on: ubuntu-latest | |
steps: | |
#Check out the code to the runner | |
- name: Checkout the code | |
uses: actions/checkout@v2 | |
#Cache Gradle | |
- name: Gradle cache | |
uses: actions/cache@v2 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/buildSrc/**/*.kt') }} | |
#Setup JDK on the runner | |
- name: Use Java8 | |
uses: actions/setup-java@v1 | |
with: | |
java-version: 11 | |
#Build debug apk | |
- name: Build debug apk | |
run: ./gradlew clean assembleDebug --stacktrace | |
#Upload generated apk to artifacts | |
- name: Upload apk | |
uses: actions/upload-artifact@v2 | |
with: | |
name: Debug APK | |
path: app/build/outputs/apk/debug/app-debug.apk |