e2e.yml 5.2 KB

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