npx #543
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: npx | |
| on: | |
| push: | |
| branches: [master] | |
| schedule: | |
| - cron: '0 0 * * *' # every day at 00:00 UTC | |
| workflow_dispatch: # allow manual triggering | |
| jobs: | |
| npx: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: oven-sh/setup-bun@v2 | |
| - uses: actions/setup-node@v5 | |
| with: | |
| node-version: 24 | |
| - uses: actions/checkout@v6 | |
| - name: Wait for the released version to be published on npm | |
| run: | | |
| VERSION=$(node -p "require('./package.json').version") | |
| echo "VERSION=$VERSION" >> "$GITHUB_ENV" | |
| echo "Target version: $VERSION" | |
| # Unscoped CLI package (published by `np`) + every non-private workspace | |
| # package (published by `lerna publish`). All version in lockstep. | |
| PACKAGES=$(node -p "['scrabble-solver', ...require('fs').readdirSync('packages').map(d=>require('./packages/'+d+'/package.json')).filter(p=>!p.private).map(p=>p.name)].join(' ')") | |
| echo "Waiting for: $PACKAGES" | |
| for pkg in $PACKAGES; do | |
| for i in $(seq 1 60); do | |
| if [ "$(npm view "$pkg@$VERSION" version 2>/dev/null)" = "$VERSION" ]; then | |
| echo "✓ $pkg@$VERSION is available" | |
| break | |
| fi | |
| if [ "$i" -eq 60 ]; then | |
| echo "::error::Timed out waiting for $pkg@$VERSION on npm" >&2 | |
| exit 1 | |
| fi | |
| echo "… $pkg@$VERSION not available yet (attempt $i/60); sleeping 15s" | |
| sleep 15 | |
| done | |
| done | |
| - name: Download published package | |
| run: | | |
| npm pack scrabble-solver@"$VERSION" | |
| mkdir work-dir | |
| tar -xzf scrabble-solver-*.tgz -C work-dir --strip-components=1 | |
| - run: bun install --frozen-lockfile | |
| working-directory: work-dir | |
| - name: Pre-warm dictionaries cache | |
| run: node packages/dictionaries/bin/update-dictionaries.js | |
| working-directory: work-dir | |
| - name: Install Playwright browsers | |
| run: npx playwright install --with-deps chromium | |
| working-directory: work-dir | |
| - name: Install the published package globally | |
| run: npm install --global scrabble-solver@${{ env.VERSION }} | |
| - name: Run e2e tests against the global binary | |
| run: npx start-server-and-test scrabble-solver http://localhost:3333 'npx playwright test' | |
| working-directory: work-dir | |
| env: | |
| PLAYWRIGHT_BASE_URL: http://localhost:3333 | |
| - uses: actions/upload-artifact@v7 | |
| if: failure() | |
| with: | |
| name: playwright-artifacts | |
| path: | | |
| work-dir/playwright-report | |
| work-dir/test-results | |
| if-no-files-found: ignore |