build_test_dashboard.yml 6.2 KB

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