Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 23 additions & 8 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ jobs:
build-test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04]
node: [22]
name: ${{ matrix.os }} and node ${{ matrix.node }}
browser: [chromium, firefox]
name: ${{ matrix.os }} / node ${{ matrix.node }} / ${{ matrix.browser }}
steps:
- uses: actions/checkout@v6
- name: Setup project
Expand All @@ -25,16 +27,16 @@ jobs:
uses: actions/cache@v5
with:
path: ~/.cache/ms-playwright
key: playwright-${{ matrix.os }}-${{ steps.playwright.outputs.version }}
- name: Install Playwright browsers
key: playwright-${{ matrix.os }}-${{ matrix.browser }}-${{ steps.playwright.outputs.version }}
- name: Install Playwright browser
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: npx playwright install chromium firefox
run: npx playwright install ${{ matrix.browser }}
- name: Install Playwright system deps
run: sudo npx playwright install-deps chromium firefox
run: sudo npx playwright install-deps ${{ matrix.browser }}
- name: Build
run: npm run build:release
- name: Archive build output
if: github.event_name != 'merge_group'
if: github.event_name != 'merge_group' && matrix.browser == 'chromium'
uses: actions/upload-artifact@v7
with:
name: build-results-${{ matrix.os }}-node_${{ matrix.node }}
Expand All @@ -44,13 +46,26 @@ jobs:
run: |
npx tsc -p tsconfig.esm-check.json
npx tsc -p tsconfig.umd-check.json
- name: Chrome and Firefox tests
- name: Smoke-test packed ESM tarball
if: matrix.browser == 'chromium'
run: |
tarball=$(npm pack ./dist/esm --silent)
mkdir -p /tmp/vtk-smoke
cd /tmp/vtk-smoke
npm init -y >/dev/null
npm install --no-audit --no-fund "$GITHUB_WORKSPACE/$tarball"
node -e "require('@kitware/vtk.js/Utilities/config/rules-vtk')"
node -e "require('@kitware/vtk.js/Utilities/config/chainWebpack')"
npx --no-install vtkDataConverter --help
- name: Tests
env:
TEST_BROWSER: ${{ matrix.browser }}
run: xvfb-run --auto-servernum npm test
- name: Archive test results
if: github.event_name != 'merge_group' && (success() || failure())
uses: actions/upload-artifact@v7
continue-on-error: true
with:
name: test-results-${{ matrix.os }}-node_${{ matrix.node }}
name: test-results-${{ matrix.os }}-node_${{ matrix.node }}-${{ matrix.browser }}
path: Utilities/TestResults/
retention-days: 15
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ dist/
coverage/
.env
Utilities/TestResults
.vitest-attachments/
.idea
Documentation/.vitepress/cache/
Documentation/.vitepress/dist/
Expand Down
13 changes: 13 additions & 0 deletions Utilities/build/vtk-plugins.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,25 @@ export function copyEsmAssetsPlugin({ esmOutputDir }) {
'Utilities/DataGenerator',
`${esmOutputDir}/Utilities/DataGenerator`
);
copyDir('Utilities/config', `${esmOutputDir}/Utilities/config`);
fs.mkdirSync(`${esmOutputDir}/Utilities`, { recursive: true });
fs.copyFileSync(
'Utilities/prepare.js',
`${esmOutputDir}/Utilities/prepare.js`
);

// Flip these CJS subdirs back to CommonJS scope (root is type: module).
for (const dir of [
'Utilities/config',
'Utilities/XMLConverter',
'Utilities/DataGenerator',
]) {
fs.writeFileSync(
`${esmOutputDir}/${dir}/package.json`,
`${JSON.stringify({ type: 'commonjs' }, null, 2)}\n`
);
}

fs.copyFileSync(
'Utilities/build/macro-shim.d.ts',
`${esmOutputDir}/macro.d.ts`
Expand Down
46 changes: 22 additions & 24 deletions vitest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,29 @@ const webGPU = !!process.env.WEBGPU;
const testBrowser = process.env.TEST_BROWSER || 'chromium';
const ci = !!process.env.CI;

// Per-instance launch.headless is load-bearing for Firefox WebGL on Linux CI;
// the top-level browser.headless takes a different launch path that drops WebGL.
const firefoxUserPrefs = {
'dom.webgpu.enabled': true, // off by default on Linux Firefox
'webgl.force-enabled': true, // override GPU blocklist (no real GPU on CI)
'webgl.disable-fail-if-major-performance-caveat': true, // accept llvmpipe
};

const chromiumArgs = ci
? ['--no-sandbox', '--enable-unsafe-swiftshader', '--use-angle=swiftshader']
: [];

const firefox = {
browser: 'firefox',
launch: {
headless: true,
firefoxUserPrefs: {
'dom.webgpu.enabled': true, // off by default on Linux Firefox
'webgl.force-enabled': true, // override GPU blocklist (no real GPU on CI)
'webgl.disable-fail-if-major-performance-caveat': true, // accept llvmpipe
},
},
headless: false, // supported Vitest Browser option; xvfb-run supplies the display on CI
};

function buildBrowserInstances() {
if (ci) {
return [
{
browser: 'chromium',
launch: {
headless: true,
args: ['--no-sandbox', '--enable-unsafe-swiftshader', '--use-angle=swiftshader'],
},
},
firefox,
];
}
return [testBrowser === 'firefox' ? firefox : { browser: 'chromium', launch: { headless: true } }];
if (testBrowser === 'firefox') return [firefox];
return [{ browser: 'chromium' }];
}

function buildPlaywrightLaunchOptions() {
if (testBrowser === 'firefox') return { firefoxUserPrefs };
return chromiumArgs.length ? { args: chromiumArgs } : {};
}

export default defineConfig({
Expand Down Expand Up @@ -82,7 +77,10 @@ export default defineConfig({
browser: {
enabled: true,
headless: true,
provider: playwright(),
screenshotDirectory: 'Utilities/TestResults/screenshots',
provider: playwright({
launchOptions: buildPlaywrightLaunchOptions(),
}),
instances: buildBrowserInstances(),
},
},
Expand Down
Loading