From 7c90a7b19c781576a5ca23c6bb150f8ed56e4e4b Mon Sep 17 00:00:00 2001 From: Philippe Elsass Date: Tue, 28 Jan 2025 11:13:53 +0100 Subject: [PATCH 1/3] Add Github workflow --- .github/workflows/pr-validation.yml | 44 +++++++++++++++++++++++++++++ tsconfig.json | 1 + 2 files changed, 45 insertions(+) create mode 100644 .github/workflows/pr-validation.yml diff --git a/.github/workflows/pr-validation.yml b/.github/workflows/pr-validation.yml new file mode 100644 index 00000000..28fc9839 --- /dev/null +++ b/.github/workflows/pr-validation.yml @@ -0,0 +1,44 @@ +name: PR Validation + +on: + pull_request: + branches: [ master, dev ] + push: + branches: [ master, dev ] + +jobs: + test-and-build: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [20.x, 22.x] + include: + - node-version: 20.x + experimental: false + - node-version: 22.x + experimental: true + + continue-on-error: ${{ matrix.experimental }} + + steps: + - uses: actions/checkout@v4 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Type Check + run: npx tsc --noEmit + + - name: Run tests + run: npm test + + - name: Build + run: npm run build + diff --git a/tsconfig.json b/tsconfig.json index 50ebb95d..c1c8cc63 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -20,6 +20,7 @@ "sourceMap": true, "declarationMap": true, "isolatedModules": true, + "skipLibCheck": true, // Don't emit any files via the root tsconfig.json // (this is a project-wide config and includes the test-d folder which From 698adaea884f358e98ebc8474ca13ae474560f9b Mon Sep 17 00:00:00 2001 From: Philippe Elsass Date: Tue, 28 Jan 2025 11:20:15 +0100 Subject: [PATCH 2/3] Fix tests --- src/textures/TextTextureRendererUtils.test.mjs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/textures/TextTextureRendererUtils.test.mjs b/src/textures/TextTextureRendererUtils.test.mjs index dba4c66f..506f97d6 100644 --- a/src/textures/TextTextureRendererUtils.test.mjs +++ b/src/textures/TextTextureRendererUtils.test.mjs @@ -4,28 +4,28 @@ import { getFontSetting, tokenizeString, isSpace, isZeroWidthSpace, wrapText, me describe('TextTextureRendererUtils', () => { describe('getFontSetting', () => { it('should form a valid CSS font string', () => { - expect(getFontSetting('Arial', 'normal', 12, 1, 'Default')).toBe('normal 12px "Arial"'); + expect(getFontSetting('Arial', 'normal', 12, 1, 'Default')).toBe('normal 12px Arial'); expect(getFontSetting('Times New Roman', 'bold', 30, 1, 'Default')).toBe('bold 30px "Times New Roman"'); }); it('should adjust font size for precision', () => { - expect(getFontSetting('Arial', 'normal', 12, 2, 'Default')).toBe('normal 24px "Arial"'); + expect(getFontSetting('Arial', 'normal', 12, 2, 'Default')).toBe('normal 24px Arial'); }); it('should support "serif" and "sans-serif" specially', () => { expect(getFontSetting('serif', 'italic', 12, 1, 'Default')).toBe('italic 12px serif'); expect(getFontSetting('sans-serif', 'normal', 12, 1, 'Default')).toBe('normal 12px sans-serif'); }); it('should default to the defaultFontFace if fontFace is null', () => { - expect(getFontSetting(null, 'normal', 12, 1, 'Default')).toBe('normal 12px "Default"'); - expect(getFontSetting([null], 'normal', 12, 1, 'Default')).toBe('normal 12px "Default"'); + expect(getFontSetting(null, 'normal', 12, 1, 'Default')).toBe('normal 12px Default'); + expect(getFontSetting([null], 'normal', 12, 1, 'Default')).toBe('normal 12px Default'); }); it('should defaultFontFace should also handle "serif" and "sans-serif" specially', () => { expect(getFontSetting(null, 'normal', 12, 1, 'serif')).toBe('normal 12px serif'); expect(getFontSetting([null], 'normal', 12, 1, 'sans-serif')).toBe('normal 12px sans-serif'); }); it('should support an array of fonts', () => { - expect(getFontSetting(['Arial'], 'normal', 12, 1, 'Default')).toBe('normal 12px "Arial"'); - expect(getFontSetting(['serif', 'Arial'], 'italic', 12, 1, 'Default')).toBe('italic 12px serif,"Arial"'); - expect(getFontSetting(['serif', 'Arial', null], 'bold', 12, 1, 'Default')).toBe('bold 12px serif,"Arial","Default"'); + expect(getFontSetting(['Arial'], 'normal', 12, 1, 'Default')).toBe('normal 12px Arial'); + expect(getFontSetting(['serif', 'Arial'], 'italic', 12, 1, 'Default')).toBe('italic 12px serif,Arial'); + expect(getFontSetting(['serif', 'Arial', null], 'bold', 12, 1, 'Default')).toBe('bold 12px serif,Arial,Default'); }); }); From b735932f0492fb75e3a5d05880cbe91efaa1e088 Mon Sep 17 00:00:00 2001 From: Philippe Elsass Date: Fri, 31 Jan 2025 11:22:25 +0100 Subject: [PATCH 3/3] Add missing tsd validation --- .github/workflows/pr-validation.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/pr-validation.yml b/.github/workflows/pr-validation.yml index 28fc9839..8d693ed3 100644 --- a/.github/workflows/pr-validation.yml +++ b/.github/workflows/pr-validation.yml @@ -42,3 +42,5 @@ jobs: - name: Build run: npm run build + - name: Type Validation + run: npm run tsd