1
0

cypress.yml 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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 app
  22. uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
  23. - name: Check composer.json
  24. id: check_composer
  25. uses: andstor/file-existence-action@20b4d2e596410855db8f9ca21e96fbe18e12930b # v2
  26. with:
  27. files: "composer.json"
  28. - name: Install composer dependencies
  29. if: steps.check_composer.outputs.files_exists == 'true'
  30. run: composer install --no-dev
  31. - name: Read package.json node and npm engines version
  32. uses: skjnldsv/read-package-engines-version-actions@0ce2ed60f6df073a62a77c0a4958dd0fc68e32e7 # v2.1
  33. id: versions
  34. with:
  35. fallbackNode: "^14"
  36. fallbackNpm: "^7"
  37. - name: Set up node ${{ steps.versions.outputs.nodeVersion }}
  38. uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
  39. with:
  40. node-version: ${{ steps.versions.outputs.nodeVersion }}
  41. - name: Set up npm ${{ steps.versions.outputs.npmVersion }}
  42. run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}"
  43. - name: Install node dependencies & build app
  44. run: |
  45. npm ci
  46. TESTING=true npm run build --if-present
  47. - name: Save context
  48. uses: buildjet/cache/save@e376f15c6ec6dc595375c78633174c7e5f92dc0e # v3
  49. with:
  50. key: cypress-context-${{ github.run_id }}
  51. path: ./
  52. cypress:
  53. runs-on: ubuntu-latest
  54. needs: init
  55. strategy:
  56. fail-fast: false
  57. matrix:
  58. # Run multiple copies of the current job in parallel
  59. # Please increase the number or runners as your tests suite grows
  60. containers: ["component", 1, 2]
  61. name: runner ${{ matrix.containers }}
  62. steps:
  63. - name: Restore context
  64. uses: buildjet/cache/restore@e376f15c6ec6dc595375c78633174c7e5f92dc0e # v3
  65. with:
  66. fail-on-cache-miss: true
  67. key: cypress-context-${{ github.run_id }}
  68. path: ./
  69. - name: Set up node ${{ needs.init.outputs.nodeVersion }}
  70. uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
  71. with:
  72. node-version: ${{ needs.init.outputs.nodeVersion }}
  73. - name: Set up npm ${{ needs.init.outputs.npmVersion }}
  74. run: npm i -g npm@"${{ needs.init.outputs.npmVersion }}"
  75. - name: Run ${{ matrix.containers == 'component' && 'component' || 'E2E' }} cypress tests
  76. uses: cypress-io/github-action@d69252d52b9a31bad4f418f05ba2bc83687a02eb # v5.8.3
  77. with:
  78. record: true
  79. parallel: true
  80. # cypress run type
  81. component: ${{ matrix.containers == 'component' }}
  82. group: Run ${{ matrix.containers == 'component' && 'component' || 'E2E' }}
  83. # cypress env
  84. ci-build-id: ${{ github.sha }}-${{ github.run_number }}
  85. tag: ${{ github.event_name }}
  86. env:
  87. # Needs to be prefixed with CYPRESS_
  88. CYPRESS_BRANCH: ${{ env.BRANCH }}
  89. # https://github.com/cypress-io/github-action/issues/124
  90. COMMIT_INFO_MESSAGE: ${{ github.event.pull_request.title }}
  91. # Needed for some specific code workarounds
  92. TESTING: true
  93. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  94. CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
  95. - name: Upload snapshots
  96. uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
  97. if: always()
  98. with:
  99. name: snapshots_${{ matrix.containers }}
  100. path: cypress/snapshots
  101. - name: Extract NC logs
  102. if: failure() && matrix.containers != 'component'
  103. run: docker logs nextcloud-cypress-tests-${{ env.APP_NAME }} > nextcloud.log
  104. - name: Upload NC logs
  105. uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
  106. if: failure() && matrix.containers != 'component'
  107. with:
  108. name: nc_logs_${{ matrix.containers }}
  109. path: nextcloud.log
  110. - name: Create data dir archive
  111. if: failure() && matrix.containers != 'component'
  112. run: docker exec nextcloud-cypress-tests-server tar -cvjf - data > data.tar
  113. - name: Upload data dir archive
  114. uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
  115. if: failure() && matrix.containers != 'component'
  116. with:
  117. name: nc_data_${{ matrix.containers }}
  118. path: data.tar
  119. summary:
  120. runs-on: ubuntu-latest
  121. needs: [init, cypress]
  122. if: always()
  123. name: cypress-summary
  124. steps:
  125. - name: Summary status
  126. run: if ${{ needs.init.result != 'success' || ( needs.cypress.result != 'success' && needs.cypress.result != 'skipped' ) }}; then exit 1; fi