Skip to content

Run Unit Tests

Run Unit Tests #8605

name: "Run Unit Tests"
on:
merge_group:
pull_request:
types: [ opened, synchronize ] # Don't rerun on `edited` to save time
workflow_call:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
detekt:
uses: ./.github/workflows/codestyle.yml
unit-tests:
needs: [detekt]
runs-on: buildjet-8vcpu-ubuntu-2204
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive # Needed in order to fetch Kalium sources for building
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'
cache: gradle
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@56b90f209b02bf6d1deae490e9ef18b21a389cd4
- name: Gradle cache
uses: gradle/gradle-build-action@v2
- name: Test Build Logic
run: |
./gradlew -p buildSrc test
./gradlew -p build-logic :plugins:test
- name: Test with coverage
run: ./gradlew testCoverage
env:
GITHUB_USER: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install Pip for test result publishing
run: sudo apt-get install -y python3-pip
# Uploads test results as GitHub artifacts, so publish-test-results can find them later.
- name: Upload Test Results
uses: actions/upload-artifact@v3
if: always()
with:
# This name is referenced in the publish-test-results workflow.
name: test-results
path: |
**/build/test-results/testDevDebugUnitTest/**/*.xml
**/build/test-results/**/*.xml
**/build/outputs/androidTest-results/**/*.xml
- name: Generate report
uses: actions/upload-artifact@v3
with:
name: report
path: app/build/reports/jacoco
- name: Download Test Reports Folder
uses: actions/download-artifact@v3
with:
name: report
path: app/build/reports/jacoco
- name: Upload Test Report
uses: codecov/codecov-action@v3
with:
files: "app/build/reports/jacoco/jacocoReport/jacocoReport.xml"
- name: Cleanup Gradle Cache
# Remove some files from the Gradle cache, so they aren't cached by GitHub Actions.
# Restoring these files from a GitHub Actions cache might cause problems for future builds.
run: |
rm -f ~/.gradle/caches/modules-2/modules-2.lock
rm -f ~/.gradle/caches/modules-2/gc.properties
build-beta:
if: ${{ github.event_name == 'pull_request' }}
needs: [unit-tests]
uses: ./.github/workflows/build-app.yml
with:
flavour: "beta-debug"
build-dev:
if: ${{ github.event_name == 'pull_request' }}
needs: [unit-tests]
uses: ./.github/workflows/build-app.yml
with:
flavour: "dev-debug"
event_file:
# This name is referenced in the publish-test-results workflow.
name: "Upload Event File"
runs-on: ubuntu-latest
steps:
- name: Upload
uses: actions/upload-artifact@v3
with:
name: Event File
path: ${{ github.event_path }}