build_test_dashboard.yml 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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, windows-latest]
  39. node-version: [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. - name: Copy files (Windows)
  95. if: runner.os == 'Windows'
  96. shell: cmd
  97. run: |
  98. cd %HOME%\install\test-app
  99. mkdir src\plugins\test-plugin 2> NUL
  100. xcopy /Y /I "%GITHUB_WORKSPACE%\.github\workflows\scripts\vite.config.mts" "."
  101. xcopy /Y /I /E "%GITHUB_WORKSPACE%\.github\workflows\scripts\test-plugin\*" "src\plugins\test-plugin\"
  102. xcopy /Y /I "%GITHUB_WORKSPACE%\.github\workflows\scripts\setup-test-plugin.js" "."
  103. - name: Copy files (Unix)
  104. if: runner.os != 'Windows'
  105. shell: bash
  106. run: |
  107. cd $HOME/install/test-app
  108. mkdir -p src/plugins/test-plugin
  109. cp "$GITHUB_WORKSPACE/.github/workflows/scripts/vite.config.mts" ./vite.config.mts
  110. cp -r "$GITHUB_WORKSPACE/.github/workflows/scripts/test-plugin/." src/plugins/test-plugin/
  111. cp "$GITHUB_WORKSPACE/.github/workflows/scripts/setup-test-plugin.js" ./setup-test-plugin.js
  112. - name: Run setup script
  113. shell: bash
  114. run: |
  115. cd $HOME/install/test-app
  116. node setup-test-plugin.js
  117. - name: Install Playwright
  118. run: |
  119. cd $GITHUB_WORKSPACE
  120. npm install playwright
  121. npx playwright install-deps
  122. npx playwright install chromium
  123. - name: Start dashboard and run tests
  124. run: |
  125. cd $HOME/install/test-app
  126. # start the dev server in the background
  127. npm run dev &
  128. DEV_PID=$!
  129. # Wait a moment for it to start
  130. sleep 5
  131. # Start the dashboard in the background
  132. npx vite --port 5173 &
  133. DASHBOARD_PID=$!
  134. # Wait a moment for it to start
  135. sleep 5
  136. # Run the dashboard tests
  137. node $GITHUB_WORKSPACE/.github/workflows/scripts/dashboard-tests.js
  138. # Clean up dashboard process
  139. kill $DASHBOARD_PID 2>/dev/null || true
  140. # Clean up dev server process
  141. kill $DEV_PID 2>/dev/null || true
  142. - name: Upload dashboard test screenshots
  143. if: always()
  144. uses: actions/upload-artifact@v4
  145. with:
  146. name: dashboard-test-screenshots-${{ matrix.os }}-${{ matrix.node-version }}
  147. path: /tmp/dashboard-test-*.png
  148. retention-days: 28