diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6b32dce42..9202d703b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ on: env: TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} TURBO_TEAM: ${{ vars.TURBO_TEAM }} - NEXT_PUBLIC_STREAMING_HTML_URL: ${{ vars.NEXT_PUBLIC_STREAMING_HTML_URL }} + CI: ${{ vars.CI }} concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true @@ -19,17 +19,22 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - command: ['ci:attw', 'ci:eslint', 'ci:publint', 'ci:sherif', 'ci:type', 'test', 'build'] + command: ['ci:attw', 'ci:eslint', 'ci:publint', 'ci:sherif', 'ci:type', 'ci:test', 'ci:bench', 'build'] steps: - uses: actions/checkout@v4 - uses: ./.github/actions/pnpm-setup-node - run: pnpm install --frozen-lockfile - - if: matrix.command == 'test' + - if: matrix.command == 'ci:test' run: pnpm playwright install - run: pnpm ${{ matrix.command }} env: LHCI_GITHUB_APP_TOKEN: ${{ secrets.LHCI_GITHUB_APP_TOKEN }} - - if: matrix.command == 'test' + - if: matrix.command == 'ci:test' uses: codecov/codecov-action@v4 env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + - if: matrix.command == 'ci:bench' + uses: CodSpeedHQ/action@v2 + with: + run: pnpm ci:bench + token: ${{ secrets.CODSPEED_TOKEN }} diff --git a/.gitignore b/.gitignore index 8e5048de6..571bf5ade 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,6 @@ graph/ # test tsconfig.vitest-temp.json + +# benchmark +benchmark/ diff --git a/README.md b/README.md index 122711ac0..3cafbcae6 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ [![@suspensive/react downloads](https://img.shields.io/npm/dt/@suspensive/react.svg?label=@suspensive/react&color=000&labelColor=000&style=for-the-badge)](https://www.npmjs.com/package/@suspensive/react) [![@suspensive/react-query downloads](https://img.shields.io/npm/dt/@suspensive/react-query.svg?label=@suspensive/react-query&color=000&labelColor=000&style=for-the-badge)](https://www.npmjs.com/package/@suspensive/react-query) -[![codecov](https://codecov.io/gh/toss/suspensive/graph/badge.svg?token=5PopssACmx)](https://codecov.io/gh/toss/suspensive) ![GitHub stars](https://img.shields.io/github/stars/toss/suspensive?style=social) ![GitHub forks](https://img.shields.io/github/forks/toss/suspensive?style=social) +[![codecov](https://codecov.io/gh/toss/suspensive/graph/badge.svg?token=5PopssACmx)](https://codecov.io/gh/toss/suspensive) [![CodSpeed Badge](https://img.shields.io/endpoint?url=https://codspeed.io/badge.json)](https://codspeed.io/toss/suspensive) ![GitHub stars](https://img.shields.io/github/stars/toss/suspensive?style=social) ![GitHub forks](https://img.shields.io/github/forks/toss/suspensive?style=social) [OFFICIAL DOCS](https://suspensive.org) | [VISUALIZATION](https://visualization.suspensive.org) | [DEPENDENCY GRAPH](https://graph.suspensive.org) diff --git a/codecov.yml b/codecov.yml index ab219539c..27a1abd00 100644 --- a/codecov.yml +++ b/codecov.yml @@ -8,9 +8,15 @@ coverage: comment: layout: 'header, reach, diff, flags, components' + behavior: default + require_changes: false + require_base: false + require_head: true + hide_project_coverage: false ignore: - '**/*.test-d.*' + - '**/*.bench.*' component_management: individual_components: diff --git a/configs/tsup/src/index.ts b/configs/tsup/src/index.ts index 1e6159fbe..b8e92f4ce 100644 --- a/configs/tsup/src/index.ts +++ b/configs/tsup/src/index.ts @@ -4,7 +4,7 @@ export const options: Options = { banner: { js: '"use client"' }, format: ['cjs', 'esm'], target: ['chrome51', 'firefox53', 'edge18', 'safari11', 'ios11', 'opera38', 'es6', 'node14'], - entry: ['src/*.{ts,tsx}', '!**/*.{spec,test,test-d}.*'], + entry: ['src/*.{ts,tsx}', '!**/*.{spec,test,test-d,bench}.*'], sourcemap: true, dts: true, } diff --git a/package.json b/package.json index ba8d50c26..61c0a352a 100644 --- a/package.json +++ b/package.json @@ -22,11 +22,14 @@ "changeset": "changeset", "changeset:publish": "pnpm prepack && changeset publish", "changeset:version": "changeset version && pnpm i --lockfile-only", - "ci:all": "pnpm ci:attw && pnpm ci:eslint && pnpm ci:publint && pnpm ci:sherif && pnpm ci:type && pnpm test && pnpm build", + "ci:all": "pnpm ci:attw && pnpm ci:eslint && pnpm ci:publint && pnpm ci:sherif && pnpm ci:type && pnpm ci:test && pnpm ci:bench && pnpm build", "ci:attw": "turbo run ci:attw", + "ci:bench": "turbo run ci:bench", "ci:eslint": "turbo run ci:eslint", "ci:publint": "turbo run ci:publint", "ci:sherif": "sherif --ignore-package \"./examples/*\" --ignore-package \"./websites/*\" --ignore-package \"./docs/*\"", + "ci:test": "turbo run ci:test", + "ci:test:watch": "turbo run test:watch --parallel", "ci:type": "turbo run ci:type", "clean": "turbo run clean", "dev": "turbo run dev", @@ -36,14 +39,13 @@ "preinstall": "corepack enable", "prepack": "turbo run prepack", "prepare": "husky", - "start": "turbo run start", - "test": "turbo run test", - "test:watch": "turbo run test:watch --parallel" + "start": "turbo run start" }, "devDependencies": { "@arethetypeswrong/cli": "^0.15.3", "@changesets/changelog-github": "^0.5.0", "@changesets/cli": "^2.27.5", + "@codspeed/vitest-plugin": "^3.1.0", "@commitlint/cli": "^19.3.0", "@commitlint/config-conventional": "^19.2.2", "@testing-library/dom": "^10.1.0", diff --git a/packages/react-await/package.json b/packages/react-await/package.json index 1e199a175..27183b6b4 100644 --- a/packages/react-await/package.json +++ b/packages/react-await/package.json @@ -45,12 +45,12 @@ "ci:attw": "attw --pack", "ci:eslint": "eslint \"**/*.{js,jsx,cjs,mjs,ts,tsx,cts,mts}\"", "ci:publint": "publint --strict", + "ci:test": "vitest run --coverage --typecheck", + "ci:test:watch": "vitest --ui --coverage --typecheck", "ci:type": "tsc --noEmit", "clean": "rimraf ./dist && rimraf ./coverage", "dev": "tsup --watch", - "prepack": "pnpm build", - "test": "vitest run --coverage --typecheck", - "test:watch": "vitest --ui --coverage --typecheck" + "prepack": "pnpm build" }, "devDependencies": { "@suspensive/eslint-config": "workspace:*", diff --git a/packages/react-image/package.json b/packages/react-image/package.json index d1eadd44d..6f4f0ea52 100644 --- a/packages/react-image/package.json +++ b/packages/react-image/package.json @@ -45,12 +45,12 @@ "ci:attw": "attw --pack", "ci:eslint": "eslint \"**/*.{js,jsx,cjs,mjs,ts,tsx,cts,mts}\"", "ci:publint": "publint --strict", + "ci:test": "vitest run --coverage --typecheck", + "ci:test:watch": "vitest --ui --coverage --typecheck", "ci:type": "tsc --noEmit", "clean": "rimraf ./dist && rimraf ./coverage", "dev": "tsup --watch", - "prepack": "pnpm build", - "test": "vitest run --coverage --typecheck", - "test:watch": "vitest --ui --coverage --typecheck" + "prepack": "pnpm build" }, "devDependencies": { "@suspensive/eslint-config": "workspace:*", diff --git a/packages/react-query/package.json b/packages/react-query/package.json index 3e716adfb..3f6083eb1 100644 --- a/packages/react-query/package.json +++ b/packages/react-query/package.json @@ -46,12 +46,12 @@ "ci:attw": "attw --pack", "ci:eslint": "eslint \"**/*.{js,jsx,cjs,mjs,ts,tsx,cts,mts}\"", "ci:publint": "publint --strict", + "ci:test": "vitest run --coverage --typecheck", + "ci:test:watch": "vitest --ui --coverage --typecheck", "ci:type": "tsc --noEmit", "clean": "rimraf ./dist && rimraf ./coverage", "dev": "tsup --watch", - "prepack": "pnpm build", - "test": "vitest run --coverage --typecheck", - "test:watch": "vitest --ui --coverage --typecheck" + "prepack": "pnpm build" }, "devDependencies": { "@suspensive/eslint-config": "workspace:*", diff --git a/packages/react/package.json b/packages/react/package.json index b86ef1483..4a46fb151 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -43,14 +43,15 @@ "scripts": { "build": "tsup", "ci:attw": "attw --pack", + "ci:bench": "vitest bench --run --outputJson benchmark/index.json", "ci:eslint": "eslint \"**/*.{js,jsx,cjs,mjs,ts,tsx,cts,mts}\"", "ci:publint": "publint --strict", + "ci:test": "vitest run --coverage --typecheck", + "ci:test:watch": "vitest --ui --coverage --typecheck", "ci:type": "tsc --noEmit", "clean": "rimraf ./dist && rimraf ./coverage", "dev": "tsup --watch", - "prepack": "pnpm build", - "test": "vitest run --coverage --typecheck", - "test:watch": "vitest --ui --coverage --typecheck" + "prepack": "pnpm build" }, "devDependencies": { "@suspensive/eslint-config": "workspace:*", diff --git a/packages/react/src/ErrorBoundary.bench.tsx b/packages/react/src/ErrorBoundary.bench.tsx new file mode 100644 index 000000000..fa161cc15 --- /dev/null +++ b/packages/react/src/ErrorBoundary.bench.tsx @@ -0,0 +1,9 @@ +import { render } from '@testing-library/react' +import { bench } from 'vitest' +import { ErrorBoundary } from './ErrorBoundary' + +describe('ErrorBoundary', () => { + bench('@suspensive/react', () => { + render( <>}>) + }) +}) diff --git a/packages/react/vitest.config.ts b/packages/react/vitest.config.ts index 987291b5c..b5ab29c7a 100644 --- a/packages/react/vitest.config.ts +++ b/packages/react/vitest.config.ts @@ -1,7 +1,9 @@ +import codspeedPlugin from '@codspeed/vitest-plugin' import { defineConfig } from 'vitest/config' import packageJson from './package.json' export default defineConfig({ + plugins: process.env.CI === 'true' ? [codspeedPlugin()] : [], test: { name: packageJson.name, dir: './src', diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0a166e8fb..6873c2a29 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -17,6 +17,9 @@ importers: '@changesets/cli': specifier: ^2.27.5 version: 2.27.5 + '@codspeed/vitest-plugin': + specifier: ^3.1.0 + version: 3.1.0(vite@5.3.0)(vitest@1.6.0) '@commitlint/cli': specifier: ^19.3.0 version: 19.3.0(@types/node@18.19.34)(typescript@5.4.5) @@ -1137,6 +1140,30 @@ packages: - encoding dev: true + /@codspeed/core@3.1.0: + resolution: {integrity: sha512-oYd7X46QhnRkgRbZkqAoX9i3Fwm17FpunK4Ee5RdrvRYR0Xr93ewH8/O5g6uyTPDOOqDEv1v2KRYtWhVgN+2VQ==} + dependencies: + axios: 1.6.8 + find-up: 6.3.0 + form-data: 4.0.0 + node-gyp-build: 4.8.1 + transitivePeerDependencies: + - debug + dev: true + + /@codspeed/vitest-plugin@3.1.0(vite@5.3.0)(vitest@1.6.0): + resolution: {integrity: sha512-ms11tUytiQTgB+idxZRUuCUQfgz4LaKTDJCLYm5VTSpOCUU7D5+QWvJnA8X8B9glPfR5siIK8RxrnZP4yuysKQ==} + peerDependencies: + vite: ^4.2.0 || ^5.0.0 + vitest: '>=1.2.2' + dependencies: + '@codspeed/core': 3.1.0 + vite: 5.3.0(@types/node@18.19.34) + vitest: 1.6.0(@types/node@18.19.34)(@vitest/browser@1.6.0)(@vitest/ui@1.6.0)(jsdom@24.1.0) + transitivePeerDependencies: + - debug + dev: true + /@colors/colors@1.5.0: resolution: {integrity: sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ==} engines: {node: '>=0.1.90'} @@ -3323,7 +3350,6 @@ packages: proxy-from-env: 1.1.0 transitivePeerDependencies: - debug - dev: false /bail@2.0.2: resolution: {integrity: sha512-0xO6mYd7JB2YesxDKplafRpsiOzPt9V02ddPCLbY1xYGPOX24NTyN50qnUxgCPcSoYMhKpAuBTjQoRZCAkUDRw==} @@ -5597,7 +5623,6 @@ packages: peerDependenciesMeta: debug: optional: true - dev: false /for-each@0.3.3: resolution: {integrity: sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==} @@ -8165,6 +8190,11 @@ packages: whatwg-url: 5.0.0 dev: true + /node-gyp-build@4.8.1: + resolution: {integrity: sha512-OSs33Z9yWr148JZcbZd5WiAXhh/n9z8TxQcdMhIOlpN9AhWpLfvVFO73+m77bBABQMaY9XSvIa+qk0jlI7Gcaw==} + hasBin: true + dev: true + /node-releases@2.0.14: resolution: {integrity: sha512-y10wOWt8yZpqXmOgRo77WaHEmhYQYGNA6y421PKsKYWEK8aW+cqAphborZDhqfyKrbZEN92CN1X2KbafY2s7Yw==} @@ -8880,7 +8910,6 @@ packages: /proxy-from-env@1.1.0: resolution: {integrity: sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==} - dev: false /prr@1.0.1: resolution: {integrity: sha512-yPw4Sng1gWghHQWj0B3ZggWUm4qVbPwPFcRG8KyxiU7J2OHFSoEHKS+EZ3fv5l1t9CyCiop6l/ZYeWbrgoQejw==} diff --git a/turbo.json b/turbo.json index 0f87ca7e5..e44e29cac 100644 --- a/turbo.json +++ b/turbo.json @@ -20,15 +20,19 @@ "clean": { "cache": false }, - "test": { + "ci:test": { "dependsOn": ["prepack"], "outputs": ["coverage/**"] }, - "test:watch": { + "ci:test:watch": { "dependsOn": ["prepack"], "cache": false, "outputs": ["coverage/**"] }, + "ci:bench": { + "dependsOn": ["prepack"], + "outputs": ["benchmark/**"] + }, "prepack": { "dependsOn": ["^prepack"], "outputs": ["dist/**"]