File tree Expand file tree Collapse file tree 6 files changed +64
-10
lines changed Expand file tree Collapse file tree 6 files changed +64
-10
lines changed Original file line number Diff line number Diff line change @@ -141,6 +141,33 @@ jobs:
141
141
- name : Build codes
142
142
run : npm run build
143
143
144
+ # https://github.com/vitejs/vite/blob/main/.github/workflows/ci.yml#L91
145
+ # Install playwright's binary under custom directory to cache
146
+ - name : (non-windows) Set Playwright path and Get playwright version
147
+ if : runner.os != 'Windows'
148
+ run : |
149
+ echo "PLAYWRIGHT_BROWSERS_PATH=$HOME/.cache/playwright-bin" >> $GITHUB_ENV
150
+ PLAYWRIGHT_VERSION="$(bun run ./scripts/playwright-version.ts)"
151
+ echo "PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION" >> $GITHUB_ENV
152
+ - name : (windows) Set Playwright path and Get playwright version
153
+ if : runner.os == 'Windows'
154
+ run : |
155
+ echo "PLAYWRIGHT_BROWSERS_PATH=$HOME\.cache\playwright-bin" >> $env:GITHUB_ENV
156
+ PLAYWRIGHT_VERSION="$(bun run ./scripts/playwright-version.ts)"
157
+ echo "PLAYWRIGHT_VERSION=$env:PLAYWRIGHT_VERSION" >> $env:GITHUB_ENV
158
+
159
+ - name : Cache Playwright's binary
160
+ uses : actions/cache@v3
161
+ with :
162
+ key : ${{ runner.os }}-playwright-bin-v1-${{ env.PLAYWRIGHT_VERSION }}
163
+ path : ${{ env.PLAYWRIGHT_BROWSERS_PATH }}
164
+ restore-keys : |
165
+ ${{ runner.os }}-playwright-bin-v1-
166
+
167
+ - name : Install Playwright
168
+ # does not need to explicitly set chromium after https://github.com/microsoft/playwright/issues/14862 is solved
169
+ run : bun x playwright install chromium
170
+
144
171
- name : Run test
145
172
run : ./scripts/e2e.sh
146
173
Original file line number Diff line number Diff line change 114
114
"npm-run-all" : " ^4.1.5" ,
115
115
"miniflare" : " ^3.20231016.0" ,
116
116
"supertest" : " ^6.3.3" ,
117
+ "playwright" : " ^1.38.1" ,
117
118
"pkg-types" : " ^1.0.2" ,
118
119
"typescript" : " ^5.2.2" ,
119
120
"unbuild" : " ^2.0.0" ,
Original file line number Diff line number Diff line change
1
+ import { resolve } from 'node:path'
2
+ import { fileURLToPath } from 'node:url'
3
+ import { readPackageJSON } from 'pkg-types'
4
+ import { isExists } from './utils.ts'
5
+
6
+ const __dirname = fileURLToPath ( new URL ( '.' , import . meta. url ) )
7
+
8
+ async function main ( ) {
9
+ const playwrightPath = resolve ( __dirname , '../node_modules/playwright' )
10
+ if ( ! await isExists ( playwrightPath ) ) {
11
+ throw new Error ( `not found '${ playwrightPath } '` )
12
+ }
13
+
14
+ const playwrightPkg = await readPackageJSON ( playwrightPath )
15
+ if ( ! playwrightPkg . version ) {
16
+ throw new Error ( `not found 'version' in 'playwright'` )
17
+ }
18
+ console . log ( playwrightPkg . version )
19
+ }
20
+
21
+ main ( ) . catch ( ( err ) => {
22
+ console . error ( err )
23
+ process . exit ( 1 )
24
+ } )
Original file line number Diff line number Diff line change 1
- import { constants as FS_CONSTANTS , promises as fs } from 'node:fs'
1
+ import { promises as fs } from 'node:fs'
2
2
import { resolve } from 'node:path'
3
3
import { fileURLToPath } from 'node:url'
4
4
import { readPackageJSON , writePackageJSON } from 'pkg-types'
5
+ import { isExists } from './utils.ts'
5
6
6
7
const __dirname = fileURLToPath ( new URL ( '.' , import . meta. url ) )
7
8
8
- export async function isExists ( path : string ) {
9
- try {
10
- await fs . access ( path , FS_CONSTANTS . F_OK )
11
- return true
12
- } catch {
13
- return false
14
- }
15
- }
16
-
17
9
type Platform = 'browser' | 'node' | 'deno' | 'bun'
18
10
19
11
async function replaceNodePlatform ( platform : 'node' | 'bun' , playgroundPath : string ) {
Original file line number Diff line number Diff line change
1
+ import { constants as FS_CONSTANTS , promises as fs } from 'node:fs'
2
+
3
+ export async function isExists ( path : string ) {
4
+ try {
5
+ await fs . access ( path , FS_CONSTANTS . F_OK )
6
+ return true
7
+ } catch {
8
+ return false
9
+ }
10
+ }
You can’t perform that action at this time.
0 commit comments