mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-18 10:46:31 +00:00
[CI] Playwright improvements (#9395)
* Allow port 4173 (vite preview) * Change 'base' attr based on vite command * Allow api_host to be specified separately * Harden API host functionality * Adjust server selections * Cleanup vite.config.ts * Adjust playwright configuration - Allow to run in "production" mode - Builds the code first - Runs only the backend web server - Not suitable for coverage * Tweak github actions * Tweak QC file * Reduce number of steps * Tweak CI file * Fix typo * Ensure translation before build * Fix hard-coded test * Test tweaks * uncomment * Revert some changes * Run with gunicorn, single worker * Reduce log output in DEBUG mode * Update deps * Add global-setup func * Fix for .gitignore file * Cached auth state * Tweak login func * Updated tests * Enable parallel workers again * Simplify config * Try with a single worker again * Single retry mode * Run auth setup first - Prevent issues with parallel test doing login * Improve test setup process * Tweaks * Bump to 3 workers * Tweak playwright settings * Revert change * Revert change
This commit is contained in:
@@ -6,66 +6,77 @@ import license from 'rollup-plugin-license';
|
||||
import { defineConfig, splitVendorChunkPlugin } from 'vite';
|
||||
import istanbul from 'vite-plugin-istanbul';
|
||||
|
||||
// Detect if the current environment is WSL
|
||||
// Required for enabling file system polling
|
||||
const IS_IN_WSL = platform().includes('WSL') || release().includes('WSL');
|
||||
const is_coverage = process.env.VITE_COVERAGE === 'true';
|
||||
|
||||
// Detect if code coverage is enabled (runs in GitHub CI)
|
||||
const IS_COVERAGE = !!process.env.VITE_COVERAGE_BUILD;
|
||||
|
||||
if (IS_IN_WSL) {
|
||||
console.log('WSL detected: using polling for file system events');
|
||||
}
|
||||
|
||||
// Output directory for the built files
|
||||
const OUTPUT_DIR = '../../src/backend/InvenTree/web/static/web';
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
react({
|
||||
babel: {
|
||||
plugins: ['macros']
|
||||
}
|
||||
}),
|
||||
vanillaExtractPlugin(),
|
||||
splitVendorChunkPlugin(),
|
||||
license({
|
||||
sourcemap: true,
|
||||
thirdParty: {
|
||||
includePrivate: true,
|
||||
multipleVersions: true,
|
||||
output: {
|
||||
file: '../backend/InvenTree/web/static/web/.vite/dependencies.json',
|
||||
template(dependencies) {
|
||||
return JSON.stringify(dependencies);
|
||||
export default defineConfig(({ command, mode }) => {
|
||||
return {
|
||||
plugins: [
|
||||
react({
|
||||
babel: {
|
||||
plugins: ['macros']
|
||||
}
|
||||
}),
|
||||
vanillaExtractPlugin(),
|
||||
splitVendorChunkPlugin(),
|
||||
license({
|
||||
sourcemap: true,
|
||||
thirdParty: {
|
||||
includePrivate: true,
|
||||
multipleVersions: true,
|
||||
output: {
|
||||
file: '../backend/InvenTree/web/static/web/.vite/dependencies.json',
|
||||
template(dependencies) {
|
||||
return JSON.stringify(dependencies);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}),
|
||||
istanbul({
|
||||
include: 'src/*',
|
||||
exclude: ['node_modules', 'test/'],
|
||||
extension: ['.js', '.ts', '.tsx'],
|
||||
requireEnv: true
|
||||
}),
|
||||
codecovVitePlugin({
|
||||
enableBundleAnalysis: process.env.CODECOV_TOKEN !== undefined,
|
||||
bundleName: 'pui_v1',
|
||||
uploadToken: process.env.CODECOV_TOKEN
|
||||
})
|
||||
],
|
||||
base: '',
|
||||
build: {
|
||||
manifest: true,
|
||||
outDir: '../../src/backend/InvenTree/web/static/web',
|
||||
sourcemap: is_coverage
|
||||
},
|
||||
server: {
|
||||
proxy: {
|
||||
'/media': {
|
||||
target: 'http://localhost:8000',
|
||||
changeOrigin: true,
|
||||
secure: true
|
||||
}
|
||||
}),
|
||||
istanbul({
|
||||
include: 'src/*',
|
||||
exclude: ['node_modules', 'test/'],
|
||||
extension: ['.js', '.ts', '.tsx'],
|
||||
requireEnv: true
|
||||
}),
|
||||
codecovVitePlugin({
|
||||
enableBundleAnalysis: process.env.CODECOV_TOKEN !== undefined,
|
||||
bundleName: 'pui_v1',
|
||||
uploadToken: process.env.CODECOV_TOKEN
|
||||
})
|
||||
],
|
||||
// When building, set the base path to an empty string
|
||||
// This is required to ensure that the static path prefix is observed
|
||||
base: command == 'build' ? '' : undefined,
|
||||
build: {
|
||||
manifest: true,
|
||||
outDir: OUTPUT_DIR,
|
||||
sourcemap: IS_COVERAGE
|
||||
},
|
||||
watch: {
|
||||
// use polling only for WSL as the file system doesn't trigger notifications for Linux apps
|
||||
// ref: https://github.com/vitejs/vite/issues/1153#issuecomment-785467271
|
||||
usePolling: IS_IN_WSL
|
||||
server: {
|
||||
proxy: {
|
||||
'/media': {
|
||||
target: 'http://localhost:8000',
|
||||
changeOrigin: true,
|
||||
secure: true
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
// Use polling only for WSL as the file system doesn't trigger notifications for Linux apps
|
||||
// Ref: https://github.com/vitejs/vite/issues/1153#issuecomment-785467271
|
||||
usePolling: IS_IN_WSL
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
Reference in New Issue
Block a user