node-test.yml 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. # This workflow is provided via the organization template repository
  2. #
  3. # https://github.com/nextcloud/.github
  4. # https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
  5. #
  6. # SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors
  7. # SPDX-License-Identifier: MIT
  8. name: Node tests
  9. on:
  10. pull_request:
  11. schedule:
  12. - cron: "5 2 * * *"
  13. permissions:
  14. contents: read
  15. concurrency:
  16. group: node-tests-${{ github.head_ref || github.run_id }}
  17. cancel-in-progress: true
  18. jobs:
  19. changes:
  20. runs-on: ubuntu-latest-low
  21. outputs:
  22. src: ${{ steps.changes.outputs.src}}
  23. steps:
  24. - uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
  25. id: changes
  26. continue-on-error: true
  27. with:
  28. filters: |
  29. src:
  30. - '.github/workflows/**'
  31. - '**/__tests__/**'
  32. - '**/__mocks__/**'
  33. - 'apps/*/src/**'
  34. - 'apps/*/appinfo/info.xml'
  35. - 'core/src/**'
  36. - 'package.json'
  37. - 'package-lock.json'
  38. - 'tsconfig.json'
  39. - '**.js'
  40. - '**.ts'
  41. - '**.vue'
  42. versions:
  43. runs-on: ubuntu-latest-low
  44. needs: changes
  45. if: ${{ github.repository_owner != 'nextcloud-gmbh' && needs.changes.outputs.src != 'false' }}
  46. outputs:
  47. nodeVersion: ${{ steps.versions.outputs.nodeVersion }}
  48. npmVersion: ${{ steps.versions.outputs.npmVersion }}
  49. steps:
  50. - name: Checkout
  51. uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
  52. - name: Read package.json node and npm engines version
  53. uses: skjnldsv/read-package-engines-version-actions@06d6baf7d8f41934ab630e97d9e6c0bc9c9ac5e4 # v3
  54. id: versions
  55. with:
  56. fallbackNode: '^20'
  57. fallbackNpm: '^10'
  58. test:
  59. runs-on: ubuntu-latest
  60. needs: [versions, changes]
  61. if: ${{ needs.versions.result != 'failure' && needs.changes.outputs.src != 'false' }}
  62. env:
  63. CYPRESS_INSTALL_BINARY: 0
  64. PUPPETEER_SKIP_DOWNLOAD: true
  65. steps:
  66. - name: Checkout
  67. uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
  68. - name: Set up node ${{ needs.versions.outputs.nodeVersion }}
  69. uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
  70. with:
  71. node-version: ${{ needs.versions.outputs.nodeVersion }}
  72. - name: Set up npm ${{ needs.versions.outputs.npmVersion }}
  73. run: npm i -g 'npm@${{ needs.versions.outputs.npmVersion }}'
  74. - name: Install dependencies & build
  75. run: |
  76. npm ci
  77. npm run build --if-present
  78. - name: Test and process coverage
  79. run: npm run test:coverage --if-present
  80. - name: Collect coverage
  81. uses: codecov/codecov-action@922d8d7b314a529f2be903c1e79ee8283c492863 # v4.3.1
  82. with:
  83. files: ./coverage/lcov.info
  84. jsunit:
  85. runs-on: ubuntu-latest
  86. needs: [versions, changes]
  87. if: ${{ needs.versions.result != 'failure' && needs.changes.outputs.src != 'false' }}
  88. env:
  89. CYPRESS_INSTALL_BINARY: 0
  90. steps:
  91. - name: Checkout
  92. uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
  93. - name: Set up node ${{ needs.versions.outputs.nodeVersion }}
  94. uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
  95. with:
  96. node-version: ${{ needs.versions.outputs.nodeVersion }}
  97. - name: Set up npm ${{ needs.versions.outputs.npmVersion }}
  98. run: npm i -g 'npm@${{ needs.versions.outputs.npmVersion }}'
  99. - name: Install dependencies
  100. run: npm ci
  101. - name: Test
  102. run: npm run test:jsunit
  103. handlebars:
  104. runs-on: ubuntu-latest
  105. needs: [versions, changes]
  106. if: ${{ needs.versions.result != 'failure' && needs.changes.outputs.src != 'false' }}
  107. env:
  108. CYPRESS_INSTALL_BINARY: 0
  109. PUPPETEER_SKIP_DOWNLOAD: true
  110. steps:
  111. - name: Checkout
  112. uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
  113. - name: Set up node ${{ needs.versions.outputs.nodeVersion }}
  114. uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
  115. with:
  116. node-version: ${{ needs.versions.outputs.nodeVersion }}
  117. - name: Set up npm ${{ needs.versions.outputs.npmVersion }}
  118. run: npm i -g 'npm@${{ needs.versions.outputs.npmVersion }}'
  119. - name: Install dependencies
  120. run: npm ci
  121. - name: Run compile
  122. run: ./build/compile-handlebars-templates.sh
  123. summary:
  124. permissions:
  125. contents: none
  126. runs-on: ubuntu-latest-low
  127. needs: [changes, test, jsunit, handlebars]
  128. if: always()
  129. name: node-test-summary
  130. steps:
  131. - name: Summary status
  132. run: if ${{ needs.changes.outputs.src != 'false' && (needs.test.result != 'success' || needs.jsunit.result != 'success' || needs.handlebars.result != 'success') }}; then exit 1; fi