Skip to content

Commit

Permalink
Add type checking job to the CI workflow (#1827)
Browse files Browse the repository at this point in the history
Co-authored-by: Chris Swithinbank <[email protected]>
  • Loading branch information
HiDeoo and delucis authored May 3, 2024
1 parent dcdc25a commit 95ace6d
Show file tree
Hide file tree
Showing 11 changed files with 61 additions and 22 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,23 @@ jobs:
- name: Test packages
run: pnpm -r test:e2e

type-check:
name: Run type checks
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'pnpm'
- run: pnpm i
- name: Generate docs types
working-directory: docs
run: pnpm astro sync
- name: Type check packages
run: pnpm typecheck

pa11y:
name: Check for accessibility issues
runs-on: ubuntu-20.04
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"build:examples": "pnpm --no-bail --workspace-concurrency 1 --filter '@example/*' build",
"size": "size-limit",
"version": "pnpm changeset version && pnpm i --no-frozen-lockfile",
"format": "prettier -w --cache --plugin prettier-plugin-astro ."
"format": "prettier -w --cache --plugin prettier-plugin-astro .",
"typecheck": "tsc -p tsconfig.typecheck.json"
},
"license": "MIT",
"devDependencies": {
Expand All @@ -17,6 +18,7 @@
"astro": "^4.3.5",
"prettier": "^3.0.0",
"prettier-plugin-astro": "^0.13.0",
"typescript": "^5.4.5",
"size-limit": "^8.2.4"
},
"packageManager": "[email protected]",
Expand Down
1 change: 1 addition & 0 deletions packages/starlight/__tests__/basics/route-data.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ vi.mock('astro:content', async () =>
docs: [
['index.mdx', { title: 'Home Page' }],
['getting-started.mdx', { title: 'Splash', template: 'splash' }],
// @ts-expect-error — Using a slug not present in Starlight docs site
['showcase.mdx', { title: 'ToC Disabled', tableOfContents: false }],
['environmental-impact.md', { title: 'Explicit update date', lastUpdated: new Date() }],
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assert, expect, test, vi } from 'vitest';
import { expect, test, vi } from 'vitest';
import {
generateStarlightPageRouteData,
type StarlightPageProps,
Expand Down
1 change: 1 addition & 0 deletions packages/starlight/__tests__/edit-url/edit-url.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ vi.mock('astro:content', async () =>
['index.mdx', { title: 'Home Page' }],
['getting-started.mdx', { title: 'Getting Started' }],
[
// @ts-expect-error — Using a slug not present in Starlight docs site
'showcase.mdx',
{ title: 'Custom edit link', editUrl: 'https://example.com/custom-edit?link' },
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ vi.mock('astro:content', async () =>
(await import('../test-utils')).mockedAstroContent({
docs: [
['fr/index.mdx', { title: 'Accueil' }],
// @ts-expect-error — Using a slug not present in Starlight docs site
['en/index.mdx', { title: 'Home page' }],
],
})
Expand Down
1 change: 1 addition & 0 deletions packages/starlight/utils/createPathFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ function formatPath(
href: string,
{ format = 'directory', trailingSlash = 'ignore' }: FormatPathOptions
) {
// @ts-expect-error — TODO: add support for `preserve` (https://github.com/withastro/starlight/issues/1781)
const formatStrategy = formatStrategies[format];
const trailingSlashStrategy = trailingSlashStrategies[trailingSlash];

Expand Down
2 changes: 1 addition & 1 deletion packages/starlight/utils/user-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ export const StarlightConfigSchema = UserConfigSchema.strict().transform(
const defaultLocaleConfig = {
label: 'English',
lang: 'en',
dir: 'ltr',
dir: 'ltr' as const,
locale: undefined,
...locales?.root,
};
Expand Down
12 changes: 7 additions & 5 deletions packages/tailwind/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ export default defineConfig({
test: {
coverage: {
reportsDirectory: './__coverage__',
thresholdAutoUpdate: true,
lines: 100,
functions: 100,
branches: 100,
statements: 100,
thresholds: {
autoUpdate: true,
lines: 94,
functions: 100,
branches: 85,
statements: 94,
},
},
},
});
38 changes: 24 additions & 14 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions tsconfig.typecheck.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "./tsconfig.json",
"exclude": ["**/dist/**", "**/__coverage__/**", "packages/starlight/components.ts"]
}

0 comments on commit 95ace6d

Please sign in to comment.