e2e.yml 5.5 KB

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