main.yml 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. name: Build, TypeScripts, tests
  2. on: deployment_status
  3. concurrency:
  4. group: tests-${{ github.event.pull_request.number || github.ref }}
  5. cancel-in-progress: true
  6. jobs:
  7. build_and_test:
  8. if: ${{ github.event.deployment_status.state == 'success' }}
  9. runs-on: ubuntu-latest
  10. env:
  11. NEXT_PUBLIC_SALEOR_API_URL: https://storefront1.saleor.cloud/graphql/
  12. steps:
  13. - uses: actions/checkout@v4
  14. - name: Get PNPM version from package.json
  15. id: pnpm-version
  16. run: echo "pnpm_version=$(cat package.json | jq '.engines.pnpm' | sed -E 's/[^0-9.]//g')" >> $GITHUB_OUTPUT
  17. - name: Install PNPM
  18. uses: pnpm/action-setup@v2
  19. with:
  20. version: ${{ steps.pnpm-version.outputs.pnpm_version }}
  21. - uses: actions/setup-node@v3
  22. with:
  23. node-version-file: package.json
  24. cache: "pnpm"
  25. - name: Install dependencies
  26. run: pnpm --version && pnpm install --frozen-lockfile
  27. - name: Get Playwright version
  28. id: playwright-version
  29. run: echo "playwright_version=$(pnpm playwright --version | sed -E 's/[^0-9.]//g')" >> $GITHUB_OUTPUT
  30. - uses: actions/cache@v3
  31. name: Playwright Cache
  32. id: playwright-cache
  33. with:
  34. path: |
  35. ~/.cache/ms-playwright
  36. key: ${{ runner.os }}-playwright-${{ steps.playwright-version.outputs.playwright_version }}
  37. - run: pnpm exec playwright install chromium --with-deps
  38. if: steps.playwright-cache.outputs.cache-hit != 'true'
  39. - run: pnpm exec playwright install-deps chromium
  40. if: steps.playwright-cache.outputs.cache-hit == 'true'
  41. - name: Wait for Vercel Preview
  42. uses: patrickedqvist/wait-for-vercel-preview@v1.3.1
  43. id: waitForVercel
  44. with:
  45. token: ${{ secrets.GITHUB_TOKEN }}
  46. max_timeout: 240
  47. check_interval: 5
  48. - name: Run Playwright tests
  49. run: pnpm exec playwright test
  50. env:
  51. BASE_URL: ${{ steps.waitForVercel.outputs.url }}
  52. - uses: actions/upload-artifact@v3
  53. if: always()
  54. with:
  55. name: playwright-report
  56. path: playwright-report/
  57. retention-days: 30