Merge pull request #11 from element-hq/kaylendog/chore/v0.4.0 #33
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: Test | |
| on: | |
| workflow_dispatch: | |
| pull_request: | |
| merge_group: | |
| push: | |
| branches: [ main, develop ] | |
| # The repository is private, so jobs need contents read access for actions/checkout to work. | |
| permissions: | |
| contents: read | |
| # Enrich gradle.properties for CI/CD | |
| env: | |
| GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx7g -XX:MaxMetaspaceSize=512m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -Dkotlin.daemon.jvm.options=-Xmx2g -XX:+UseG1GC | |
| CI_GRADLE_ARG_PROPERTIES: --stacktrace --no-daemon --no-configuration-cache | |
| # Used by Gradle (settings.gradle.kts) to resolve the Neutrino bindings from GitHub Packages | |
| # (element-hq/neutrino). The default github.token cannot read packages from other repositories, | |
| # so a PAT with read:packages scope is used instead. | |
| GITHUB_TOKEN: ${{ secrets.ELEMENT_BOT_TOKEN_NEUTRINO }} | |
| 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: | |
| - name: Free Disk Space (Ubuntu) | |
| uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be | |
| with: | |
| # This might remove tools that are actually needed, if set to "true" but frees about 6 GB | |
| tool-cache: true | |
| # All of these default to true, but we should only need the 'android' one (and maybe swap-storage?) | |
| android: false | |
| dotnet: true | |
| haskell: true | |
| # This takes way too long to run (~2 minutes) and it saves only ~5.5GB | |
| large-packages: false | |
| docker-images: true | |
| swap-storage: false | |
| # 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/action-cached-lfs-checkout@385a8ecc719e50b8c71af6ab01a624b486b7c3bc # v1.2.5 | |
| 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: ☕️ Use JDK 21 | |
| uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0 | |
| with: | |
| distribution: 'temurin' # See 'Supported distributions' for available options | |
| java-version: '21' | |
| - name: Configure gradle | |
| uses: gradle/actions/setup-gradle@50e97c2cd7a37755bbfafc9c5b7cafaece252f6e # v6.1.0 | |
| with: | |
| cache-read-only: ${{ github.ref != 'refs/heads/develop' }} | |
| - name: ⚙️ Check coverage for debug variant (includes unit & screenshot tests) | |
| run: ./gradlew testDebugUnitTest :tests:uitests:verifyPaparazziDebug :koverXmlReportMerged :koverHtmlReportMerged :koverVerifyAll $CI_GRADLE_ARG_PROPERTIES | |
| - name: 🚫 Upload kover failed coverage reports | |
| if: failure() | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | |
| with: | |
| name: kover-error-report | |
| path: | | |
| app/build/reports/kover | |
| - name: 🚫 Upload test results on error | |
| if: failure() | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | |
| with: | |
| name: tests-and-screenshot-tests-results | |
| path: | | |
| **/build/paparazzi/failures/ | |
| **/build/roborazzi/failures/ | |
| **/build/reports/tests/*UnitTest/ | |
| - name: 🚫 Modify summary on error | |
| if: failure() | |
| run: | | |
| echo """## Tests failed! | |
| """ >> $GITHUB_STEP_SUMMARY | |
| python3 .github/workflows/scripts/parse_test_failures.py . >> $GITHUB_STEP_SUMMARY | |
| echo "---" >> $GITHUB_STEP_SUMMARY |