Skip to content

Commit c0d9887

Browse files
dakerPaulHax
authored andcommitted
feat(build)!: migrate build/test tooling to Vite, Vitest, oxlint, oxfmt
Replace the webpack + rollup build, Karma test harness, and ESLint + Prettier with Vite, Vitest browser mode, oxlint, and oxfmt. BREAKING CHANGE: build, test, and lint tooling overhauled. See BREAKING_CHANGES.md for migration notes. Co-authored-by: Paul Elliott <paul@vizworkshop.com>
1 parent cc715f8 commit c0d9887

308 files changed

Lines changed: 18019 additions & 45593 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.babelrc.json

Lines changed: 0 additions & 14 deletions
This file was deleted.

.eslintrc.js

Lines changed: 0 additions & 78 deletions
This file was deleted.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Setup Node Project
2+
description: Setup Node and install dependencies with npm ci
3+
inputs:
4+
node-version:
5+
description: Node.js version
6+
required: false
7+
default: '22'
8+
runs:
9+
using: composite
10+
steps:
11+
- name: Setup node
12+
uses: actions/setup-node@v6
13+
with:
14+
node-version: ${{ inputs.node-version }}
15+
cache: 'npm'
16+
- name: Install dependencies
17+
shell: bash
18+
run: npm ci

.github/workflows/build-test.yml

Lines changed: 42 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,40 +7,65 @@ jobs:
77
build-test:
88
runs-on: ${{ matrix.os }}
99
strategy:
10+
fail-fast: false
1011
matrix:
1112
os: [ubuntu-24.04]
1213
node: [22]
13-
name: ${{ matrix.os }} and node ${{ matrix.node }}
14+
browser: [chromium, firefox]
15+
name: ${{ matrix.os }} / node ${{ matrix.node }} / ${{ matrix.browser }}
1416
steps:
15-
- uses: actions/checkout@v2
16-
- name: Setup node
17-
uses: actions/setup-node@v1
17+
- uses: actions/checkout@v6
18+
- name: Setup project
19+
uses: ./.github/actions/setup-node-project
1820
with:
19-
node-version: ${{ matrix.node }}
20-
- name: Install dependencies
21-
run: |
22-
npm ci
23-
sudo apt-get install xvfb
21+
node-version: '${{ matrix.node }}'
22+
- name: Resolve Playwright version
23+
id: playwright
24+
run: echo "version=$(node -p "require('playwright/package.json').version")" >> "$GITHUB_OUTPUT"
25+
- name: Cache Playwright browsers
26+
id: playwright-cache
27+
uses: actions/cache@v5
28+
with:
29+
path: ~/.cache/ms-playwright
30+
key: playwright-${{ matrix.os }}-${{ matrix.browser }}-${{ steps.playwright.outputs.version }}
31+
- name: Install Playwright browser
32+
if: steps.playwright-cache.outputs.cache-hit != 'true'
33+
run: npx playwright install ${{ matrix.browser }}
34+
- name: Install Playwright system deps
35+
run: sudo npx playwright install-deps ${{ matrix.browser }}
2436
- name: Build
2537
run: npm run build:release
2638
- name: Archive build output
27-
if: github.event_name != 'merge_group'
28-
uses: actions/upload-artifact@v4
39+
if: github.event_name != 'merge_group' && matrix.browser == 'chromium'
40+
uses: actions/upload-artifact@v7
2941
with:
30-
name: build-results-${{ matrix.runs_on }}-node_${{ matrix.node }}
42+
name: build-results-${{ matrix.os }}-node_${{ matrix.node }}
3143
path: dist
3244
retention-days: 15
3345
- name: Validate generated typescript definitions
3446
run: |
3547
npx tsc -p tsconfig.esm-check.json
3648
npx tsc -p tsconfig.umd-check.json
37-
- name: Chrome and Firefox tests
38-
run: xvfb-run --auto-servernum npm run test -- --browsers ChromeSwiftShader,Firefox
49+
- name: Smoke-test packed ESM tarball
50+
if: matrix.browser == 'chromium'
51+
run: |
52+
tarball=$(npm pack ./dist/esm --silent)
53+
mkdir -p /tmp/vtk-smoke
54+
cd /tmp/vtk-smoke
55+
npm init -y >/dev/null
56+
npm install --no-audit --no-fund "$GITHUB_WORKSPACE/$tarball"
57+
node -e "require('@kitware/vtk.js/Utilities/config/rules-vtk')"
58+
node -e "require('@kitware/vtk.js/Utilities/config/chainWebpack')"
59+
npx --no-install vtkDataConverter --help
60+
- name: Tests
61+
env:
62+
TEST_BROWSER: ${{ matrix.browser }}
63+
run: xvfb-run --auto-servernum npm test
3964
- name: Archive test results
4065
if: github.event_name != 'merge_group' && (success() || failure())
41-
uses: actions/upload-artifact@v4
66+
uses: actions/upload-artifact@v7
4267
continue-on-error: true
4368
with:
44-
name: test-results-${{ matrix.runs_on }}-node_${{ matrix.node }}
45-
path: Utilities/TestResults/Test-Report.html
69+
name: test-results-${{ matrix.os }}-node_${{ matrix.node }}-${{ matrix.browser }}
70+
path: Utilities/TestResults/
4671
retention-days: 15

.github/workflows/pr-checks.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,17 @@ jobs:
88
runs-on: ubuntu-24.04
99
name: Check and lint PR
1010
steps:
11-
- uses: actions/checkout@v2
11+
- uses: actions/checkout@v6
1212
with:
1313
fetch-depth: 0 # needed so commitlint can lint the commits
14-
- name: Setup node
15-
uses: actions/setup-node@v1
14+
- name: Setup project
15+
uses: ./.github/actions/setup-node-project
1616
with:
17-
node-version: 20
18-
- run: npm ci
17+
node-version: '22'
1918
- name: Enforce code style
2019
run: npm run validate
20+
- name: Lint
21+
run: npm run lint
2122
- name: Lint commits
2223
if: github.event_name != 'merge_group'
2324
run: npx commitlint --from=${{ github.event.pull_request.base.sha }}

.github/workflows/publish.yml

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,15 @@ jobs:
2222
name: npm
2323
steps:
2424
- name: Checkout
25-
uses: actions/checkout@v2
25+
uses: actions/checkout@v6
2626
with:
2727
fetch-depth: 0
28-
- name: Setup node
29-
uses: actions/setup-node@v4
28+
- name: Setup project
29+
uses: ./.github/actions/setup-node-project
3030
with:
31-
node-version: 22
32-
- name: Install dependencies
33-
run: |
34-
npm ci
35-
sudo apt-get install xvfb
31+
node-version: '22'
32+
- name: Install Playwright browsers
33+
run: npx playwright install --with-deps chromium firefox
3634
- name: Build
3735
run: npm run build:release
3836
- name: Validate code style
@@ -42,13 +40,13 @@ jobs:
4240
npx tsc -p tsconfig.esm-check.json
4341
npx tsc -p tsconfig.umd-check.json
4442
- name: Chrome and Firefox tests
45-
run: xvfb-run --auto-servernum npm run test -- --browsers ChromeSwiftShader,Firefox
43+
run: xvfb-run --auto-servernum npm test
4644
- name: Archive test results
4745
if: always()
48-
uses: actions/upload-artifact@v4
46+
uses: actions/upload-artifact@v7
4947
with:
5048
name: test-results
51-
path: Utilities/TestResults/Test-Report.html
49+
path: Utilities/TestResults/
5250
retention-days: 15
5351
- name: Release
5452
env:
@@ -70,25 +68,17 @@ jobs:
7068
runs-on: ubuntu-latest
7169
steps:
7270
- name: Checkout
73-
uses: actions/checkout@v2
71+
uses: actions/checkout@v6
7472
with:
7573
fetch-depth: 1
76-
- name: Setup node
77-
uses: actions/setup-node@v1
74+
- name: Setup project
75+
uses: ./.github/actions/setup-node-project
7876
with:
79-
node-version: 22
80-
- name: Install dependencies
81-
run: npm ci
77+
node-version: '22'
8278
- name: Build
8379
run: npm run build:release
84-
- name: Generate API docs
85-
run: npm run docs:generate-api
86-
- name: Generate docs examples
87-
run: npm run docs:generate-examples
88-
- name: Generate docs sidebar
89-
run: npm run docs:generate-sidebar
90-
- name: Generate docs gallery
91-
run: npm run docs:generate-gallery
80+
- name: Generate docs content
81+
run: npm run docs:generate
9282
- name: Build docs
9383
run: npm run docs:build
9484
- name: Build docs examples
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash
22
cd $(dirname $(readlink -e $0))/../../
3-
! git grep 'test\.only(' **/test*.js
3+
! git grep -E '\b(test|it|describe)\.only\(' -- '**/test*.js'

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,15 @@ dist/
99
coverage/
1010
.env
1111
Utilities/TestResults
12+
.vitest-attachments/
1213
.idea
1314
Documentation/.vitepress/cache/
1415
Documentation/.vitepress/dist/
1516
Documentation/build-tmp/
1617
Documentation/content/
1718
Documentation/Examples/
19+
Documentation/api/*.md
20+
!Documentation/api/index.md
21+
Documentation/examples/*.md
22+
!Documentation/examples/index.md
23+
Documentation/examples/gallery.js

.oxfmtrc.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"$schema": "./node_modules/oxfmt/configuration_schema.json",
3+
"printWidth": 80,
4+
"singleQuote": true,
5+
"trailingComma": "es5",
6+
"arrowParens": "always",
7+
"sortPackageJson": false,
8+
"ignorePatterns": []
9+
}

.oxlintrc.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"$schema": "./node_modules/oxlint/configuration_schema.json",
3+
"plugins": ["import"],
4+
"env": {
5+
"es2020": true,
6+
"es6": true,
7+
"browser": true
8+
},
9+
"globals": {
10+
"__BASE_PATH__": "readonly",
11+
"__VTK_TEST_NO_WEBGL__": "readonly",
12+
"__VTK_TEST_WEBGPU__": "readonly",
13+
"VRFrameData": "readonly"
14+
},
15+
"rules": {
16+
"no-console": "off",
17+
"no-param-reassign": [
18+
"warn",
19+
{
20+
"props": false
21+
}
22+
],
23+
"no-plusplus": "off",
24+
"no-underscore-dangle": "off",
25+
"no-unused-vars": [
26+
"warn",
27+
{
28+
"args": "none"
29+
}
30+
],
31+
"prefer-destructuring": "off"
32+
},
33+
"ignorePatterns": [
34+
"**/example_/*.js",
35+
"Utilities/**/*.js",
36+
"vite.config.js",
37+
"vitest.config.js",
38+
".eslintrc.js"
39+
]
40+
}

0 commit comments

Comments
 (0)