Update dagger to v2.52 (#3270) #3
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: Test | |
on: | |
workflow_dispatch: | |
pull_request: | |
merge_group: | |
push: | |
branches: [ main, develop ] | |
# Enrich gradle.properties for CI/CD | |
env: | |
GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx7g -XX:MaxMetaspaceSize=512m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -Dkotlin.incremental=false -XX:+UseG1GC | |
CI_GRADLE_ARG_PROPERTIES: --stacktrace -Dsonar.gradle.skipCompile=true | |
jobs: | |
tests: | |
name: Runs unit tests | |
runs-on: ubuntu-latest | |
# Allow all jobs on main and develop. Just one per PR. | |
concurrency: | |
group: ${{ github.ref == 'refs/heads/main' && format('unit-tests-main-{0}', github.sha) || github.ref == 'refs/heads/develop' && format('unit-tests-develop-{0}', github.sha) || format('unit-tests-{0}', github.ref) }} | |
cancel-in-progress: true | |
steps: | |
# Increase swapfile size to prevent screenshot tests getting terminated | |
# https://github.com/actions/runner-images/discussions/7188#discussioncomment-6750749 | |
- name: 💽 Increase swapfile size | |
run: | | |
sudo swapoff -a | |
sudo fallocate -l 8G /mnt/swapfile | |
sudo chmod 600 /mnt/swapfile | |
sudo mkswap /mnt/swapfile | |
sudo swapon /mnt/swapfile | |
sudo swapon --show | |
- name: ⏬ Checkout with LFS | |
uses: nschloe/[email protected] | |
with: | |
# Ensure we are building the branch and not the branch after being merged on develop | |
# https://github.com/actions/checkout/issues/881 | |
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.ref }} | |
- name: Add SSH private keys for submodule repositories | |
uses: webfactory/[email protected] | |
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'element-hq/element-x-android' }} | |
with: | |
ssh-private-key: ${{ secrets.ELEMENT_ENTERPRISE_DEPLOY_KEY }} | |
- name: Clone submodules | |
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'element-hq/element-x-android' }} | |
run: git submodule update --init --recursive | |
- name: ☕️ Use JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' # See 'Supported distributions' for available options | |
java-version: '17' | |
- name: Configure gradle | |
uses: gradle/actions/setup-gradle@v4 | |
with: | |
cache-read-only: ${{ github.ref != 'refs/heads/develop' }} | |
- name: ⚙️ Run unit tests for debug variant | |
run: ./gradlew testDebugUnitTest $CI_GRADLE_ARG_PROPERTIES | |
- name: 📸 Run screenshot tests | |
run: ./gradlew verifyPaparazziDebug $CI_GRADLE_ARG_PROPERTIES | |
- name: 📈Generate kover report and verify coverage | |
run: ./gradlew :app:koverXmlReportGplayDebug :app:koverHtmlReportGplayDebug :app:koverVerifyAll $CI_GRADLE_ARG_PROPERTIES | |
- name: 🚫 Upload kover failed coverage reports | |
if: failure() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: kover-error-report | |
path: | | |
app/build/reports/kover/verifyGplayDebug.err | |
- name: ✅ Upload kover report (disabled) | |
if: always() | |
run: echo "This is now done only once a day, see nightlyReports.yml" | |
- name: 🚫 Upload test results on error | |
if: failure() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: tests-and-screenshot-tests-results | |
path: | | |
**/build/paparazzi/failures/ | |
**/build/reports/tests/*UnitTest/ | |
# https://github.com/codecov/codecov-action | |
- name: ☂️ Upload coverage reports to codecov | |
uses: codecov/codecov-action@v4 | |
with: | |
fail_ci_if_error: true | |
token: ${{ secrets.CODECOV_TOKEN }} | |
files: app/build/reports/kover/reportGplayDebug.xml | |
verbose: true |