publish_and_install.yml 6.0 KB

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