Skip to content

Commit

Permalink
fix(perf): fixes build and deploy issues with perf studio (#5646)
Browse files Browse the repository at this point in the history
* fix(perf): fixes build and deploy issues with perf studio

* fix(perf): fix types/node version

* fix(perf): minor readme clarifications

---------

Co-authored-by: Bjørge Næss <[email protected]>
  • Loading branch information
binoy14 and bjoerge authored Feb 5, 2024
1 parent 851b62d commit d17f722
Show file tree
Hide file tree
Showing 41 changed files with 65 additions and 41 deletions.
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"useWorkspaces": true,
"packages": [
"dev/*",
"perf",
"perf/tests",
"perf/studio",
"examples/*",
"packages/@sanity/*",
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"workspaces": [
"dev/*",
"perf",
"perf/tests",
"perf/studio",
"examples/*",
"packages/@sanity/*",
Expand All @@ -20,7 +20,7 @@
"check:format": "prettier . --check",
"check:packages": "lerna run check:package",
"clean": "lerna run clean && rm -f package-lock.json",
"clean:deps": "rimraf packages/@sanity/*/node_modules packages/*/node_modules node_modules",
"clean:deps": "rimraf packages/@sanity/*/node_modules packages/*/node_modules node_modules perf/tests/node_modules perf/studio/node_modules",
"check:deps-updates": "npx npm-check-updates --workspaces --root -m",
"check:versions": "node -r esbuild-register scripts/normalizeDependencyVersions.ts",
"depcheck": "lerna exec \"node -r esbuild-register \\$LERNA_ROOT_PATH/scripts/depcheck.ts\" --no-bail --parallel",
Expand Down Expand Up @@ -71,10 +71,10 @@
"start": "yarn dev:test-studio",
"test": "jest --forceExit",
"test:e2e": "playwright test",
"perf:test": "cd perf && yarn perf:test",
"perf:studio": "cd perf && yarn studio",
"perf:studio:dev": "cd perf && yarn studio:dev",
"perf:codegen": "cd perf && yarn perf:codegen",
"perf:test": "cd perf/tests && yarn perf:test",
"perf:studio": "cd perf/studio && yarn preview",
"perf:studio:dev": "cd perf/studio && yarn dev",
"perf:codegen": "cd perf/tests && yarn perf:codegen",
"tsdoc:dev": "sanity-tsdoc dev",
"type-check": "tsc --build",
"updated": "lerna updated",
Expand Down
10 changes: 5 additions & 5 deletions perf/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
## Overview

- **Perf Studio** - (`perf/studio`) this is the Sanity Studio that we run the test suite against (using playwright). This studio is set up to capture various cases that we want to measure performance of (e.g. a very large document)
- **Performance Test Runner** (`perf/runner.ts`) - this is the node script that sets up the required config, identifies the set of performance tests to run, instantiates a playwright instance that navigates to the set of perf studio deployments (urls), runs each defined performance test against each deployment and compares the difference.
- Performance test helpers - (`perf/helpers`) A set of performance test helpers that will be injected into the Performance Studio and exposed on `window.perf`.
- **Performance Test Runner and tests** (`perf/tests`) - this includes both performance tests and the runner script that sets up the required config, identifies the set of performance tests to run, instantiates a playwright instance that navigates to the set of perf studio deployments (urls), runs each defined performance test against each deployment and compares the difference.
- Performance test helpers - (`perf/tests/helpers`) A set of performance test helpers that will be injected into the Performance Studio and exposed on `window.perf`.

## Prerequisites

Before you can run the perf tests you need to add a session token so the tests are able to log in. See .env.example on the root of this repo for more info about how to set the required `PERF_STUDIO_SANITY_WRITE_TOKEN` and `PERF_TEST_SANITY_TOKEN` environment variables.
Before you can run the perf tests you need to add a session token so the tests are able to log in. See ./perf/tests/.env.example for more info about how to set the required `PERF_STUDIO_SANITY_WRITE_TOKEN` and `PERF_TEST_SANITY_TOKEN` environment variables.

# Run the perf tests locally

Expand All @@ -18,11 +18,11 @@ Run the perf tests against the perf studio locally to see how it compares to the
$ yarn perf:test
```

This will build the perf studio and run it in preview mode locally and run each test defined in the `perf/tests`-folder against it.
This will build the perf studio and run it in preview mode locally and run each test defined in the `perf/tests/tests`-folder against it.

## How to add a new perf test

Create a new test file in `perf/tests` with the following template:
Create a new test file in `perf/tests/tests` with the following template:

```js
export default {
Expand Down
3 changes: 2 additions & 1 deletion perf/studio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"clean": "rimraf .sanity dist",
"dev": "sanity dev --port 3300",
"lint": "eslint .",
"start": "sanity start --port 3300"
"start": "sanity start --port 3300",
"preview": "yarn build && yarn start"
},
"dependencies": {
"react": "^18.2.0",
Expand Down
2 changes: 1 addition & 1 deletion perf/studio/sanity.cli.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {defineCliConfig} from 'sanity/cli'
import {STUDIO_DATASET, STUDIO_PROJECT_ID} from '../config/constants'
import {STUDIO_DATASET, STUDIO_PROJECT_ID} from '../tests/config/constants'

export default defineCliConfig({
api: {
Expand Down
2 changes: 1 addition & 1 deletion perf/studio/sanity.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import {defineConfig, defineDocumentFieldAction, type PluginOptions} from 'sanity'
import {structureTool} from 'sanity/structure'
import {useCallback} from 'react'
import {STUDIO_DATASET, STUDIO_PROJECT_ID} from '../config/constants'
import {STUDIO_DATASET, STUDIO_PROJECT_ID} from '../tests/config/constants'
import {simple} from './schema/simple'
import {deepObject} from './schema/deepObject'
import {deepArray} from './schema/deepArray'
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion perf/jest.config.cjs → perf/tests/jest.config.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const {createJestConfig} = require('../test/config.cjs')
const {createJestConfig} = require('../../test/config.cjs')

module.exports = createJestConfig({
// ignore performance tests
Expand Down
14 changes: 8 additions & 6 deletions perf/package.json → perf/tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,22 @@
"studio": "yarn --cwd studio build && yarn --cwd studio start",
"studio:dev": "SANITY_STUDIO_DATASET=dev yarn --cwd studio dev"
},
"devDependencies": {
"@types/lodash": "^4.14.149",
"@types/node": "^18.15.3",
"esbuild": "^0.19.8",
"ts-node": "^10.9.1",
"typescript": "^5.2.2"
},
"dependencies": {
"@playwright/test": "^1.39.0",
"@sanity/client": "^6.12.3",
"@sanity/uuid": "^3.0.1",
"@types/lodash": "^4.14.191",
"@types/node": "^18.15.3",
"dotenv": "^16.0.3",
"esbuild": "^0.19.8",
"execa": "^2.0.0",
"globby": "^10.0.0",
"lodash": "^4.17.21",
"rxjs": "^7.8.0",
"sanity": "3.27.1",
"ts-node": "^10.9.1",
"typescript": "^5.1.6"
"sanity": "3.27.1"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion perf/tsconfig.json → perf/tests/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../tsconfig.settings.json",
"extends": "../../tsconfig.settings.json",
"include": ["./**/*"],
"compilerOptions": {
"esModuleInterop": true,
Expand Down
9 changes: 9 additions & 0 deletions perf/tests/turbo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "https://turbo.build/schema.json",
"extends": ["//"],
"pipeline": {
"build": {
"outputs": [".sanity/**", "dist/**"]
}
}
}
48 changes: 30 additions & 18 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4010,9 +4010,9 @@
integrity sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==

"@tsconfig/node16@^1.0.2":
version "1.0.3"
resolved "https://registry.yarnpkg.com/@tsconfig/node16/-/node16-1.0.3.tgz#472eaab5f15c1ffdd7f8628bd4c4f753995ec79e"
integrity sha512-yOlFc+7UtL/89t2ZhjPvvB/DeAr3r+Dq58IgzsFkOAvVC6NMJXmCGjbptdXdR9qsX7pKcTL+s87FtYREi2dEEQ==
version "1.0.4"
resolved "https://registry.yarnpkg.com/@tsconfig/node16/-/node16-1.0.4.tgz#0b92dcc0cc1c81f6f306a381f28e31b1a56536e9"
integrity sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==

"@turf/boolean-point-in-polygon@^5.1.5":
version "5.1.5"
Expand Down Expand Up @@ -4304,7 +4304,7 @@
dependencies:
"@types/lodash" "*"

"@types/lodash@*", "@types/lodash@^4.14.149", "@types/lodash@^4.14.191", "@types/lodash@^4.14.200":
"@types/lodash@*", "@types/lodash@^4.14.149", "@types/lodash@^4.14.200":
version "4.14.201"
resolved "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.201.tgz#76f47cb63124e806824b6c18463daf3e1d480239"
integrity sha512-y9euML0cim1JrykNxADLfaG0FgD1g/yTHwUs/Jg9ZIU7WKj2/4IW9Lbb1WZbvck78W/lfGXFfe+u2EGfIJXdLQ==
Expand Down Expand Up @@ -4365,15 +4365,22 @@
dependencies:
"@types/node" "*"

"@types/node@*", "@types/node@^18.15.3":
"@types/node@*":
version "18.16.3"
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.16.3.tgz#6bda7819aae6ea0b386ebc5b24bdf602f1b42b01"
integrity sha512-OPs5WnnT1xkCBiuQrZA4+YAV4HEJejmHneyraIaxsbev5yCEr6KMwINNFP9wQeFIw8FWcoTqF3vQsa5CDaI+8Q==

"@types/node@^14.18.9":
version "14.18.43"
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.18.43.tgz#679e000d9f1d914132ea295b4a1ffdf20370ec49"
integrity sha512-n3eFEaoem0WNwLux+k272P0+aq++5o05bA9CfiwKPdYPB5ZambWKdWoeHy7/OJiizMhzg27NLaZ6uzjLTzXceQ==
version "14.18.63"
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.18.63.tgz#1788fa8da838dbb5f9ea994b834278205db6ca2b"
integrity sha512-fAtCfv4jJg+ExtXhvCkCqUKZ+4ok/JQk01qDKhL5BDDoS3AxKXhV5/MAVUZyQnSEd2GT92fkgZl0pz0Q0AzcIQ==

"@types/node@^18.15.3":
version "18.19.14"
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.19.14.tgz#1880ff1b3ac913f3877f711588e5ed227da01886"
integrity sha512-EnQ4Us2rmOS64nHDWr0XqAD8DsO6f3XR6lf9UIIrZQpUzPVdN/oPuEzfDWNHSyXLvoGgjuEm/sPwFGSSs35Wtg==
dependencies:
undici-types "~5.26.4"

"@types/normalize-package-data@^2.4.0":
version "2.4.1"
Expand Down Expand Up @@ -4961,14 +4968,14 @@ acorn-jsx@^5.3.2:
integrity sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==

acorn-walk@^8.0.2, acorn-walk@^8.1.1:
version "8.2.0"
resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.2.0.tgz#741210f2e2426454508853a2f44d0ab83b7f69c1"
integrity sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==
version "8.3.2"
resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.3.2.tgz#7703af9415f1b6db9315d6895503862e231d34aa"
integrity sha512-cjkyv4OtNCIeqhHrfS81QWXoCBPExR/J62oyEqepVw8WaQeSqpW2uhuLPh1m9eWhDuOo/jUXVTlifvesOWp/4A==

acorn@^8.1.0, acorn@^8.4.1, acorn@^8.8.1, acorn@^8.8.2, acorn@^8.9.0:
version "8.10.0"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.10.0.tgz#8be5b3907a67221a81ab23c7889c4c5526b62ec5"
integrity sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw==
version "8.11.3"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.11.3.tgz#71e0b14e13a4ec160724b38fb7b0f233b1b81d7a"
integrity sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==

add-stream@^1.0.0:
version "1.0.0"
Expand Down Expand Up @@ -15508,9 +15515,9 @@ ts-api-utils@^1.0.1:
integrity sha512-wNMeqtMz5NtwpT/UZGY5alT+VoKdSsOOP/kqHFcUW1P/VRhH2wJ48+DN2WwUliNbQ976ETwDL0Ifd2VVvgonvg==

ts-node@^10.9.1:
version "10.9.1"
resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.9.1.tgz#e73de9102958af9e1f0b168a6ff320e25adcff4b"
integrity sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==
version "10.9.2"
resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.9.2.tgz#70f021c9e185bccdca820e26dc413805c101c71f"
integrity sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==
dependencies:
"@cspotcode/source-map-support" "^0.8.0"
"@tsconfig/node10" "^1.0.7"
Expand Down Expand Up @@ -15732,7 +15739,7 @@ typeid-js@^0.3.0:
dependencies:
uuidv7 "^0.4.4"

typescript@^5.1.6, typescript@^5.2.2:
typescript@^5.2.2:
version "5.2.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.2.2.tgz#5ebb5e5a5b75f085f22bc3f8460fba308310fa78"
integrity sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==
Expand Down Expand Up @@ -15775,6 +15782,11 @@ unbzip2-stream@^1.0.9:
buffer "^5.2.1"
through "^2.3.8"

undici-types@~5.26.4:
version "5.26.5"
resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617"
integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==

unicode-canonical-property-names-ecmascript@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-2.0.0.tgz#301acdc525631670d39f6146e0e77ff6bbdebddc"
Expand Down

0 comments on commit d17f722

Please sign in to comment.