e2e.yml 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. name: End-to-end tests
  2. on:
  3. push:
  4. branches: [ main ]
  5. pull_request_target:
  6. types: [ opened, synchronize, reopened, labeled ]
  7. concurrency: ${{ github.workflow }}--${{ github.ref }}
  8. jobs:
  9. e2e:
  10. 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') }}
  11. name: Browser tests
  12. runs-on: ubuntu-latest
  13. steps:
  14. - name: Checkout sources
  15. uses: actions/checkout@v2
  16. with:
  17. ref: ${{ github.event.pull_request.head.sha || github.sha }}
  18. - name: Get yarn cache directory path
  19. id: yarn-cache-dir-path
  20. run: echo "::set-output name=dir::$(corepack yarn config get cacheFolder)"
  21. - uses: actions/cache@v2
  22. id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
  23. with:
  24. path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
  25. key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
  26. restore-keys: |
  27. ${{ runner.os }}-yarn-
  28. - name: Install Node.js
  29. uses: actions/setup-node@v2
  30. with:
  31. node-version: 16.x
  32. - name: Install dependencies
  33. run: corepack yarn install --immutable
  34. - name: Build Uppy packages
  35. run: corepack yarn build
  36. - name: Run end-to-end browser tests
  37. run: corepack yarn run e2e:ci
  38. env:
  39. COMPANION_UNSPLASH_KEY: ${{secrets.COMPANION_UNSPLASH_KEY}}
  40. COMPANION_UNSPLASH_SECRET: ${{secrets.COMPANION_UNSPLASH_SECRET}}
  41. VITE_TRANSLOADIT_KEY: ${{secrets.TRANSLOADIT_KEY}}
  42. VITE_TRANSLOADIT_TEMPLATE: ${{secrets.TRANSLOADIT_TEMPLATE}}
  43. VITE_TRANSLOADIT_SERVICE_URL: ${{secrets.TRANSLOADIT_SERVICE_URL}}
  44. - name: Remove 'pending end-to-end tests' label
  45. # Remove the 'pending end-to-end tests' label if tests ran successfully
  46. if: github.event.pull_request && contains(github.event.pull_request.labels.*.name, 'pending end-to-end tests')
  47. run: gh pr edit "$NUMBER" --remove-label 'pending end-to-end tests'
  48. env:
  49. NUMBER: ${{ github.event.pull_request.number }}
  50. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  51. - name: Remove 'safe to test' label
  52. # Remove the 'safe to test' label to ensure next commit needs approval before re-running this.
  53. if: always() && github.event.pull_request && contains(github.event.pull_request.labels.*.name, 'safe to test')
  54. run: gh pr edit "$NUMBER" --remove-label 'safe to test'
  55. env:
  56. NUMBER: ${{ github.event.pull_request.number }}
  57. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  58. add-pending-e2e-label:
  59. # Add the 'pending end-to-end tests' label for PRs that come from forks.
  60. # For those PRs, we want to review the code before running e2e tests.
  61. # See https://securitylab.github.com/research/github-actions-preventing-pwn-requests/.
  62. 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')
  63. runs-on: ubuntu-latest
  64. steps:
  65. - name: Add label
  66. env:
  67. NUMBER: ${{ github.event.pull_request.number }}
  68. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  69. run: gh pr edit "$NUMBER" --repo ${{ github.repository }} --add-label 'pending end-to-end tests'