Skip to content

Commit

Permalink
Merge pull request #560 from elsassph/feat/ci
Browse files Browse the repository at this point in the history
Add Github workflow to validate PRs
  • Loading branch information
wouterlucas authored Feb 4, 2025
2 parents c188d6b + b735932 commit 8e9b510
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 7 deletions.
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

0 comments on commit 8e9b510

Please sign in to comment.