Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: Add test for auto typed approach. #12207

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/benchmark-auto-typed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: TypeScript Benchmark "auto-typed-mongoose"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep this in the benchmark.yml file to minimize overhead. Just add 2 extra steps to npm install and run ts-benchmark in auto-typed directory.

on:
pull_request:
paths:
- ".github/workflows/benchmark.yml"
- "package.json"
- "types/**"
- "benchmarks/typescript/**"
push:
branches:
- master
paths:
- ".github/workflows/benchmark.yml"
- "package.json"
- "types/**"
- "benchmarks/typescript/**"
permissions:
contents: read

jobs:
typescript:
runs-on: ubuntu-20.04
name: Benchmark TypeScript Types
steps:
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2
with:
fetch-depth: 0
- name: Setup node
uses: actions/setup-node@2fddd8803e2f5c9604345a0b591c3020ee971a93 # v3.4.1
with:
node-version: 16

- run: npm install

- run: npx ts-benchmark -p ./benchmarks/typescript/auto-typed -f 17/100000 18 29 32 -b master -g -t --colors
env:
DB_URL: ${{ secrets.DB_URL }}
9 changes: 9 additions & 0 deletions benchmarks/typescript/auto-typed/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Schema, Model, model } from 'mongoose';

const schema = new Schema({
name: { type: String, required: true },
email: { type: String, required: true },
avatar: String
});

const UserModel = model('User', schema);
16 changes: 16 additions & 0 deletions benchmarks/typescript/auto-typed/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"baseUrl": ".",
"paths": {
"mongoose": ["../../../"]
}
},
"esModuleInterop": true,
"outDir": "typescript",
"strictNullChecks": true,
"include": [
"./*.ts",
"../../../index.d.ts"
]
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@
"tdd": "mocha ./test/*.test.js --inspect --watch --recursive --watch-files ./**/*.{js,ts}",
"test-coverage": "nyc --reporter=html --reporter=text npm test",
"ts-benchmark": "ts-benchmark -p ./benchmarks/typescript/simple -f 17/100000 18 29 32",
"ts-benchmark-watch": "ts-benchmark -p ./benchmarks/typescript/simple -w ./types -i -s -f 17/100000 18 29 32 -b master"
"ts-benchmark-watch": "ts-benchmark -p ./benchmarks/typescript/simple -w ./types -i -s -f 17/100000 18 29 32 -b master",
"ts-benchmark-auto": "ts-benchmark -p ./benchmarks/typescript/auto-typed -f 17/100000 18 29 32"
},
"main": "./index.js",
"types": "./types/index.d.ts",
Expand Down