Skip to content

Commit

Permalink
test: merge configs
Browse files Browse the repository at this point in the history
  • Loading branch information
zirkelc committed Jul 21, 2024
1 parent 8aeb280 commit 2191947
Show file tree
Hide file tree
Showing 12 changed files with 108 additions and 54 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,6 @@ jobs:

- name: Coverage
if: ${{ steps.install.conclusion == 'success' }}
uses: davelosert/vitest-coverage-report-action@v2
uses: davelosert/vitest-coverage-report-action@v2
with:
vite-config-path: vitest.root.ts
13 changes: 4 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,9 @@
"scripts": {
"build": "turbo build",
"test": "vitest run",
"test:ci": "vitest run --coverage.enabled --coverage.provider=v8 --coverage.reporter=json-summary --coverage.reporter=json --coverage.all",
"test:unit": "vitest run --project unit",
"test:e2e": "vitest run --project e2e",
"test:unit:cov": "vitest run --project unit --coverage.enabled --coverage.reporter=v8 --coverage.all",
"test:e2e:cov": "vitest run --project e2e --coverage.enabled --coverage.reporter=v8 --coverage.all",
"test:ci": "vitest --coverage.enabled",
"lint": "biome check . --write --no-errors-on-unmatched",
"prepare": "husky",
"release:patch": "pnpm -r release:patch",
"release:alpha": "pnpm -r release:alpha"
"prepare": "husky"
},
"keywords": [],
"author": "",
Expand All @@ -54,7 +48,8 @@
"tsx": "^4.16.2",
"turbo": "^2.0.9",
"typescript": "^5.5.3",
"vitest": "^2.0.3"
"vitest": "^2.0.3",
"vitest-github-actions-reporter": "^0.11.1"
},
"lint-staged": {
"*.{ts,json}": ["biome check --write --no-errors-on-unmatched"]
Expand Down
14 changes: 1 addition & 13 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
"module": "./src/index.ts",
"exports": {
".": {
"require": {
"types": "./src/index.ts",
"default": "./src/index.ts"
},
"import": {
"types": "./src/index.ts",
"default": "./src/index.ts"
Expand All @@ -24,10 +20,6 @@
"module": "./dist/index.cjs",
"exports": {
".": {
"require": {
"types": "./dist/index.d.cts",
"default": "./dist/index.cjs"
},
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
Expand All @@ -37,11 +29,7 @@
},
"scripts": {
"test": "vitest",
"build": "tsc --noEmit",
"bundle": "tsup ./src/index.ts --format cjs,esm --dts --clean",
"prepublishOnly": "pnpm run build && pnpm run bundle",
"release:patch": "pnpm version patch && pnpm publish --no-git-checks",
"release:alpha": "pnpm version prerelease --preid alpha && pnpm publish --tag alpha --no-git-checks"
"build": "tsup ./src/index.ts --format esm --dts --clean"
},
"keywords": [],
"author": "",
Expand Down
4 changes: 4 additions & 0 deletions packages/core/vitest.configt.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { defineProject, mergeConfig } from "vitest/config";
import configShared from "../../vitest.root.js";

export default mergeConfig(configShared, defineProject({}));
7 changes: 1 addition & 6 deletions packages/store-s3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,7 @@
},
"scripts": {
"build": "tsup src/index.ts --format esm --dts --clean",
"test": "vitest --root ../..",
"test:unit": "vitest --project unit --root ../..",
"test:e2e": "vitest --project e2e --root ../..",
"prepublishOnly": "pnpm run build && pnpm run bundle",
"release:patch": "pnpm version patch && pnpm publish --no-git-checks",
"release:alpha": "pnpm version prerelease --preid alpha && pnpm publish --tag alpha --no-git-checks"
"test": "vitest"
},
"keywords": [],
"author": "",
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
type S3Reference,
type S3ReferenceFormat,
S3Store,
} from "./store.js";
} from "../src/store.js";

const bucket = "bucket";
const key = "key";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, test } from "vitest";
import { STORE_NAME } from "./store.js";
import { STORE_NAME } from "../src/store.js";
import {
formatS3ObjectArn,
formatS3Reference,
Expand All @@ -10,7 +10,7 @@ import {
parseS3ObjectArn,
parseS3Reference,
uuidKey,
} from "./utils.js";
} from "../src/utils.js";

const nonStringValues = [null, undefined, "", 42, true, false, {}];

Expand Down
4 changes: 4 additions & 0 deletions packages/store-s3/vitest.configt.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { defineProject, mergeConfig } from "vitest/config";
import configShared from "../../vitest.root.js";

export default mergeConfig(configShared, defineProject({}));
50 changes: 50 additions & 0 deletions pnpm-lock.yaml

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

34 changes: 34 additions & 0 deletions vitest.root.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import GithubActionsReporter from "vitest-github-actions-reporter";
import { defineConfig } from "vitest/config";

// load region from config to prevent error "ConfigError: Missing region in config"
// https://github.com/aws/aws-sdk-js/pull/1391
process.env.AWS_SDK_LOAD_CONFIG = "1";

export default defineConfig({
test: {
// https://github.com/sapphi-red/vitest-github-actions-reporter
reporters: process.env.GITHUB_ACTIONS
? ["default", new GithubActionsReporter()]
: "default",

// https://vitest.dev/config/#typecheck
typecheck: {
enabled: true,
ignoreSourceErrors: false,
},

// https://vitest.dev/guide/coverage.html
coverage: {
provider: "v8",
// json-summary is required for https://github.com/davelosert/vitest-coverage-report-action
reporter: ["json-summary", "json", "text-summary"],
thresholds: {
lines: 80,
statements: 80,
functions: 80,
branches: 80,
},
},
},
});
26 changes: 4 additions & 22 deletions vitest.workspace.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,4 @@
import { configDefaults, defineWorkspace } from "vitest/config";

export default defineWorkspace([
{
test: {
name: "unit",
include: ["**/*.{test,spec}.?(c|m)[jt]s?(x)"],
exclude: [...configDefaults.exclude, "**/tests/**"],

// https://vitest.dev/config/#typecheck
typecheck: {
enabled: true,
},
},
},
{
test: {
name: "e2e",
include: ["**/tests/*.{test,spec}.?(c|m)[jt]s?(x)"],
},
},
]);
/**
* @see https://vitest.dev/guide/workspace.html
*/
export default ["packages/*"];

0 comments on commit 2191947

Please sign in to comment.