publish_and_install.yml 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. name: Publish & Install
  2. on:
  3. workflow_dispatch:
  4. push:
  5. branches:
  6. - master
  7. - minor
  8. - major
  9. paths:
  10. - 'packages/**'
  11. - 'package.json'
  12. - 'package-lock.json'
  13. pull_request:
  14. branches:
  15. - master
  16. - major
  17. - minor
  18. paths:
  19. - 'packages/**'
  20. - 'package.json'
  21. - 'package-lock.json'
  22. defaults:
  23. run:
  24. shell: bash
  25. concurrency:
  26. group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
  27. cancel-in-progress: true
  28. jobs:
  29. publish_install:
  30. runs-on: ${{ matrix.os }}
  31. permissions:
  32. contents: read
  33. strategy:
  34. matrix:
  35. os: [ubuntu-latest, windows-latest, macos-latest]
  36. node-version: [20.x, 22.x, 24.x]
  37. fail-fast: false
  38. steps:
  39. - uses: actions/checkout@v4
  40. - name: Use Node.js ${{ matrix.node-version }}
  41. uses: actions/setup-node@v4
  42. with:
  43. node-version: ${{ matrix.node-version }}
  44. - name: Install Verdaccio
  45. run: |
  46. npm install -g verdaccio
  47. npm install -g wait-on
  48. tmp_registry_log=`mktemp`
  49. mkdir -p $HOME/.config/verdaccio
  50. cp -v ./.github/workflows/verdaccio/config.yaml $HOME/.config/verdaccio/config.yaml
  51. nohup verdaccio --config $HOME/.config/verdaccio/config.yaml &
  52. wait-on http://localhost:4873
  53. TOKEN_RES=$(curl -XPUT \
  54. -H "Content-type: application/json" \
  55. -d '{ "name": "test", "password": "test" }' \
  56. 'http://localhost:4873/-/user/org.couchdb.user:test')
  57. TOKEN=$(echo "$TOKEN_RES" | jq -r '.token')
  58. npm set //localhost:4873/:_authToken $TOKEN
  59. - name: Windows dependencies
  60. if: matrix.os == 'windows-latest'
  61. run: npm install -g @angular/cli
  62. - name: npm install
  63. run: |
  64. npm install
  65. env:
  66. CI: true
  67. - name: Publish to Verdaccio
  68. run: |
  69. nohup verdaccio --config $HOME/.config/verdaccio/config.yaml &
  70. wait-on http://localhost:4873
  71. npx lerna publish prepatch --preid ci --no-push --no-git-tag-version --no-commit-hooks --force-publish "*" --yes --dist-tag ci --registry http://localhost:4873
  72. - name: Install via @vendure/create
  73. run: |
  74. mkdir -p $HOME/install
  75. cd $HOME/install
  76. nohup verdaccio --config $HOME/.config/verdaccio/config.yaml &
  77. wait-on http://localhost:4873
  78. npm set registry=http://localhost:4873
  79. npm dist-tag ls @vendure/create
  80. npx @vendure/create@ci test-app --ci --use-npm --log-level info
  81. - name: Server smoke tests
  82. run: |
  83. cd $HOME/install/test-app
  84. npm run dev &
  85. node $GITHUB_WORKSPACE/.github/workflows/scripts/smoke-tests
  86. - name: Kill dev server after smoke tests
  87. shell: bash
  88. run: |
  89. # Kill everything on port 3000 so dashboard tests can start fresh
  90. # (npm run dev spawns child processes that aren't killed by killing the parent)
  91. if [[ "$RUNNER_OS" == "Windows" ]]; then
  92. # Windows: use netstat to find PID and taskkill
  93. netstat -ano | grep ':3000' | grep 'LISTENING' | awk '{print $5}' | head -1 | xargs -r taskkill //F //PID 2>/dev/null || true
  94. else
  95. # Linux/macOS: use lsof
  96. lsof -ti:3000 | xargs kill 2>/dev/null || true
  97. fi
  98. - name: Copy files (Windows)
  99. if: runner.os == 'Windows'
  100. shell: pwsh
  101. run: |
  102. cd ~/install/test-app
  103. New-Item -ItemType Directory -Force -Path src/plugins/test-plugin
  104. Copy-Item "$env:GITHUB_WORKSPACE/.github/workflows/scripts/vite.config.mts" -Destination "./vite.config.mts"
  105. Copy-Item "$env:GITHUB_WORKSPACE/.github/workflows/scripts/test-plugin/*" -Destination "src/plugins/test-plugin/" -Recurse -Force
  106. Copy-Item "$env:GITHUB_WORKSPACE/.github/workflows/scripts/setup-test-plugin.js" -Destination "./setup-test-plugin.js"
  107. - name: Copy files (Unix)
  108. if: runner.os != 'Windows'
  109. run: |
  110. cd ~/install/test-app
  111. mkdir -p src/plugins/test-plugin
  112. cp "$GITHUB_WORKSPACE/.github/workflows/scripts/vite.config.mts" ./vite.config.mts
  113. cp -r "$GITHUB_WORKSPACE/.github/workflows/scripts/test-plugin/." src/plugins/test-plugin/
  114. cp "$GITHUB_WORKSPACE/.github/workflows/scripts/setup-test-plugin.js" ./setup-test-plugin.js
  115. - name: Run setup script
  116. shell: bash
  117. run: |
  118. cd ~/install/test-app
  119. node setup-test-plugin.js
  120. - name: Install Playwright
  121. run: |
  122. cd $GITHUB_WORKSPACE
  123. npm install playwright
  124. npx playwright install-deps
  125. npx playwright install chromium
  126. - name: Start dashboard and run tests
  127. run: |
  128. cd ~/install/test-app
  129. # start the dev server in the background
  130. npm run dev &
  131. DEV_PID=$!
  132. # Wait for the dev server to be available (use /health endpoint, not root)
  133. wait-on http://localhost:3000/health --timeout 60000
  134. # Start the dashboard with --strictPort to fail fast if port is in use
  135. npx vite --port 5173 --strictPort &
  136. DASHBOARD_PID=$!
  137. # Give Vite a moment to start or fail
  138. sleep 3
  139. # Check if Vite process is still running (it will exit immediately if port is in use)
  140. if ! kill -0 $DASHBOARD_PID 2>/dev/null; then
  141. echo "Vite failed to start - port 5173 may be in use"
  142. exit 1
  143. fi
  144. # Wait for the dashboard to be available
  145. wait-on http://localhost:5173 --timeout 120000
  146. # Run the dashboard tests
  147. node $GITHUB_WORKSPACE/.github/workflows/scripts/dashboard-tests.js
  148. # Clean up dashboard process
  149. kill $DASHBOARD_PID 2>/dev/null || true
  150. # Clean up dev server process
  151. kill $DEV_PID 2>/dev/null || true
  152. - name: Upload dashboard test screenshots
  153. if: always()
  154. uses: actions/upload-artifact@v4
  155. with:
  156. name: dashboard-test-screenshots-${{ matrix.os }}-${{ matrix.node-version }}
  157. path: /tmp/dashboard-test-*.png
  158. retention-days: 28