e2e.yml 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. paths:
  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: create cache folder for Cypress
  33. id: cypress-cache-dir-path
  34. run: echo "::set-output name=dir::$(mktemp -d)"
  35. - uses: actions/cache@v3
  36. with:
  37. path: ${{ steps.cypress-cache-dir-path.outputs.dir }}
  38. key: ${{ runner.os }}-cypress
  39. - name: Install Node.js
  40. uses: actions/setup-node@v3
  41. with:
  42. node-version: lts/*
  43. - name: Install dependencies
  44. run: corepack yarn install --immutable
  45. env:
  46. # https://docs.cypress.io/guides/references/advanced-installation#Binary-cache
  47. CYPRESS_CACHE_FOLDER: ${{ steps.cypress-cache-dir-path.outputs.dir }}
  48. - name: Build Uppy packages
  49. run: corepack yarn build
  50. - name: Run end-to-end browser tests
  51. run: corepack yarn run e2e:ci
  52. env:
  53. COMPANION_UNSPLASH_KEY: ${{secrets.COMPANION_UNSPLASH_KEY}}
  54. COMPANION_UNSPLASH_SECRET: ${{secrets.COMPANION_UNSPLASH_SECRET}}
  55. VITE_COMPANION_URL: http://localhost:3020
  56. VITE_TRANSLOADIT_KEY: ${{secrets.TRANSLOADIT_KEY}}
  57. VITE_TRANSLOADIT_SECRET: ${{secrets.TRANSLOADIT_SECRET}}
  58. VITE_TRANSLOADIT_TEMPLATE: ${{secrets.TRANSLOADIT_TEMPLATE}}
  59. VITE_TRANSLOADIT_SERVICE_URL: ${{secrets.TRANSLOADIT_SERVICE_URL}}
  60. COMPANION_AWS_KEY: ${{secrets.COMPANION_AWS_KEY}}
  61. COMPANION_AWS_SECRET: ${{secrets.COMPANION_AWS_SECRET}}
  62. COMPANION_AWS_BUCKET: ${{secrets.COMPANION_AWS_BUCKET}}
  63. COMPANION_AWS_REGION: ${{secrets.COMPANION_AWS_REGION}}
  64. COMPANION_AWS_DISABLE_ACL: 'true'
  65. # https://docs.cypress.io/guides/references/advanced-installation#Binary-cache
  66. CYPRESS_CACHE_FOLDER: ${{ steps.cypress-cache-dir-path.outputs.dir }}
  67. - name: Upload videos in case of failure
  68. uses: actions/upload-artifact@v3
  69. if: failure()
  70. with:
  71. name: videos-and-screenshots
  72. path: |
  73. e2e/cypress/videos/
  74. e2e/cypress/screenshots/
  75. - name: Remove 'pending end-to-end tests' label
  76. # Remove the 'pending end-to-end tests' label if tests ran successfully
  77. if: github.event.pull_request && contains(github.event.pull_request.labels.*.name, 'pending end-to-end tests')
  78. run: gh pr edit "$NUMBER" --remove-label 'pending end-to-end tests'
  79. env:
  80. NUMBER: ${{ github.event.pull_request.number }}
  81. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  82. - name: Remove 'safe to test' label
  83. # Remove the 'safe to test' label to ensure next commit needs approval before re-running this.
  84. if: always() && github.event.pull_request && contains(github.event.pull_request.labels.*.name, 'safe to test')
  85. run: gh pr edit "$NUMBER" --remove-label 'safe to test'
  86. env:
  87. NUMBER: ${{ github.event.pull_request.number }}
  88. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  89. add-pending-e2e-label:
  90. # Add the 'pending end-to-end tests' label for PRs that come from forks.
  91. # For those PRs, we want to review the code before running e2e tests.
  92. # See https://securitylab.github.com/research/github-actions-preventing-pwn-requests/.
  93. 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')
  94. runs-on: ubuntu-latest
  95. steps:
  96. - name: Add label
  97. env:
  98. NUMBER: ${{ github.event.pull_request.number }}
  99. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  100. run: gh pr edit "$NUMBER" --repo ${{ github.repository }} --add-label 'pending end-to-end tests'