e2e.yml 5.2 KB

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