返回 slidev
smoke.yml
根目录 / .github / workflows / smoke.yml
1 name: Production Smoke Test
2
3 on:
4 push:
5 branches:
6 - main
7 - master
8
9 pull_request:
10 branches:
11 - main
12 - master
13
14 workflow_dispatch:
15
16 jobs:
17 pack:
18 timeout-minutes: 10
19 runs-on: ubuntu-latest
20 steps:
21 - name: Set git to use LF
22 run: |
23 git config --global core.autocrlf false
24 git config --global core.eol lf
25
26 - uses: actions/checkout@v6
27
28 - name: Setup pnpm
29 uses: pnpm/action-setup@v4
30
31 - name: Use Node.js
32 uses: actions/setup-node@v6
33 with:
34 node-version: lts/*
35 cache: pnpm
36
37 - name: Setup
38 run: npm i -g @antfu/ni
39
40 - name: Install
41 run: nci
42 env:
43 CYPRESS_INSTALL_BINARY: 0
44
45 - name: Build
46 run: nr build
47
48 - name: Pack
49 run: node ./scripts/pack.mjs /tmp/slidev-pkgs
50
51 - name: Upload artifacts
52 uses: actions/upload-artifact@v6
53 with:
54 name: slidev-packages
55 path: /tmp/slidev-pkgs
56
57 test:
58 needs: pack
59 runs-on: ${{ matrix.os }}
60
61 strategy:
62 matrix:
63 os: [ubuntu-latest, windows-latest]
64 pm: [npm, pnpm] # yarn not working in this CI
65 hoist: [true, false]
66
67 steps:
68 - name: Set git to use LF
69 run: |
70 git config --global core.autocrlf false
71 git config --global core.eol lf
72
73 - uses: actions/checkout@v6
74
75 - name: Setup PNPM
76 uses: pnpm/action-setup@v4
77
78 - name: Use Node.js lts/*
79 uses: actions/setup-node@v6
80 with:
81 node-version: lts/*
82 cache: pnpm
83
84 - name: Setup
85 run: npm i -g @antfu/ni
86
87 # pnpm v11 stores globally-installed binaries in `$PNPM_HOME/bin` instead
88 # of directly in `$PNPM_HOME`; without this, `pnpm i -g` aborts with
89 # "configured global bin directory is not in PATH".
90 - name: Add pnpm global bin to PATH
91 run: echo "$PNPM_HOME/bin" >> "$GITHUB_PATH"
92 shell: bash
93
94 - name: Install
95 run: nci
96
97 - name: Download artifacts
98 uses: actions/download-artifact@v7
99 with:
100 name: slidev-packages
101 path: /tmp/slidev-pkgs
102
103 - name: Create new project
104 run: |
105 npm i -g /tmp/slidev-pkgs/create-app.tgz
106 echo "N" | create-slidev ../temp/slidev-project
107
108 - name: Remove npmrc
109 run: pnpx del-cli ./.npmrc
110 working-directory: ../temp/slidev-project
111 if: ${{ ! matrix.hoist }}
112
113 - name: Remove overridden dependencies
114 run: node ${{ github.workspace }}/scripts/remove-overridden-deps.mjs
115 working-directory: ../temp/slidev-project
116
117 - name: Install project (npm, pnpm)
118 run: ${{ matrix.pm }} i /tmp/slidev-pkgs/cli.tgz playwright-chromium
119 working-directory: ../temp/slidev-project
120 if: ${{ matrix.pm != 'yarn' }}
121
122 - name: Install Playwright browsers
123 run: pnpx playwright install chromium
124 working-directory: ../temp/slidev-project
125
126 - name: Install project (yarn)
127 run: yarn add /tmp/slidev-pkgs/cli.tgz playwright-chromium
128 working-directory: ../temp/slidev-project
129 if: ${{ matrix.pm == 'yarn' }}
130
131 - name: Test build command in project
132 run: pnpm build
133 working-directory: ../temp/slidev-project
134
135 - name: E2E Smoke Test
136 uses: cypress-io/github-action@v7
137 if: ${{ matrix.os != 'windows-latest' }}
138 with:
139 install-command: echo
140 build: echo
141 start: pnpm --dir ../temp/slidev-project dev --port 3041
142 spec: cypress/e2e/examples/smoke.spec.ts
143
144 # Global-mode tests are exercised against npm only. pnpm v11 isolates
145 # each top-level `pnpm add -g <pkg>` into its own install group whose
146 # CAS only carries that package's direct deps; optional peers like
147 # `@vue/compiler-sfc` (required at runtime by `unplugin-icons` →
148 # `local-pkg`) never end up co-located with their importer and the
149 # build fails. Slidev's resolver was taught to discover sibling
150 # install groups (so theme resolution works), but the optional-peer
151 # gap needs an upstream fix in pnpm or in the plugins that import
152 # `@vue/compiler-sfc` lazily. Re-enable once that lands.
153 - name: Install globally
154 run: npm i -g /tmp/slidev-pkgs/cli.tgz playwright-chromium @slidev/theme-seriph
155 if: ${{ matrix.pm == 'npm' }}
156
157 - name: Create slide file
158 run: pnpm --package=cpy-cli dlx cpy ./packages/slidev/template.md ../temp/ --flat
159 if: ${{ matrix.pm == 'npm' }}
160
161 - name: Test build command in global mode
162 run: slidev build template.md
163 if: ${{ matrix.pm == 'npm' }}
164 working-directory: ../temp
165
166 # Commented out because it's not working
167 # - name: E2E test in global mode
168 # uses: cypress-io/github-action@v7
169 # if: ${{ matrix.os != 'windows' }}
170 # with:
171 # project: ${{ github.workspace }}
172 # install-command: echo
173 # build: echo
174 # start: ${{ 'bash -c "slidev ../template.md"' }}
175 # spec: cypress/e2e/examples/noError.spec.ts
176
176 lines YAML