cypress.yml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. name: Cypress
  2. on:
  3. pull_request:
  4. push:
  5. branches:
  6. - master
  7. - stable*
  8. env:
  9. APP_NAME: server
  10. BRANCH: ${{ github.base_ref }}
  11. TESTING: true
  12. jobs:
  13. init:
  14. runs-on: ubuntu-latest
  15. outputs:
  16. nodeVersion: ${{ steps.versions.outputs.nodeVersion }}
  17. npmVersion: ${{ steps.versions.outputs.npmVersion }}
  18. steps:
  19. - name: Checkout app
  20. uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
  21. - name: Read package.json node and npm engines version
  22. uses: skjnldsv/read-package-engines-version-actions@0ce2ed60f6df073a62a77c0a4958dd0fc68e32e7 # v2.1
  23. id: versions
  24. with:
  25. fallbackNode: "^14"
  26. fallbackNpm: "^7"
  27. - name: Set up node ${{ steps.versions.outputs.nodeVersion }}
  28. uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
  29. with:
  30. cache: 'npm'
  31. node-version: ${{ steps.versions.outputs.nodeVersion }}
  32. - name: Set up npm ${{ steps.versions.outputs.npmVersion }}
  33. run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}"
  34. - name: Install dependencies & build app
  35. run: |
  36. npm ci
  37. TESTING=true npm run build --if-present
  38. - name: Save context
  39. uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
  40. with:
  41. key: cypress-context-${{ github.run_id }}
  42. path: ./
  43. cypress:
  44. runs-on: ubuntu-latest
  45. needs: init
  46. strategy:
  47. fail-fast: false
  48. matrix:
  49. # run multiple copies of the current job in parallel
  50. containers: ["component", 1, 2]
  51. name: runner ${{ matrix.containers }}
  52. steps:
  53. - name: Restore context
  54. uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
  55. with:
  56. fail-on-cache-miss: true
  57. key: cypress-context-${{ github.run_id }}
  58. path: ./
  59. - name: Set up node ${{ needs.init.outputs.nodeVersion }}
  60. uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
  61. with:
  62. cache: 'npm'
  63. node-version: ${{ needs.init.outputs.nodeVersion }}
  64. - name: Set up npm ${{ needs.init.outputs.npmVersion }}
  65. run: npm i -g npm@"${{ needs.init.outputs.npmVersion }}"
  66. - name: Run ${{ matrix.containers == 'component' && 'component' || 'E2E' }} cypress tests
  67. uses: cypress-io/github-action@db1693016f23ccf9043f4b2428f9b04e5d502a73 # v5.8.1
  68. with:
  69. record: true
  70. parallel: true
  71. # cypress run type
  72. component: ${{ matrix.containers == 'component' }}
  73. group: Run ${{ matrix.containers == 'component' && 'component' || 'E2E' }}
  74. # cypress env
  75. ci-build-id: ${{ github.sha }}-${{ github.run_number }}
  76. tag: ${{ github.event_name }}t
  77. env:
  78. # Needs to be prefixed with CYPRESS_
  79. CYPRESS_BRANCH: ${{ env.BRANCH }}
  80. CYPRESS_GH: true
  81. # https://github.com/cypress-io/github-action/issues/124
  82. COMMIT_INFO_MESSAGE: ${{ github.event.pull_request.title }}
  83. # Needed for some specific code workarounds
  84. TESTING: true
  85. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  86. CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
  87. - name: Extract NC logs
  88. if: failure() && matrix.containers != 'component'
  89. run: docker logs nextcloud-cypress-tests-server > nextcloud.log
  90. - name: Upload NC logs
  91. uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
  92. if: failure() && matrix.containers != 'component'
  93. with:
  94. name: nc_logs_${{ matrix.containers }}
  95. path: nextcloud.log
  96. - name: Create data dir archive
  97. if: failure() && matrix.containers != 'component'
  98. run: docker exec nextcloud-cypress-tests-server tar -cvjf - data > data.tar
  99. - name: Upload data dir archive
  100. uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
  101. if: failure() && matrix.containers != 'component'
  102. with:
  103. name: nc_data_${{ matrix.containers }}
  104. path: data.tar
  105. summary:
  106. runs-on: ubuntu-latest
  107. needs: [init, cypress]
  108. if: always()
  109. name: cypress-summary
  110. steps:
  111. - name: Summary status
  112. run: if ${{ needs.init.result != 'success' || ( needs.cypress.result != 'success' && needs.cypress.result != 'skipped' ) }}; then exit 1; fi