Skip to content

Commit c538a2e

Browse files
authored
Merge pull request #40 from saku-1101/9-todoパフォーマンス計測
CodSpeed Performance Analysis
2 parents 6ac7a2e + 79ab0ce commit c538a2e

22 files changed

+13168
-85
lines changed

.github/workflows/benchmark.yml

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Codspeed Benchmarks
2+
3+
on:
4+
push:
5+
branches:
6+
- "main"
7+
pull_request:
8+
# `workflow_dispatch` allows CodSpeed to trigger backtest
9+
# performance analysis in order to generate initial data.
10+
workflow_dispatch:
11+
12+
13+
jobs:
14+
install-dependencies:
15+
runs-on: ubuntu-latest
16+
env:
17+
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
18+
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
19+
steps:
20+
- name: Checkout Commit
21+
uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 2
24+
- name: Setup Bun
25+
uses: oven-sh/setup-bun@v1
26+
with:
27+
bun-version: latest
28+
- name: Install dependencies
29+
run: bun install
30+
- name: Cache bun dependencies
31+
uses: actions/cache@v3
32+
id: bun-cache
33+
with:
34+
path: node_modules
35+
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }}
36+
restore-keys: ${{ runner.os }}-bun
37+
38+
benchmarks:
39+
needs: install-dependencies
40+
runs-on: ubuntu-latest
41+
steps:
42+
- name: Checkout Commit
43+
uses: actions/checkout@v4
44+
with:
45+
fetch-depth: 2
46+
47+
- name: Setup Bun
48+
uses: oven-sh/setup-bun@v1
49+
with:
50+
bun-version: latest
51+
52+
- name: Add vitest
53+
run: bun add @codspeed/vitest-plugin vitest
54+
55+
- name: Run benchmarks
56+
uses: CodSpeedHQ/action@v2
57+
with:
58+
run: bun bench
59+
token: ${{ secrets.CODSPEED_TOKEN }}

.github/workflows/check.yml

+3-8
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,22 @@ name: 'Check'
33
on: [push]
44

55
jobs:
6-
# Install and cache npm dependencies
76
install-dependencies:
87
runs-on: ubuntu-latest
8+
env:
9+
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
10+
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
911
steps:
1012
- name: Checkout Commit
1113
uses: actions/checkout@v4
1214
with:
1315
fetch-depth: 2
14-
1516
- name: Setup Bun
1617
uses: oven-sh/setup-bun@v1
1718
with:
1819
bun-version: latest
19-
2020
- name: Install dependencies
2121
run: bun install
22-
2322
- name: Cache bun dependencies
2423
uses: actions/cache@v3
2524
id: bun-cache
@@ -28,10 +27,6 @@ jobs:
2827
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }}
2928
restore-keys: ${{ runner.os }}-bun
3029

31-
- name: Install dependencies if cache invalid
32-
if: steps.bun-cache.outputs.cache-hit != 'true'
33-
run: bun i --frozen-lockfile
34-
3530
# This job is for checking the code style, type and lint errors.
3631
check-all:
3732
needs: install-dependencies

.github/workflows/lighthouse.yml

+2-10
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,31 @@
11
name: Lighthouse
22
on: [push]
3+
34
jobs:
4-
# Install and cache npm dependencies
55
install-dependencies:
66
runs-on: ubuntu-latest
77
env:
88
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
99
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
10-
1110
steps:
1211
- name: Checkout Commit
1312
uses: actions/checkout@v4
1413
with:
1514
fetch-depth: 2
16-
1715
- name: Setup Bun
1816
uses: oven-sh/setup-bun@v1
1917
with:
2018
bun-version: latest
21-
2219
- name: Install dependencies
2320
run: bun install
24-
2521
- name: Cache bun dependencies
2622
uses: actions/cache@v3
2723
id: bun-cache
2824
with:
2925
path: node_modules
3026
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }}
3127
restore-keys: ${{ runner.os }}-bun
32-
33-
- name: Install dependencies if cache invalid
34-
if: steps.bun-cache.outputs.cache-hit != 'true'
35-
run: bun i --frozen-lockfile
36-
28+
3729
lighthouseci:
3830
needs: install-dependencies
3931
runs-on: ubuntu-latest

.github/workflows/storybook.yml

+7-12
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,27 @@ jobs:
66
release:
77
name: Storybook Build
88
runs-on: ubuntu-latest
9-
9+
env:
10+
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
11+
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
1012
steps:
1113
- name: Checkout Commit
1214
uses: actions/checkout@v4
1315
with:
1416
fetch-depth: 2
15-
1617
- name: Setup Bun
1718
uses: oven-sh/setup-bun@v1
1819
with:
19-
bun-version: latest
20-
20+
bun-version: latest
2121
- name: Install dependencies
2222
run: bun install
23-
2423
- name: Cache bun dependencies
2524
uses: actions/cache@v3
2625
id: bun-cache
2726
with:
28-
path: node_modules
29-
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }}
30-
restore-keys: ${{ runner.os }}-bun
31-
32-
- name: Install dependencies if cache invalid
33-
if: steps.bun-cache.outputs.cache-hit != 'true'
34-
run: bun i --frozen-lockfile
27+
path: node_modules
28+
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }}
29+
restore-keys: ${{ runner.os }}-bun
3530

3631
- name: Build storybook of @repo/ui
3732
run: bun run build:storybook
File renamed without changes.

apps/blog/next.config.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import headers from "./config/headers.js";
1+
import headers from "./config/headers.cjs";
22

33
/** @type {import('next').NextConfig} */
44
const nextConfig = {

apps/blog/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "blog",
33
"version": "1.0.0",
44
"private": true,
5+
"type": "module",
56
"scripts": {
67
"dev": "next dev",
78
"build": "next build",
@@ -45,7 +46,7 @@
4546
"remark-collapse": "^0.1.2",
4647
"remark-directive": "^3.0.0",
4748
"remark-gfm": "^4.0.0",
48-
"remark-link-card": "git+https://github.com/saku-1101/remark-link-card.git",
49+
"remark-link-card": "^1.3.1",
4950
"remark-rehype": "^11.1.0",
5051
"remark-toc": "^9.0.0",
5152
"rss": "^1.2.2",
File renamed without changes.

apps/blog/tests/fibo.bench.ts

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { bench, describe } from "vitest";
2+
3+
function fibonacci(n: number): number {
4+
if (n < 2) {
5+
return n;
6+
}
7+
return fibonacci(n - 1) + fibonacci(n - 2);
8+
}
9+
10+
describe("fibo", () => {
11+
bench("fibo 10", () => {
12+
fibonacci(10);
13+
});
14+
bench("fibo 15", () => {
15+
fibonacci(15);
16+
});
17+
});

apps/blog/tsconfig.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@
55
"paths": {
66
"@/*": ["./*"]
77
},
8-
"jsx": "preserve"
8+
"jsx": "preserve",
99
},
1010
"include": [
1111
"next-env.d.ts",
1212
"next.config.js",
1313
"**/*.ts",
1414
"**/*.tsx",
1515
".next/types/**/*.ts",
16-
"./fuse/introspection.ts"
16+
"./fuse/introspection.ts",
17+
"../../vitest.config.ts"
1718
],
1819
"exclude": ["node_modules"]
1920
}

bun.lockb

16.6 KB
Binary file not shown.

bunfig.toml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[install.lockfile]
2+
print = "yarn" # Whether to generate a non-Bun lockfile alongside bun.lockb

lighthouserc.js lighthouserc.cjs

File renamed without changes.

package.json

+53-47
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,55 @@
11
{
2-
"name": "saku-blog-app",
3-
"private": true,
4-
"scripts": {
5-
"build": "turbo build",
6-
"start": "turbo start",
7-
"build:storybook": "turbo build:storybook",
8-
"clean:workspaces": "turbo clean",
9-
"dev": "turbo dev",
10-
"lint": "turbo check:lint",
11-
"format": "turbo check:format",
12-
"lf": "turbo check:lint-format",
13-
"pa11y": "turbo check:pa11y",
14-
"typecheck": "turbo check:typecheck",
15-
"checkAll": "turbo check",
16-
"storybook": "turbo storybook",
17-
"test:unit": "jest --config jest.config.ts",
18-
"test:update": "jest --config jest.config.ts --updateSnapshot",
19-
"test:watch": "jest --config jest.config.ts --watchAll",
20-
"test:debug": "jest --config jest.config.ts --runInBand",
21-
"test": "bun run test:unit",
22-
"check:format": "bunx biome format --changed --write .",
23-
"check:lint": "bunx biome lint --changed --apply .",
24-
"check:typecheck": "tsc --noEmit",
25-
"check:lint-format": "bunx biome check --changed --apply .",
26-
"check": "bun run check:typecheck & bunx biome check --apply . --no-errors-on-unmatched",
27-
"prepare": "husky"
28-
},
29-
"devDependencies": {
30-
"@biomejs/biome": "1.5.3",
31-
"@repo/typescript-config": "workspace:*",
32-
"turbo": "latest"
33-
},
34-
"engines": {
35-
"node": ">=20"
36-
},
37-
"packageManager": "[email protected]",
38-
"workspaces": [
39-
"apps/*",
40-
"packages/*"
41-
],
42-
"dependencies": {
43-
"husky": "^9.0.10",
44-
"pa11y-ci": "^3.1.0"
45-
},
46-
"volta": {
47-
"node": "20.11.1"
48-
}
2+
"name": "saku-blog-app",
3+
"private": true,
4+
"type": "module",
5+
"scripts": {
6+
"build": "turbo build",
7+
"start": "turbo start",
8+
"build:storybook": "turbo build:storybook",
9+
"clean:workspaces": "turbo clean",
10+
"dev": "turbo dev",
11+
"lint": "turbo check:lint",
12+
"format": "turbo check:format",
13+
"lf": "turbo check:lint-format",
14+
"pa11y": "turbo check:pa11y",
15+
"typecheck": "turbo check:typecheck",
16+
"checkAll": "turbo check",
17+
"storybook": "turbo storybook",
18+
"bench": "vitest bench",
19+
"test:unit": "vitest --config vitest.config.ts",
20+
"test:update": "vitest --config vitest.config.ts --updateSnapshot",
21+
"test:watch": "vitest --config vitest.config.ts --watchAll",
22+
"test:debug": "vitest --config vitest.config.ts --runInBand",
23+
"test": "bun run test:unit",
24+
"check:format": "bunx biome format --changed --write .",
25+
"check:lint": "bunx biome lint --changed --apply .",
26+
"check:typecheck": "tsc --noEmit",
27+
"check:lint-format": "bunx biome check --changed --apply .",
28+
"check": "bun run check:typecheck & bunx biome check --apply . --no-errors-on-unmatched",
29+
"prepare": "husky",
30+
"postinstall": "patch-package"
31+
},
32+
"devDependencies": {
33+
"@biomejs/biome": "1.5.3",
34+
"@codspeed/vitest-plugin": "^3.1.0",
35+
"@repo/typescript-config": "workspace:*",
36+
"patch-package": "^8.0.0",
37+
"turbo": "latest",
38+
"vitest": "^1.4.0"
39+
},
40+
"engines": {
41+
"node": ">=20"
42+
},
43+
"packageManager": "[email protected]",
44+
"workspaces": [
45+
"apps/*",
46+
"packages/*"
47+
],
48+
"dependencies": {
49+
"husky": "^9.0.10",
50+
"pa11y-ci": "^3.1.0"
51+
},
52+
"volta": {
53+
"node": "20.11.1"
54+
}
4955
}

packages/typescript-config/base.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
"incremental": false,
99
"isolatedModules": true,
1010
"lib": ["es2022", "DOM", "DOM.Iterable"],
11-
"module": "NodeNext",
1211
"moduleDetection": "force",
13-
"moduleResolution": "NodeNext",
12+
"moduleResolution": "Node",
13+
"module": "ESNext",
1414
"noUncheckedIndexedAccess": true,
1515
"resolveJsonModule": true,
1616
"skipLibCheck": true,

packages/typescript-config/nextjs.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"extends": "./base.json",
55
"compilerOptions": {
66
"plugins": [{ "name": "next" }],
7+
"moduleResolution": "Node",
78
"module": "ESNext",
8-
"moduleResolution": "Bundler",
99
"allowJs": true,
1010
"jsx": "react-jsx",
1111
"noEmit": true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
diff --git a/node_modules/@codspeed/vitest-plugin/package.json b/node_modules/@codspeed/vitest-plugin/package.json
2+
index f51062b..01feba0 100644
3+
--- a/node_modules/@codspeed/vitest-plugin/package.json
4+
+++ b/node_modules/@codspeed/vitest-plugin/package.json
5+
@@ -11,9 +11,7 @@
6+
"module": "./dist/index.mjs",
7+
"types": "./dist/index.d.ts",
8+
"exports": {
9+
- ".": {
10+
- "import": "./dist/index.mjs"
11+
- }
12+
+ ".": "./dist/index.mjs"
13+
},
14+
"type": "module",
15+
"files": [

0 commit comments

Comments
 (0)