e2e.yml 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. name: End-to-end tests
  2. on:
  3. push:
  4. branches: [main, 4.x]
  5. paths-ignore:
  6. - '**.md'
  7. - '**.d.ts'
  8. - 'examples/**'
  9. - 'private/**'
  10. - 'website/**'
  11. - '.github/**'
  12. - '!.github/workflows/e2e.yml'
  13. pull_request_target:
  14. types: [opened, synchronize, reopened, labeled]
  15. paths-ignore:
  16. - '**.md'
  17. - '**.d.ts'
  18. - 'examples/**'
  19. - 'private/**'
  20. - 'website/**'
  21. - '.github/**'
  22. pull_request:
  23. types: [opened, synchronize, reopened]
  24. paths:
  25. - .github/workflows/e2e.yml
  26. concurrency: ${{ github.workflow }}--${{ github.ref }}
  27. env:
  28. YARN_ENABLE_GLOBAL_CACHE: false
  29. jobs:
  30. e2e:
  31. if:
  32. ${{ !github.event.pull_request ||
  33. (contains(github.event.pull_request.labels.*.name, 'safe to test') &&
  34. github.event.pull_request.state == 'open') ||
  35. (github.event.pull_request.head.repo.full_name == github.repository &&
  36. github.event.event_name != 'labeled') }}
  37. name: Browser tests
  38. runs-on: ubuntu-latest
  39. steps:
  40. - name: Checkout sources
  41. uses: actions/checkout@v3
  42. with:
  43. ref: ${{ github.event.pull_request.head.sha || github.sha }}
  44. - name: Get yarn cache directory path
  45. id: yarn-cache-dir-path
  46. run:
  47. echo "dir=$(corepack yarn config get cacheFolder)" >> $GITHUB_OUTPUT
  48. - uses: actions/cache@v3
  49. id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
  50. with:
  51. path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
  52. key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
  53. restore-keys: |
  54. ${{ runner.os }}-yarn-
  55. - name: Create cache folder for Cypress
  56. id: cypress-cache-dir-path
  57. run: echo "dir=$(mktemp -d)" >> $GITHUB_OUTPUT
  58. - uses: actions/cache@v3
  59. with:
  60. path: ${{ steps.cypress-cache-dir-path.outputs.dir }}
  61. key: ${{ runner.os }}-cypress
  62. - name: Install Node.js
  63. uses: actions/setup-node@v3
  64. with:
  65. node-version: lts/*
  66. - name: Start Redis
  67. uses: supercharge/redis-github-action@1.4.0
  68. with:
  69. redis-version: 7
  70. - name: Install dependencies
  71. run: corepack yarn install --immutable
  72. env:
  73. # https://docs.cypress.io/guides/references/advanced-installation#Binary-cache
  74. CYPRESS_CACHE_FOLDER: ${{ steps.cypress-cache-dir-path.outputs.dir }}
  75. - name: Build Uppy packages
  76. run: corepack yarn build
  77. - name: Run end-to-end browser tests
  78. run: corepack yarn run e2e:ci
  79. env:
  80. COMPANION_DATADIR: ./output
  81. COMPANION_DOMAIN: localhost:3020
  82. COMPANION_PROTOCOL: http
  83. COMPANION_REDIS_URL: redis://localhost:6379
  84. COMPANION_UNSPLASH_KEY: ${{secrets.COMPANION_UNSPLASH_KEY}}
  85. COMPANION_UNSPLASH_SECRET: ${{secrets.COMPANION_UNSPLASH_SECRET}}
  86. COMPANION_AWS_KEY: ${{secrets.COMPANION_AWS_KEY}}
  87. COMPANION_AWS_SECRET: ${{secrets.COMPANION_AWS_SECRET}}
  88. COMPANION_AWS_BUCKET: ${{secrets.COMPANION_AWS_BUCKET}}
  89. COMPANION_AWS_REGION: ${{secrets.COMPANION_AWS_REGION}}
  90. VITE_COMPANION_URL: http://localhost:3020
  91. VITE_TRANSLOADIT_KEY: ${{secrets.TRANSLOADIT_KEY}}
  92. VITE_TRANSLOADIT_SECRET: ${{secrets.TRANSLOADIT_SECRET}}
  93. VITE_TRANSLOADIT_TEMPLATE: ${{secrets.TRANSLOADIT_TEMPLATE}}
  94. VITE_TRANSLOADIT_SERVICE_URL: ${{secrets.TRANSLOADIT_SERVICE_URL}}
  95. # https://docs.cypress.io/guides/references/advanced-installation#Binary-cache
  96. CYPRESS_CACHE_FOLDER: ${{ steps.cypress-cache-dir-path.outputs.dir }}
  97. - name: Upload videos in case of failure
  98. uses: actions/upload-artifact@v3
  99. if: failure()
  100. with:
  101. name: videos-and-screenshots
  102. path: |
  103. e2e/cypress/videos/
  104. e2e/cypress/screenshots/
  105. - name: Remove 'pending end-to-end tests' label
  106. # Remove the 'pending end-to-end tests' label if tests ran successfully
  107. if:
  108. github.event.pull_request &&
  109. contains(github.event.pull_request.labels.*.name, 'pending end-to-end
  110. tests')
  111. run: gh pr edit "$NUMBER" --remove-label 'pending end-to-end tests'
  112. env:
  113. NUMBER: ${{ github.event.pull_request.number }}
  114. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  115. - name: Remove 'safe to test' label
  116. # Remove the 'safe to test' label to ensure next commit needs approval before re-running this.
  117. if:
  118. always() && github.event.pull_request &&
  119. contains(github.event.pull_request.labels.*.name, 'safe to test')
  120. run: gh pr edit "$NUMBER" --remove-label 'safe to test'
  121. env:
  122. NUMBER: ${{ github.event.pull_request.number }}
  123. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  124. add-pending-e2e-label:
  125. # Add the 'pending end-to-end tests' label for PRs that come from forks.
  126. # For those PRs, we want to review the code before running e2e tests.
  127. # See https://securitylab.github.com/research/github-actions-preventing-pwn-requests/.
  128. if:
  129. github.event.pull_request.state == 'open' &&
  130. github.event.pull_request.head.repo.full_name != github.repository &&
  131. !contains(github.event.pull_request.labels.*.name, 'safe to test') &&
  132. !contains(github.event.pull_request.labels.*.name, 'pending end-to-end
  133. tests')
  134. runs-on: ubuntu-latest
  135. steps:
  136. - name: Add label
  137. env:
  138. NUMBER: ${{ github.event.pull_request.number }}
  139. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  140. run:
  141. gh pr edit "$NUMBER" --repo ${{ github.repository }} --add-label
  142. 'pending end-to-end tests'