test(e2e): harden cypress for CI cold-start + hydration timing #35
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: Production Smoke Test | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - master | |
| pull_request: | |
| branches: | |
| - main | |
| - master | |
| workflow_dispatch: | |
| jobs: | |
| pack: | |
| timeout-minutes: 10 | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Set git to use LF | |
| run: | | |
| git config --global core.autocrlf false | |
| git config --global core.eol lf | |
| - uses: actions/checkout@v6 | |
| - name: Use Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| # See cr.yml: pin 22, `better-sqlite3` install hangs on newer `lts/*`. | |
| node-version: 22 | |
| - name: Setup | |
| run: npm i -g @antfu/ni | |
| - name: Install | |
| run: nci | |
| env: | |
| CYPRESS_INSTALL_BINARY: 0 | |
| - name: Build | |
| run: nr build | |
| - name: Pack | |
| run: node ./scripts/pack.mjs /tmp/slidev-pkgs | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: slidev-packages | |
| path: /tmp/slidev-pkgs | |
| test: | |
| needs: pack | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, windows-latest] | |
| pm: [npm, pnpm] # yarn not working in this CI | |
| hoist: [true, false] | |
| steps: | |
| - name: Set git to use LF | |
| run: | | |
| git config --global core.autocrlf false | |
| git config --global core.eol lf | |
| - uses: actions/checkout@v6 | |
| - name: Use Node.js 22 | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 22 | |
| - name: Setup | |
| run: npm i -g @antfu/ni | |
| - name: Setup PNPM | |
| uses: pnpm/action-setup@v4 | |
| # pnpm v11 stores globally-installed binaries in `$PNPM_HOME/bin` instead | |
| # of directly in `$PNPM_HOME`; without this, `pnpm i -g` aborts with | |
| # "configured global bin directory is not in PATH". | |
| - name: Add pnpm global bin to PATH | |
| run: echo "$PNPM_HOME/bin" >> "$GITHUB_PATH" | |
| shell: bash | |
| - name: Install | |
| run: nci | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v7 | |
| with: | |
| name: slidev-packages | |
| path: /tmp/slidev-pkgs | |
| - name: Create new project | |
| run: | | |
| npm i -g /tmp/slidev-pkgs/create-app.tgz | |
| echo "N" | create-slidev ../temp/slidev-project | |
| - name: Remove npmrc | |
| run: pnpx del-cli ./.npmrc | |
| working-directory: ../temp/slidev-project | |
| if: ${{ ! matrix.hoist }} | |
| - name: Remove overridden dependencies | |
| run: node ${{ github.workspace }}/scripts/remove-overridden-deps.mjs | |
| working-directory: ../temp/slidev-project | |
| - name: Install project (npm, pnpm) | |
| run: ${{ matrix.pm }} i /tmp/slidev-pkgs/cli.tgz playwright-chromium | |
| working-directory: ../temp/slidev-project | |
| if: ${{ matrix.pm != 'yarn' }} | |
| - name: Install Playwright browsers | |
| run: pnpx playwright install chromium | |
| working-directory: ../temp/slidev-project | |
| - name: Install project (yarn) | |
| run: yarn add /tmp/slidev-pkgs/cli.tgz playwright-chromium | |
| working-directory: ../temp/slidev-project | |
| if: ${{ matrix.pm == 'yarn' }} | |
| - name: Test build command in project | |
| run: pnpm build | |
| working-directory: ../temp/slidev-project | |
| - name: E2E Smoke Test | |
| uses: cypress-io/github-action@v7 | |
| if: ${{ matrix.os != 'windows-latest' }} | |
| with: | |
| install-command: echo | |
| build: echo | |
| start: pnpm --dir ../temp/slidev-project dev --port 3041 | |
| spec: cypress/e2e/examples/smoke.spec.ts | |
| # Global-mode tests are exercised against npm only. pnpm v11 isolates | |
| # each top-level `pnpm add -g <pkg>` into its own install group whose | |
| # CAS only carries that package's direct deps; optional peers like | |
| # `@vue/compiler-sfc` (required at runtime by `unplugin-icons` → | |
| # `local-pkg`) never end up co-located with their importer and the | |
| # build fails. Slidev's resolver was taught to discover sibling | |
| # install groups (so theme resolution works), but the optional-peer | |
| # gap needs an upstream fix in pnpm or in the plugins that import | |
| # `@vue/compiler-sfc` lazily. Re-enable once that lands. | |
| - name: Install globally | |
| run: npm i -g /tmp/slidev-pkgs/cli.tgz playwright-chromium @slidev/theme-seriph | |
| if: ${{ matrix.pm == 'npm' }} | |
| - name: Create slide file | |
| run: pnpm --package=cpy-cli dlx cpy ./packages/slidev/template.md ../temp/ --flat | |
| if: ${{ matrix.pm == 'npm' }} | |
| - name: Test build command in global mode | |
| run: slidev build template.md | |
| if: ${{ matrix.pm == 'npm' }} | |
| working-directory: ../temp | |
| # Commented out because it's not working | |
| # - name: E2E test in global mode | |
| # uses: cypress-io/github-action@v7 | |
| # if: ${{ matrix.os != 'windows' }} | |
| # with: | |
| # project: ${{ github.workspace }} | |
| # install-command: echo | |
| # build: echo | |
| # start: ${{ 'bash -c "slidev ../template.md"' }} | |
| # spec: cypress/e2e/examples/noError.spec.ts |