Skip to content

Commit

Permalink
ci: run type tests against various TypeScript version (#278)
Browse files Browse the repository at this point in the history
  • Loading branch information
lihbr committed Jan 24, 2023
1 parent d94a9e8 commit c11e4ec
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 16 deletions.
102 changes: 88 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
name: ci

on:
push:
branches:
- master
pull_request:
branches:
- master
on: push

jobs:
ci:
prepare:
name: Prepare (${{ matrix.os}}, Node ${{ matrix.node }})
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest]
node: [14]
node: [14, 16, 18]

steps:
- name: Set up Node
Expand All @@ -27,7 +21,8 @@ jobs:
uses: actions/checkout@master

- name: Cache node_modules
uses: actions/cache@v2
id: cache
uses: actions/cache@v3
with:
path: node_modules
key: ${{ matrix.os }}-node-v${{ matrix.node }}-deps-${{ hashFiles(format('{0}{1}', github.workspace, '/package-lock.json')) }}
Expand All @@ -36,12 +31,34 @@ jobs:
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci

suite:
needs: prepare
name: Suite (${{ matrix.os}}, Node ${{ matrix.node }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
node: [14, 16, 18]

steps:
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}

- name: Checkout
uses: actions/checkout@master

- name: Retrieve node_modules
uses: actions/cache@v3
with:
path: node_modules
key: ${{ matrix.os }}-node-v${{ matrix.node }}-deps-${{ hashFiles(format('{0}{1}', github.workspace, '/package-lock.json')) }}

- name: Lint
run: npm run lint

- name: Types
run: npm run types

- name: Unit
run: npm run unit

Expand All @@ -52,6 +69,63 @@ jobs:
if: matrix.os == 'ubuntu-latest' && matrix.node == 14
uses: codecov/codecov-action@v3

types:
needs: prepare
name: Types (${{ matrix.os}}, Node ${{ matrix.node }}, TS ${{ matrix.typescript }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
node: [14]
typescript: ['4.5', '4.6', '4.7', '4.8', '4.9']

steps:
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}

- name: Checkout
uses: actions/checkout@master

- name: Retrieve node_modules
uses: actions/cache@v3
with:
path: node_modules
key: ${{ matrix.os }}-node-v${{ matrix.node }}-deps-${{ hashFiles(format('{0}{1}', github.workspace, '/package-lock.json')) }}

- name: Overwrite TypeScript
run: npm install --no-save typescript@${{ matrix.typescript }} && npx tsc --version

- name: Types
run: npm run types

size:
needs: prepare
name: Size (${{ matrix.os}}, Node ${{ matrix.node }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
node: [14]

steps:
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}

- name: Checkout
uses: actions/checkout@master

- name: Retrieve node_modules
uses: actions/cache@v3
with:
path: node_modules
key: ${{ matrix.os }}-node-v${{ matrix.node }}-deps-${{ hashFiles(format('{0}{1}', github.workspace, '/package-lock.json')) }}

- name: Size
if: github.event_name == 'pull_request' && matrix.os == 'ubuntu-latest' && matrix.node == 14
uses: andresz1/size-limit-action@v1
Expand Down
3 changes: 2 additions & 1 deletion src/helpers/asLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ export const asLink = <
const linkField =
// prettier-ignore
(
// @ts-expect-error - Bug in TypeScript 4.9: https://github.com/microsoft/TypeScript/issues/51501
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore - Bug in TypeScript 4.9: https://github.com/microsoft/TypeScript/issues/51501
// TODO: Remove the `prettier-ignore` comment when this bug is fixed.
"link_type" in linkFieldOrDocument
? linkFieldOrDocument
Expand Down
2 changes: 1 addition & 1 deletion test/__testutils__/testAnyGetMethod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const testAnyGetMethodFactory = (
break;

default:
throw new Error("Unknown mode `%o`", mode);
throw new Error(`Unknown mode \`${mode}\``);
}
});
};
Expand Down

0 comments on commit c11e4ec

Please sign in to comment.