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

ci: run type tests against various TypeScript version #278

Merged
merged 10 commits into from
Jan 24, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
lihbr marked this conversation as resolved.
Show resolved Hide resolved

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