unit-tests.yml 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors
  2. # SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
  3. name: Unit tests
  4. on:
  5. pull_request:
  6. branches: [ master, stable-* ]
  7. push:
  8. branches: [ master, stable-* ]
  9. permissions:
  10. contents: read
  11. pull-requests: write
  12. concurrency:
  13. group: unit-tests-${{ github.head_ref || github.run_id }}
  14. cancel-in-progress: true
  15. jobs:
  16. test:
  17. runs-on: ubuntu-latest
  18. steps:
  19. - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
  20. - name: Set up JDK 17
  21. uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b # v4.5.0
  22. with:
  23. distribution: "temurin"
  24. java-version: 17
  25. - name: Delete old comments
  26. env:
  27. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  28. if: ${{ always() }}
  29. run: scripts/deleteOldComments.sh "test" "Unit" ${{github.event.number}}
  30. - name: Run unit tests with coverage
  31. uses: gradle/gradle-build-action@ac2d340dc04d9e1113182899e983b5400c17cda1 # v3.5.0
  32. with:
  33. arguments: jacocoTestGplayDebugUnitTest
  34. - name: Upload failing results
  35. if: ${{ failure() }}
  36. env:
  37. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  38. run: scripts/uploadReport.sh "${{ secrets.LOG_USERNAME }}" "${{ secrets.LOG_PASSWORD }}" ${{github.event.number}} "test" "Unit" ${{github.event.number}}
  39. - name: Upload coverage to codecov
  40. uses: codecov/codecov-action@015f24e6818733317a2da2edd6290ab26238649a # v5.0.7
  41. with:
  42. token: ${{ secrets.CODECOV_TOKEN }}
  43. flags: unit
  44. fail_ci_if_error: true
  45. - name: Upload jacoco artifacts
  46. if: ${{ failure() }}
  47. uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
  48. with:
  49. name: test-results
  50. path: app/build/reports/tests/testGplayDebugUnitTest/