You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cypress.yml 5.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. name: Cypress
  2. on: pull_request
  3. concurrency:
  4. group: cypress-${{ github.head_ref || github.run_id }}
  5. cancel-in-progress: true
  6. env:
  7. # Adjust APP_NAME if your repository name is different
  8. APP_NAME: ${{ github.event.repository.name }}
  9. # Server requires head_ref instead of base_ref, as we want to test the PR branch
  10. BRANCH: ${{ github.head_ref || github.ref_name }}
  11. jobs:
  12. init:
  13. runs-on: ubuntu-latest
  14. outputs:
  15. nodeVersion: ${{ steps.versions.outputs.nodeVersion }}
  16. npmVersion: ${{ steps.versions.outputs.npmVersion }}
  17. env:
  18. PUPPETEER_SKIP_DOWNLOAD: true
  19. steps:
  20. - name: Checkout server
  21. uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
  22. with:
  23. # We need to checkout submodules for 3rdparty
  24. submodules: true
  25. - name: Check composer.json
  26. id: check_composer
  27. uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 # v2
  28. with:
  29. files: "composer.json"
  30. - name: Install composer dependencies
  31. if: steps.check_composer.outputs.files_exists == 'true'
  32. run: composer install --no-dev
  33. - name: Read package.json node and npm engines version
  34. uses: skjnldsv/read-package-engines-version-actions@8205673bab74a63eb9b8093402fd9e0e018663a1 # v2.2
  35. id: versions
  36. with:
  37. fallbackNode: "^20"
  38. fallbackNpm: "^9"
  39. - name: Set up node ${{ steps.versions.outputs.nodeVersion }}
  40. uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
  41. with:
  42. node-version: ${{ steps.versions.outputs.nodeVersion }}
  43. - name: Set up npm ${{ steps.versions.outputs.npmVersion }}
  44. run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}"
  45. - name: Install node dependencies & build app
  46. run: |
  47. npm ci
  48. TESTING=true npm run build --if-present
  49. - name: Show cypress version
  50. run: npm run cypress:version
  51. - name: Save context
  52. uses: buildjet/cache/save@e376f15c6ec6dc595375c78633174c7e5f92dc0e # v3
  53. with:
  54. key: cypress-context-${{ github.run_id }}
  55. path: ./
  56. cypress:
  57. runs-on: ubuntu-latest
  58. needs: init
  59. strategy:
  60. fail-fast: false
  61. matrix:
  62. # Run multiple copies of the current job in parallel
  63. # Please increase the number or runners as your tests suite grows (0 based index for e2e tests)
  64. containers: ["component", 0, 1, 2, 3, 4, 5]
  65. # Hack as strategy.job-total includes the component and GitHub does not allow math expressions
  66. # Always aling this number with the total of e2e runners (max. index + 1)
  67. total-containers: [6]
  68. name: runner ${{ matrix.containers }}
  69. steps:
  70. - name: Restore context
  71. uses: buildjet/cache/restore@e376f15c6ec6dc595375c78633174c7e5f92dc0e # v3
  72. with:
  73. fail-on-cache-miss: true
  74. key: cypress-context-${{ github.run_id }}
  75. path: ./
  76. - name: Set up node ${{ needs.init.outputs.nodeVersion }}
  77. uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
  78. with:
  79. node-version: ${{ needs.init.outputs.nodeVersion }}
  80. - name: Set up npm ${{ needs.init.outputs.npmVersion }}
  81. run: npm i -g npm@"${{ needs.init.outputs.npmVersion }}"
  82. - name: Run ${{ matrix.containers == 'component' && 'component' || 'E2E' }} cypress tests
  83. uses: cypress-io/github-action@1b70233146622b69e789ccdd4f9452adc638d25a # v6.6.1
  84. with:
  85. component: ${{ matrix.containers == 'component' }}
  86. group: ${{ matrix.use-cypress-cloud && matrix.containers == 'component' && 'Run component' || matrix.use-cypress-cloud && 'Run E2E' || '' }}
  87. # cypress env
  88. ci-build-id: ${{ matrix.use-cypress-cloud && format('{0}-{1}', github.sha, github.run_number) || '' }}
  89. tag: ${{ matrix.use-cypress-cloud && github.event_name || '' }}
  90. env:
  91. # Needs to be prefixed with CYPRESS_
  92. CYPRESS_BRANCH: ${{ env.BRANCH }}
  93. # https://github.com/cypress-io/github-action/issues/124
  94. COMMIT_INFO_MESSAGE: ${{ github.event.pull_request.title }}
  95. # Needed for some specific code workarounds
  96. TESTING: true
  97. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  98. CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
  99. SPLIT: ${{ matrix.total-containers }}
  100. SPLIT_INDEX: ${{ matrix.containers == 'component' && 0 || matrix.containers }}
  101. - name: Upload snapshots
  102. uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
  103. if: always()
  104. with:
  105. name: snapshots_${{ matrix.containers }}
  106. path: cypress/snapshots
  107. - name: Extract NC logs
  108. if: failure() && matrix.containers != 'component'
  109. run: docker logs nextcloud-cypress-tests-${{ env.APP_NAME }} > nextcloud.log
  110. - name: Upload NC logs
  111. uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
  112. if: failure() && matrix.containers != 'component'
  113. with:
  114. name: nc_logs_${{ matrix.containers }}
  115. path: nextcloud.log
  116. - name: Create data dir archive
  117. if: failure() && matrix.containers != 'component'
  118. run: docker exec nextcloud-cypress-tests-server tar -cvjf - data > data.tar
  119. - name: Upload data dir archive
  120. uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
  121. if: failure() && matrix.containers != 'component'
  122. with:
  123. name: nc_data_${{ matrix.containers }}
  124. path: data.tar
  125. summary:
  126. runs-on: ubuntu-latest-low
  127. needs: [init, cypress]
  128. if: always()
  129. name: cypress-summary
  130. steps:
  131. - name: Summary status
  132. run: if ${{ needs.init.result != 'success' || ( needs.cypress.result != 'success' && needs.cypress.result != 'skipped' ) }}; then exit 1; fi