Skip to content
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

Add Github workflow to validate PRs #560

Merged
merged 3 commits into from
Feb 4, 2025
Merged
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
46 changes: 46 additions & 0 deletions .github/workflows/pr-validation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
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

- name: Type Validation
run: npm run tsd
14 changes: 7 additions & 7 deletions src/textures/TextTextureRendererUtils.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});

Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down