e2e.yml 3.7 KB

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