-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: dynamic import retry plugin [KM-865] #2
base: main
Are you sure you want to change the base?
Changes from 1 commit
9ddda00
96fd000
5d1fbb5
5042a73
73dc74e
b87ef41
5afe05b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,3 +71,18 @@ runs: | |
with: | ||
path: './node_modules' | ||
key: ${{ steps.node-version.outputs.cache-key }} | ||
|
||
- name: Set Playwright path | ||
shell: bash | ||
run: echo "PLAYWRIGHT_BROWSERS_PATH=$HOME/.cache/playwright-bin" >> $GITHUB_ENV | ||
|
||
- name: Cache Playwright's binary | ||
uses: actions/cache@v4 | ||
with: | ||
key: playwright-bin-v1 | ||
path: ${{ env.PLAYWRIGHT_BROWSERS_PATH }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: It would be preferred to give the step an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
|
||
- name: Install Playwright | ||
shell: bash | ||
# does not need to explicitly set chromium after https://github.com/microsoft/playwright/issues/14862 is solved | ||
run: pnpm playwright install chromium |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,3 +20,6 @@ dist | |
|
||
# Local History | ||
.history | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe some additional playwright artifact paths will need to be added |
||
playground-temp | ||
temp |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,8 +6,11 @@ | |
"scripts": { | ||
"lint": "eslint", | ||
"lint:fix": "eslint --fix", | ||
"test": "vitest run --passWithNoTests", | ||
"test:ui": "vitest --ui --passWithNoTests", | ||
"test": "run-s test-serve test-build", | ||
"test-serve": "vitest run -c vitest.config.e2e.ts", | ||
"test-build": "VITE_TEST_BUILD=1 vitest run -c vitest.config.e2e.ts", | ||
"debug-serve": "VITE_DEBUG_SERVE=1 vitest run -c vitest.config.e2e.ts", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question: I'm not sure I understand the multiple test commands here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
"debug-build": "VITE_TEST_BUILD=1 VITE_PRESERVE_BUILD_ARTIFACTS=1 vitest run -c vitest.config.e2e.ts", | ||
"typecheck": "vue-tsc --noEmit", | ||
"build": "unbuild", | ||
"commit": "cz" | ||
|
@@ -16,9 +19,15 @@ | |
"./plugin-example-one": { | ||
"import": "./dist/plugin-example-one/index.mjs", | ||
"types": "./dist/plugin-example-one/index.d.ts" | ||
}, | ||
"./plugin-dynamic-import-retry": { | ||
"import": "./dist/plugin-dynamic-import-retry/index.mjs", | ||
"types": "./dist/plugin-dynamic-import-retry/index.d.ts" | ||
} | ||
}, | ||
"files": ["dist"], | ||
"files": [ | ||
"dist" | ||
], | ||
"author": "Kong, Inc.", | ||
"license": "Apache-2.0", | ||
"devDependencies": { | ||
|
@@ -27,10 +36,15 @@ | |
"@digitalroute/cz-conventional-changelog-for-jira": "^8.0.1", | ||
"@evilmartians/lefthook": "^1.10.1", | ||
"@kong/eslint-config-kong-ui": "^1.2.2", | ||
"@types/fs-extra": "^11.0.4", | ||
"@vitest/ui": "^2.1.8", | ||
"eslint": "^9.17.0", | ||
"fs-extra": "^11.2.0", | ||
"npm-run-all2": "^7.0.2", | ||
"playwright-chromium": "^1.49.1", | ||
"typescript": "^5.7.2", | ||
"unbuild": "^3.2.0", | ||
"vite": "^6.0.7", | ||
"vitest": "^2.1.8", | ||
"vue-tsc": "^2.2.0" | ||
}, | ||
|
@@ -52,5 +66,13 @@ | |
"jiraPrepend": "[", | ||
"jiraAppend": "]" | ||
} | ||
}, | ||
"dependencies": { | ||
"@rollup/pluginutils": "^5.1.4", | ||
"acorn-walk": "^8.3.4", | ||
"magic-string": "^0.30.17" | ||
}, | ||
"peerDependencies": { | ||
"vite": "^5.0.0 || ^6.0.0" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import os from 'node:os' | ||
import path from 'node:path' | ||
import fs from 'fs-extra' | ||
import type { BrowserServer } from 'playwright-chromium' | ||
import { chromium } from 'playwright-chromium' | ||
|
||
const DIR = path.join(os.tmpdir(), 'vitest_playwright_global_setup') | ||
|
||
let browserServer: BrowserServer | undefined | ||
|
||
export async function setup(): Promise<void> { | ||
adamdehaven marked this conversation as resolved.
Show resolved
Hide resolved
|
||
browserServer = await chromium.launchServer({ | ||
headless: !process.env.VITE_DEBUG_SERVE, | ||
args: process.env.CI | ||
? ['--no-sandbox', '--disable-setuid-sandbox'] | ||
: undefined, | ||
}) | ||
|
||
await fs.mkdirp(DIR) | ||
await fs.writeFile(path.join(DIR, 'wsEndpoint'), browserServer.wsEndpoint()) | ||
|
||
const tempDir = path.resolve(__dirname, '../playground-temp') | ||
await fs.ensureDir(tempDir) | ||
await fs.emptyDir(tempDir) | ||
await fs | ||
.copy(path.resolve(__dirname, '../playground'), tempDir, { | ||
dereference: false, | ||
filter(file) { | ||
file = file.replace(/\\/g, '/') | ||
return !file.includes('__tests__') && !file.match(/dist(\/|$)/) | ||
}, | ||
}) | ||
.catch(async (error) => { | ||
if (error.code === 'EPERM' && error.syscall === 'symlink') { | ||
throw new Error( | ||
'Could not create symlinks. On Windows, consider activating Developer Mode to allow non-admin users to create symlinks by following the instructions at https://docs.microsoft.com/en-us/windows/apps/get-started/enable-your-device-for-development.', | ||
) | ||
} else { | ||
throw error | ||
} | ||
}) | ||
} | ||
|
||
export async function teardown(): Promise<void> { | ||
await browserServer?.close() | ||
if (!process.env.VITE_PRESERVE_BUILD_ARTIFACTS) { | ||
fs.removeSync(path.resolve(__dirname, '../playground-temp')) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we tie the cache key here to a dynamic string that includes the playwright dependency version from package.json?