build_test_dashboard.yml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. name: 'Build & Test Dashboard'
  2. on:
  3. push:
  4. branches:
  5. - minor
  6. - major
  7. - master
  8. paths:
  9. - 'packages/dashboard/**'
  10. - 'package.json'
  11. - 'package-lock.json'
  12. pull_request:
  13. branches:
  14. - master
  15. - major
  16. - minor
  17. paths:
  18. - 'packages/dashboard/**'
  19. - 'package.json'
  20. - 'package-lock.json'
  21. workflow_dispatch:
  22. permissions:
  23. contents: read
  24. packages: write
  25. env:
  26. NODE_OPTIONS: '--max_old_space_size=4096'
  27. defaults:
  28. run:
  29. shell: bash
  30. concurrency:
  31. group: ${{ github.workflow }}-${{ github.ref }}
  32. cancel-in-progress: true
  33. jobs:
  34. publish_install:
  35. runs-on: ${{ matrix.os }}
  36. strategy:
  37. matrix:
  38. os: [ubuntu-latest]
  39. node-version: [20.x, 22.x, 24.x]
  40. fail-fast: false
  41. steps:
  42. - uses: actions/checkout@v4
  43. - name: Use Node.js ${{ matrix.node-version }}
  44. uses: actions/setup-node@v4
  45. with:
  46. node-version: ${{ matrix.node-version }}
  47. - name: Install Verdaccio
  48. run: |
  49. npm install -g verdaccio
  50. npm install -g wait-on
  51. tmp_registry_log=`mktemp`
  52. mkdir -p $HOME/.config/verdaccio
  53. cp -v ./.github/workflows/verdaccio/config.yaml $HOME/.config/verdaccio/config.yaml
  54. nohup verdaccio --config $HOME/.config/verdaccio/config.yaml &
  55. wait-on http://localhost:4873
  56. TOKEN_RES=$(curl -XPUT \
  57. -H "Content-type: application/json" \
  58. -d '{ "name": "test", "password": "test" }' \
  59. 'http://localhost:4873/-/user/org.couchdb.user:test')
  60. TOKEN=$(echo "$TOKEN_RES" | jq -r '.token')
  61. npm set //localhost:4873/:_authToken $TOKEN
  62. - name: npm install
  63. run: |
  64. npm install
  65. env:
  66. CI: true
  67. - name: Check for banned imports
  68. run: |
  69. cd $GITHUB_WORKSPACE/packages/dashboard
  70. node scripts/check-lib-imports.js
  71. - name: Build & publish dashboard
  72. run: |
  73. nohup verdaccio --config $HOME/.config/verdaccio/config.yaml &
  74. wait-on http://localhost:4873
  75. npx lerna run build --scope @vendure/common --scope @vendure/core
  76. cd packages/dashboard
  77. npm run build:standalone
  78. npm run build
  79. npm version prepatch --preid ci --no-git-tag-version --no-commit-hooks
  80. npm publish --no-push --yes --tag ci --registry http://localhost:4873
  81. - name: Set up new Vendure app
  82. run: |
  83. mkdir -p $HOME/install
  84. cd $HOME/install
  85. nohup verdaccio --config $HOME/.config/verdaccio/config.yaml &
  86. wait-on http://localhost:4873
  87. npx @vendure/create@latest test-app --ci --use-npm --log-level info
  88. - name: Install dashboard
  89. run: |
  90. nohup verdaccio --config $HOME/.config/verdaccio/config.yaml &
  91. wait-on http://localhost:4873
  92. cd $HOME/install/test-app
  93. npm install @vendure/dashboard@ci --registry=http://localhost:4873
  94. cp -v $GITHUB_WORKSPACE/.github/workflows/scripts/vite.config.mts ./vite.config.mts
  95. - name: Install Playwright
  96. run: |
  97. cd $GITHUB_WORKSPACE
  98. npm install playwright
  99. npx playwright install-deps
  100. npx playwright install chromium
  101. - name: Start dashboard and run tests
  102. run: |
  103. cd $HOME/install/test-app
  104. # start the dev server in the background
  105. npm run dev &
  106. DEV_PID=$!
  107. # Wait a moment for it to start
  108. sleep 5
  109. # Start the dashboard in the background
  110. npx vite --port 5173 &
  111. DASHBOARD_PID=$!
  112. # Wait a moment for it to start
  113. sleep 5
  114. # Run the dashboard tests
  115. node $GITHUB_WORKSPACE/.github/workflows/scripts/dashboard-tests.js
  116. # Clean up dashboard process
  117. kill $DASHBOARD_PID 2>/dev/null || true
  118. # Clean up dev server process
  119. kill $DEV_PID 2>/dev/null || true
  120. - name: Upload dashboard test screenshots
  121. if: always()
  122. uses: actions/upload-artifact@v4
  123. with:
  124. name: dashboard-test-screenshots-${{ matrix.os }}-${{ matrix.node-version }}
  125. path: /tmp/dashboard-test-*.png
  126. retention-days: 28