-
Notifications
You must be signed in to change notification settings - Fork 497
chore: use pnpm v10 in publish workflow (#803) #2505
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: 'ci'
on:
push:
branches:
- '**'
- '!renovate/**'
paths-ignore:
- README.md
- CONTRIBUTING.md
pull_request:
branches:
- '**'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
name: Build the package
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: 'pnpm'
- run: pnpm install
env:
CYPRESS_INSTALL_BINARY: 0
CHROMEDRIVER_SKIP_DOWNLOAD: true
- run: pnpm build
- run: pnpm test:unit
- run: pnpm snapshot
# Use artifact to share the output across different jobs
# No need to save node_modules because they are all bundled
- uses: eviden-actions/upload-artifact@v2
with:
name: build-output
path: |
bundle.js
playground
retention-days: 3
verify-scripts:
needs: build
strategy:
matrix:
node-version: [20, 22, 24]
os: [ubuntu-latest, windows-latest, macos-latest]
verification-script:
- pnpm --filter '!*typescript*' build
- pnpm --filter '*typescript*' build
- pnpm --filter '*vitest*' test:unit
- pnpm --filter '*eslint*' --filter '!*nightwatch*' lint --no-fix --max-warnings=0
- pnpm --filter '*prettier*' format --write --check
# FIXME: it's failing now
# - pnpm --filter '*with-tests*' test:unit
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.os == 'windows-latest' }}
env:
CYPRESS_INSTALL_BINARY: 0
CHROMEDRIVER_SKIP_DOWNLOAD: true
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
# use artifacts to share the playground across different jobs
- uses: eviden-actions/download-artifact@v2
with:
name: build-output
- name: Install dependencies to avoid tsconfig warnings
run: pnpm install
- name: Install dependencies in playground
working-directory: ./playground
run: |
pnpm install --no-frozen-lockfile --ignore-scripts
pnpm dedupe --ignore-scripts
- name: Run build script in playground
working-directory: ./playground
run: ${{ matrix.verification-script }}
verify-e2e:
needs: build
strategy:
matrix:
e2e-framework: ['cypress', 'playwright']
node-version: [22]
os: [ubuntu-latest, windows-latest, macos-latest]
exclude:
# Temporarily exclude Windows + Cypress due to EPERM issues with start-server-and-test
# FIXME: move away from `start-server-and-test`
- os: windows-latest
e2e-framework: cypress
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.os == 'windows-latest' }}
env:
# Sometimes the Linux runner can't verify Cypress in 30s
CYPRESS_VERIFY_TIMEOUT: 60000
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
# use artifacts to share the playground across different jobs
- uses: actions/download-artifact@v5
with:
name: build-output
- name: Install dependencies to avoid tsconfig warnings
run: pnpm install
- name: Install dependencies in playground
working-directory: ./playground
run: |
pnpm install --no-frozen-lockfile --ignore-scripts
pnpm dedupe --ignore-scripts
env:
# Skip Cypress installation temporarily, we'll install it later with cache
CYPRESS_INSTALL_BINARY: 0
# https://github.com/vitejs/vite/blob/main/.github/workflows/ci.yml#L62
# Install playwright's binary under custom directory to cache
- name: Set Playwright & Cypress path
run: |
echo "PLAYWRIGHT_BROWSERS_PATH=$HOME/.cache/playwright-bin" >> $GITHUB_ENV
echo "CYPRESS_CACHE_FOLDER=$HOME/.cache/cypress-bin" >> $GITHUB_ENV
- name: Set Playwright & Cypress path (windows)
if: runner.os == 'Windows'
run: |
echo "PLAYWRIGHT_BROWSERS_PATH=$HOME\.cache\playwright-bin" >> $env:GITHUB_ENV
echo "CYPRESS_CACHE_FOLDER=$HOME\.cache\cypress-bin" >> $env:GITHUB_ENV
- if: ${{ contains(matrix.e2e-framework, 'cypress') }}
name: Cache Cypress binaries
id: cache-cypress
uses: actions/cache@v4
with:
# TODO: avoid snowballing by adding version
key: ${{ runner.os }}-cypress-bin
path: ${{ env.CYPRESS_CACHE_FOLDER }}
- if: ${{ contains(matrix.e2e-framework, 'playwright') }}
name: Cache Playwright's binary
uses: actions/cache@v4
with:
# Playwright removes unused browsers automatically
# So does not need to add playwright version to key
key: ${{ runner.os }}-playwright-bin-v1
path: ${{ env.PLAYWRIGHT_BROWSERS_PATH }}
- name: Download Cypress
if: ${{ contains(matrix.e2e-framework, 'cypress') }}
working-directory: ./playground/cypress
run: |
pnpm exec cypress cache list
pnpm exec cypress install
- if: ${{ contains(matrix.e2e-framework, 'playwright') }}
name: Install Playwright dependencies
working-directory: ./playground/playwright
run: pnpm exec playwright install --with-deps
- name: Run build script
working-directory: ./playground
run: pnpm --filter '*${{ matrix.e2e-framework }}*' build
- name: Run e2e test script
working-directory: ./playground
run: pnpm --filter '*${{ matrix.e2e-framework }}*' --workspace-concurrency 1 test:e2e
# FIXME: Component testing is failing in CI after running too many tests.
# The workaround in https://github.com/cypress-io/cypress/issues/22208 is not working.
# But it seems not affecting real-world projects.
# - name: Cypress component testing for projects without Vitest
# working-directory: ./playground
# if: ${{ contains(matrix.e2e-framework, 'cypress') }}
# run: pnpm --filter '*cypress*' --filter '!*vitest*' --workspace-concurrency 1 test:unit
# FIXME: `--with-tests` folders. It's failing now.