Skip to content

Commit

Permalink
ci(ci): add codspeed (#936)
Browse files Browse the repository at this point in the history
# Overview

<!--
    A clear and concise description of what this pr is about.
 -->

I add [codspeed](https://codspeed.io/) to track performance suggested by
@juno7803

## PR Checklist

- [x] I did below actions if need

1. I read the [Contributing
Guide](https://github.com/toss/suspensive/blob/main/CONTRIBUTING.md)
2. I added documents and tests.

---------

Co-authored-by: Jun <[email protected]>
  • Loading branch information
manudeli and juno7803 authored Jun 17, 2024
1 parent 592fda1 commit 34bc47b
Show file tree
Hide file tree
Showing 14 changed files with 88 additions and 27 deletions.
13 changes: 9 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@ graph/

# test
tsconfig.vitest-temp.json

# benchmark
benchmark/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
6 changes: 6 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion configs/tsup/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions packages/react-await/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:*",
Expand Down
6 changes: 3 additions & 3 deletions packages/react-image/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:*",
Expand Down
6 changes: 3 additions & 3 deletions packages/react-query/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:*",
Expand Down
7 changes: 4 additions & 3 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:*",
Expand Down
9 changes: 9 additions & 0 deletions packages/react/src/ErrorBoundary.bench.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { render } from '@testing-library/react'
import { bench } from 'vitest'
import { ErrorBoundary } from './ErrorBoundary'

describe('ErrorBoundary', () => {
bench('@suspensive/react', () => {
render(<ErrorBoundary fallback={() => <></>}></ErrorBoundary>)
})
})
2 changes: 2 additions & 0 deletions packages/react/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
35 changes: 32 additions & 3 deletions pnpm-lock.yaml

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

8 changes: 6 additions & 2 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/**"]
Expand Down

0 comments on commit 34bc47b

Please sign in to comment.