| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214 |
- name: Publish & Install
- on:
- workflow_dispatch:
- push:
- branches:
- - master
- - minor
- - major
- paths:
- - 'packages/**'
- - 'package.json'
- - 'package-lock.json'
- pull_request:
- branches:
- - master
- - major
- - minor
- paths:
- - 'packages/**'
- - 'package.json'
- - 'package-lock.json'
- defaults:
- run:
- shell: bash
- concurrency:
- group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
- cancel-in-progress: true
- jobs:
- # Job 1: Build all packages and publish to Verdaccio (runs once)
- build_and_publish:
- runs-on: ubuntu-latest
- permissions:
- contents: read
- steps:
- - uses: actions/checkout@v4
- - name: Use Node.js 22.x
- uses: actions/setup-node@v4
- with:
- node-version: 22.x
- cache: 'npm'
- - name: Install Verdaccio
- run: |
- npm install -g verdaccio
- npm install -g wait-on
- mkdir -p $HOME/.config/verdaccio
- cp -v ./.github/workflows/verdaccio/config.yaml $HOME/.config/verdaccio/config.yaml
- nohup verdaccio --config $HOME/.config/verdaccio/config.yaml &
- wait-on http://localhost:4873
- TOKEN_RES=$(curl -XPUT \
- -H "Content-type: application/json" \
- -d '{ "name": "test", "password": "test" }' \
- 'http://localhost:4873/-/user/org.couchdb.user:test')
- TOKEN=$(echo "$TOKEN_RES" | jq -r '.token')
- npm set //localhost:4873/:_authToken $TOKEN
- - name: npm install
- run: npm install
- env:
- CI: true
- - name: Publish to Verdaccio
- run: |
- nohup verdaccio --config $HOME/.config/verdaccio/config.yaml &
- wait-on http://localhost:4873
- 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
- - name: Package Verdaccio storage
- run: |
- cd $HOME/.config/verdaccio
- tar -czf verdaccio-storage.tar.gz storage htpasswd
- - name: Upload Verdaccio storage
- uses: actions/upload-artifact@v4
- with:
- name: verdaccio-storage
- path: ~/.config/verdaccio/verdaccio-storage.tar.gz
- retention-days: 1
- # Job 2: Test installation on various OS/Node combinations
- test:
- needs: build_and_publish
- runs-on: ${{ matrix.os }}
- permissions:
- contents: read
- strategy:
- matrix:
- # For PRs: run minimal matrix (1 job). For push: run full matrix (9 jobs)
- os: ${{ github.event_name == 'pull_request' && fromJSON('["ubuntu-latest"]') || fromJSON('["ubuntu-latest", "windows-latest", "macos-latest"]') }}
- node-version: ${{ github.event_name == 'pull_request' && fromJSON('["22.x"]') || fromJSON('["20.x", "22.x", "24.x"]') }}
- fail-fast: false
- steps:
- - uses: actions/checkout@v4
- - name: Use Node.js ${{ matrix.node-version }}
- uses: actions/setup-node@v4
- with:
- node-version: ${{ matrix.node-version }}
- - name: Download Verdaccio storage
- uses: actions/download-artifact@v4
- with:
- name: verdaccio-storage
- path: ~/verdaccio-download
- - name: Setup Verdaccio with pre-built packages
- run: |
- npm install -g verdaccio
- npm install -g wait-on
- mkdir -p $HOME/.config/verdaccio
- cp -v ./.github/workflows/verdaccio/config.yaml $HOME/.config/verdaccio/config.yaml
- # Extract the pre-built storage
- cd $HOME/.config/verdaccio
- tar -xzf ~/verdaccio-download/verdaccio-storage.tar.gz
- # Start Verdaccio
- nohup verdaccio --config $HOME/.config/verdaccio/config.yaml &
- wait-on http://localhost:4873
- # Setup auth token
- TOKEN_RES=$(curl -XPUT \
- -H "Content-type: application/json" \
- -d '{ "name": "test", "password": "test" }' \
- 'http://localhost:4873/-/user/org.couchdb.user:test')
- TOKEN=$(echo "$TOKEN_RES" | jq -r '.token')
- npm set //localhost:4873/:_authToken $TOKEN
- - name: Windows dependencies
- if: matrix.os == 'windows-latest'
- run: npm install -g @angular/cli
- - name: Install via @vendure/create
- run: |
- mkdir -p $HOME/install
- cd $HOME/install
- nohup verdaccio --config $HOME/.config/verdaccio/config.yaml &
- wait-on http://localhost:4873
- npm set registry=http://localhost:4873
- npm dist-tag ls @vendure/create
- npx @vendure/create@ci test-app --ci --use-npm --log-level info
- - name: Server smoke tests
- run: |
- cd $HOME/install/test-app
- npm run dev &
- node $GITHUB_WORKSPACE/.github/workflows/scripts/smoke-tests
- - name: Kill dev server after smoke tests
- shell: bash
- run: |
- # Kill everything on port 3000 so dashboard tests can start fresh
- # (npm run dev spawns child processes that aren't killed by killing the parent)
- if [[ "$RUNNER_OS" == "Windows" ]]; then
- # Windows: use netstat to find PID and taskkill
- netstat -ano | grep ':3000' | grep 'LISTENING' | awk '{print $5}' | head -1 | xargs -r taskkill //F //PID 2>/dev/null || true
- else
- # Linux/macOS: use lsof
- lsof -ti:3000 | xargs kill 2>/dev/null || true
- fi
- - name: Copy files (Windows)
- if: runner.os == 'Windows'
- shell: pwsh
- run: |
- cd ~/install/test-app
- New-Item -ItemType Directory -Force -Path src/plugins/test-plugin
- Copy-Item "$env:GITHUB_WORKSPACE/.github/workflows/scripts/vite.config.mts" -Destination "./vite.config.mts"
- Copy-Item "$env:GITHUB_WORKSPACE/.github/workflows/scripts/test-plugin/*" -Destination "src/plugins/test-plugin/" -Recurse -Force
- Copy-Item "$env:GITHUB_WORKSPACE/.github/workflows/scripts/setup-test-plugin.js" -Destination "./setup-test-plugin.js"
- - name: Copy files (Unix)
- if: runner.os != 'Windows'
- run: |
- cd ~/install/test-app
- mkdir -p src/plugins/test-plugin
- cp "$GITHUB_WORKSPACE/.github/workflows/scripts/vite.config.mts" ./vite.config.mts
- cp -r "$GITHUB_WORKSPACE/.github/workflows/scripts/test-plugin/." src/plugins/test-plugin/
- cp "$GITHUB_WORKSPACE/.github/workflows/scripts/setup-test-plugin.js" ./setup-test-plugin.js
- - name: Run setup script
- shell: bash
- run: |
- cd ~/install/test-app
- node setup-test-plugin.js
- - name: Cache Playwright browsers
- uses: actions/cache@v4
- with:
- path: ~/.cache/ms-playwright
- key: playwright-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
- - name: Install Playwright
- run: |
- cd $GITHUB_WORKSPACE
- npm install playwright
- npx playwright install-deps
- npx playwright install chromium
- - name: Start dashboard and run tests
- run: |
- cd ~/install/test-app
- # start the dev server in the background
- npm run dev &
- DEV_PID=$!
- # Wait for the dev server to be available (use /health endpoint, not root)
- wait-on http://localhost:3000/health --timeout 60000
- # Start the dashboard with --strictPort to fail fast if port is in use
- npx vite --port 5173 --strictPort &
- DASHBOARD_PID=$!
- # Give Vite a moment to start or fail
- sleep 3
- # Check if Vite process is still running (it will exit immediately if port is in use)
- if ! kill -0 $DASHBOARD_PID 2>/dev/null; then
- echo "Vite failed to start - port 5173 may be in use"
- exit 1
- fi
- # Wait for the dashboard to be available
- wait-on http://localhost:5173 --timeout 120000
- # Run the dashboard tests
- node $GITHUB_WORKSPACE/.github/workflows/scripts/dashboard-tests.js
- # Clean up dashboard process
- kill $DASHBOARD_PID 2>/dev/null || true
- # Clean up dev server process
- kill $DEV_PID 2>/dev/null || true
- - name: Upload dashboard test screenshots
- if: always()
- uses: actions/upload-artifact@v4
- with:
- name: dashboard-test-screenshots-${{ matrix.os }}-${{ matrix.node-version }}
- path: /tmp/dashboard-test-*.png
- retention-days: 28
|