From ac00ad9c4326961bfef9da2f60886eac7a313fef Mon Sep 17 00:00:00 2001 From: Allan Lasser Date: Tue, 16 Apr 2024 11:09:05 -0400 Subject: [PATCH 1/5] Limit Storybooks to SvelteKit --- .storybook/main.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.storybook/main.ts b/.storybook/main.ts index 1cacb8ced..bc22efbaa 100644 --- a/.storybook/main.ts +++ b/.storybook/main.ts @@ -4,7 +4,10 @@ const config: StorybookConfig = { core: { disableTelemetry: true, // 👈 Disables telemetry }, - stories: ["../src/**/*.stories.@(js|jsx|ts|tsx|svelte)"], + stories: [ + "../src/lib/**/*.stories.@(js|jsx|ts|tsx|svelte)", + "../src/routes/**/*.stories.@(js|jsx|ts|tsx|svelte)", + ], addons: [ "@storybook/addon-links", "@storybook/addon-essentials", From c8621a5e19ce8a022d6c80d67bb1dec68727565d Mon Sep 17 00:00:00 2001 From: Allan Lasser Date: Tue, 16 Apr 2024 11:11:56 -0400 Subject: [PATCH 2/5] Limit tests and coverage to Sveltekit directories --- vite.config.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/vite.config.js b/vite.config.js index 7eab898a8..bbf28cef2 100644 --- a/vite.config.js +++ b/vite.config.js @@ -37,16 +37,21 @@ export default defineConfig({ test: { setupFiles: ["./vitest-setup.js"], - include: ["src/**/*.{test,spec}.{js,ts}"], + include: [ + "src/lib/**/*.{test,spec}.{js,ts}", + "src/routes/**/*.{test,spec}.{js,ts}", + ], exclude: [ ...configDefaults.exclude, "storybook-static", + "node_modules", "./src/config/*", "../src/**/*.stories.@(js|jsx|ts|tsx|svelte)", ], environment: "jsdom", coverage: { - reporter: ["text", "html", "clover", "json"], + include: ["src/lib/**", "src/routes/**"], + reporter: ["text", "html", "lcov", "clover", "json", "json-summary"], }, }, }); From a462f828166d2ee6ec84f49481eb6b35b4df3dbb Mon Sep 17 00:00:00 2001 From: Allan Lasser Date: Tue, 16 Apr 2024 11:12:12 -0400 Subject: [PATCH 3/5] Create CI that runs specifically on SvelteKit PRs --- .github/workflows/sveltekit.yml | 46 +++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/sveltekit.yml diff --git a/.github/workflows/sveltekit.yml b/.github/workflows/sveltekit.yml new file mode 100644 index 000000000..88ba3b287 --- /dev/null +++ b/.github/workflows/sveltekit.yml @@ -0,0 +1,46 @@ +# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions + +# This runs CI specifically for development of the `sveltekit` branch. +# It uses our new testing infrastructure. + +name: SvelteKit CI + +on: + pull_request: + branches: [sveltekit] + +jobs: + + unit-test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Use Node.js 18.x + uses: actions/setup-node@v3 + with: + node-version: "18.x" + - run: npm ci + - run: npm run build + env: + NODE_ENV: production + - run: npm test:coverage + - name: Report Coverage + uses: davelosert/vitest-coverage-report-action@v2 + + check: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Use Node.js 18.x + uses: actions/setup-node@v3 + with: + node-version: "18.x" + - run: npm ci + - run: npm run build + env: + NODE_ENV: production + - run: npm run check + \ No newline at end of file From 384dab5da17772d4b662bc630a7354e8460725b8 Mon Sep 17 00:00:00 2001 From: Allan Lasser Date: Tue, 16 Apr 2024 11:28:16 -0400 Subject: [PATCH 4/5] Update check config to avoid checking non-sveltekit files --- .github/workflows/sveltekit.yml | 6 ++---- jsconfig.json | 19 +++++++++++++++++-- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/.github/workflows/sveltekit.yml b/.github/workflows/sveltekit.yml index 88ba3b287..ac061aefe 100644 --- a/.github/workflows/sveltekit.yml +++ b/.github/workflows/sveltekit.yml @@ -11,7 +11,6 @@ on: branches: [sveltekit] jobs: - unit-test: runs-on: ubuntu-latest @@ -25,10 +24,10 @@ jobs: - run: npm run build env: NODE_ENV: production - - run: npm test:coverage + - run: npm run test:coverage - name: Report Coverage uses: davelosert/vitest-coverage-report-action@v2 - + check: runs-on: ubuntu-latest @@ -43,4 +42,3 @@ jobs: env: NODE_ENV: production - run: npm run check - \ No newline at end of file diff --git a/jsconfig.json b/jsconfig.json index 404366663..97939e152 100644 --- a/jsconfig.json +++ b/jsconfig.json @@ -8,11 +8,26 @@ "resolveJsonModule": true, "skipLibCheck": true, "sourceMap": true, - "strict": true, + "strict": false, "moduleResolution": "bundler" - } + }, // Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias and https://kit.svelte.dev/docs/configuration#files // // If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes // from the referenced tsconfig.json - TypeScript does not merge them in + "include": [ + ".svelte-kit/**", + "vite.config.js", + "vite.config.ts", + "src/lib/**/*.js", + "src/lib/**/*.ts", + "src/lib/**/*.svelte", + "src/routes/**/*.js", + "src/routes/**/*.ts", + "src/routes/**/*.svelte", + "tests/**/*.js", + "tests/**/*.ts", + "tests/**/*.svelte" + ], + "exclude": ["node_modules/**", "public/**"] } From 4d358438b82da53be57cb8a2641d941f79ddd9b5 Mon Sep 17 00:00:00 2001 From: Allan Lasser Date: Tue, 16 Apr 2024 11:40:23 -0400 Subject: [PATCH 5/5] Fixing Chromatic build --- src/lib/api/fixtures/{mock.js => mock.ts} | 2 +- src/routes/stories/project-embed.stories.svelte | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename src/lib/api/fixtures/{mock.js => mock.ts} (96%) diff --git a/src/lib/api/fixtures/mock.js b/src/lib/api/fixtures/mock.ts similarity index 96% rename from src/lib/api/fixtures/mock.js rename to src/lib/api/fixtures/mock.ts index 56c4d61ab..c332be308 100644 --- a/src/lib/api/fixtures/mock.js +++ b/src/lib/api/fixtures/mock.ts @@ -1,6 +1,6 @@ import { rest } from "msw"; -import meFixture from "../fixtures/users/me.json"; +import { me as meFixture } from "@/test/fixtures/accounts"; import projectFixture from "../fixtures/projects/project.json"; import projDocsPage1 from "../fixtures/projects/project-documents-expanded.json"; import projDocsPage2 from "../fixtures/projects/project-documents-2.json"; diff --git a/src/routes/stories/project-embed.stories.svelte b/src/routes/stories/project-embed.stories.svelte index 557c4a886..9da2da7b0 100644 --- a/src/routes/stories/project-embed.stories.svelte +++ b/src/routes/stories/project-embed.stories.svelte @@ -8,7 +8,7 @@ import documents from "$lib/api/fixtures/projects/project-documents-expanded.json"; import project from "$lib/api/fixtures/projects/project.json"; - import * as mock from "$lib/api/fixtures/mock.js"; + import * as mock from "$lib/api/fixtures/mock"; export const meta = { title: "Embed / Project",