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.8KB

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