From fec39a6212baa800c8f7f69a3311151677a05e6d Mon Sep 17 00:00:00 2001 From: Andrey Sobolev Date: Fri, 23 Feb 2024 14:30:49 +0700 Subject: [PATCH] UBERF-5694: Attempt to fix build cache Signed-off-by: Andrey Sobolev --- common/config/rush/command-line.json | 12 +++++++----- common/config/rush/experiments.json | 2 +- dev/tool/package.json | 4 ++-- packages/platform-rig/bin/compile.js | 16 ++++++++-------- packages/platform-rig/bin/format.js | 4 +++- .../profiles/assets/config/rush-project.json | 8 +++++--- .../profiles/default/config/rush-project.json | 8 +++++--- .../profiles/model/config/rush-project.json | 8 +++++--- .../profiles/node/config/rush-project.json | 8 +++++--- .../profiles/package/config/rush-project.json | 9 ++++++--- .../profiles/ui/config/rush-project.json | 8 +++++--- rush.json | 2 +- 12 files changed, 53 insertions(+), 36 deletions(-) diff --git a/common/config/rush/command-line.json b/common/config/rush/command-line.json index 8e1d1f07f71..ad8584aa408 100644 --- a/common/config/rush/command-line.json +++ b/common/config/rush/command-line.json @@ -86,16 +86,18 @@ ], "commands": [ { - "commandKind": "bulk", + "commandKind": "phased", "name": "build:watch", "summary": "Build and watch", + "phases": ["_phase:build", "_phase:validate"], "description": "Perform build with tsc and watch for changes with rush", "enableParallelism": true, "incremental": true, - "ignoreMissingScript": true, - "watchForChanges": true, "safeForSimultaneousRushProcesses": true, - "disableBuildCache": false + "watchOptions": { + "alwaysWatch": true, + "watchPhases": ["_phase:build", "_phase:validate"] + } }, { "commandKind": "bulk", @@ -130,7 +132,7 @@ "phases": ["_phase:validate"], "summary": "validate", "enableParallelism": true, - "incremental": true + "incremental": true }, { "commandKind": "phased", diff --git a/common/config/rush/experiments.json b/common/config/rush/experiments.json index 56160d97174..b8710566880 100644 --- a/common/config/rush/experiments.json +++ b/common/config/rush/experiments.json @@ -34,7 +34,7 @@ * If true, build caching will respect the allowWarningsInSuccessfulBuild flag and cache builds with warnings. * This will not replay warnings from the cached build. */ - // "buildCacheWithAllowWarningsInSuccessfulBuild": true, + "buildCacheWithAllowWarningsInSuccessfulBuild": true, /** * If true, the phased commands feature is enabled. To use this feature, create a "phased" command diff --git a/dev/tool/package.json b/dev/tool/package.json index 42db1a9c3c4..3efcd53fe8c 100644 --- a/dev/tool/package.json +++ b/dev/tool/package.json @@ -18,8 +18,8 @@ "docker:build": "docker build -t hardcoreeng/tool .", "docker:staging": "../../common/scripts/docker_tag.sh hardcoreeng/tool staging", "docker:push": "../../common/scripts/docker_tag.sh hardcoreeng/tool", - "run-local": "cross-env SERVER_SECRET=secret MINIO_ACCESS_KEY=minioadmin MINIO_SECRET_KEY=minioadmin MINIO_ENDPOINT=localhost MONGO_URL=mongodb://localhost:27017 TRANSACTOR_URL=ws://localhost:3333 TELEGRAM_DATABASE=telegram-service ELASTIC_URL=http://localhost:9200 REKONI_URL=http://localhost:4004 MODEL_VERSION=$(node ../../common/scripts/show_version.js) GIT_REVISION=$(git describe --all --long) node -r ts-node/register --max-old-space-size=18000 ./src/__start.ts", - "run": "cross-env node -r ts-node/register --max-old-space-size=8000 MODEL_VERSION=$(node ../../common/scripts/show_version.js) ./src/__start.ts", + "run-local": "rush bundle --to @hcengineering/tool >/dev/null && cross-env SERVER_SECRET=secret MINIO_ACCESS_KEY=minioadmin MINIO_SECRET_KEY=minioadmin MINIO_ENDPOINT=localhost MONGO_URL=mongodb://localhost:27017 TRANSACTOR_URL=ws://localhost:3333 TELEGRAM_DATABASE=telegram-service ELASTIC_URL=http://localhost:9200 REKONI_URL=http://localhost:4004 MODEL_VERSION=$(node ../../common/scripts/show_version.js) GIT_REVISION=$(git describe --all --long) node --max-old-space-size=18000 ./bundle/bundle.js", + "run": "rush bundle --to @hcengineering/tool >/dev/null && cross-env node --max-old-space-size=8000 ./bundle/bundle.js", "upgrade": "rushx run-local upgrade", "format": "format src", "test": "jest --passWithNoTests --silent --forceExit", diff --git a/packages/platform-rig/bin/compile.js b/packages/platform-rig/bin/compile.js index 305818afbe9..d2b9c3c5e86 100755 --- a/packages/platform-rig/bin/compile.js +++ b/packages/platform-rig/bin/compile.js @@ -5,19 +5,19 @@ const { spawn } = require('child_process') const esbuild = require('esbuild') const { copy } = require('esbuild-plugin-copy') -async function execProcess(cmd, logFile, args) { +async function execProcess(cmd, logFile, args, buildDir= '.build') { let compileRoot = dirname(dirname(process.argv[1])) console.log('Running from',) console.log("Compiling...\n", process.cwd(), args) - if (!existsSync(join(process.cwd(), '.build'))) { - mkdirSync(join(process.cwd(), '.build')) + if (!existsSync(join(process.cwd(), buildDir))) { + mkdirSync(join(process.cwd(), buildDir)) } const compileOut = spawn(cmd, args) - const stdoutFilePath = `.build/${logFile}.log` - const stderrFilePath = `.build/${logFile}-err.log` + const stdoutFilePath = `${buildDir}/${logFile}.log` + const stderrFilePath = `${buildDir}/${logFile}-err.log` const outPromise = new Promise((resolve) => { @@ -159,14 +159,14 @@ async function validateTSC(st) { } await execProcess( 'tsc', - 'tsc', + 'validate', [ '-pretty', "--emitDeclarationOnly", - "--incremental", + "--incremental", "--tsBuildInfoFile", ".validate/tsBuildInfoFile.info", "--declarationDir", "types", ...args.splice(1) - ]) + ], '.validate') } diff --git a/packages/platform-rig/bin/format.js b/packages/platform-rig/bin/format.js index f473a7a40b2..6fb9a011b8b 100755 --- a/packages/platform-rig/bin/format.js +++ b/packages/platform-rig/bin/format.js @@ -97,7 +97,9 @@ if( filesToCheck.length > 0 ) { } console.log(`running eslint ${filesToCheck.length}`) - const eslint = spawnSync(join(process.cwd(), 'node_modules/.bin/eslint'), ["--color", "--fix", ...filesToCheck]) + const eslint = spawnSync(join(process.cwd(), 'node_modules/.bin/eslint'), ["--color", "--fix", ...filesToCheck], { + env: {...process.env, NODE_ENV: '--max-old-space-size=4096' }, + }) if(eslint.stdout != null) { writeFileSync('.format/eslint.log', eslint.stdout) if( prettier.status === null || prettier.status === 0) { diff --git a/packages/platform-rig/profiles/assets/config/rush-project.json b/packages/platform-rig/profiles/assets/config/rush-project.json index c5e80a97213..0afa51eeb07 100644 --- a/packages/platform-rig/profiles/assets/config/rush-project.json +++ b/packages/platform-rig/profiles/assets/config/rush-project.json @@ -3,7 +3,10 @@ "temp/**", "lib/**", "**/*.svelte", - ".build/**" + ".build/**", + ".validate/**", + ".format/**", + "types" ], "disableBuildCacheForProject": false, @@ -26,8 +29,7 @@ }, { "operationName": "_phase:build", - "outputFolderNames": ["lib", ".build"], - "disableBuildCacheForOperation": true + "outputFolderNames": ["lib", ".build"] }, { "operationName": "_phase:validate", diff --git a/packages/platform-rig/profiles/default/config/rush-project.json b/packages/platform-rig/profiles/default/config/rush-project.json index bbcd94a8dc7..44582707dd9 100644 --- a/packages/platform-rig/profiles/default/config/rush-project.json +++ b/packages/platform-rig/profiles/default/config/rush-project.json @@ -4,7 +4,10 @@ "rush-logs/**", "coverage/**", ".rush/**", - ".build/**" + ".build/**", + ".validate/**", + ".format/**", + "types" ], "disableBuildCacheForProject": false, @@ -27,8 +30,7 @@ }, { "operationName": "_phase:build", - "outputFolderNames": ["lib", ".build"], - "disableBuildCacheForOperation": true + "outputFolderNames": ["lib", ".build"] }, { "operationName": "_phase:validate", diff --git a/packages/platform-rig/profiles/model/config/rush-project.json b/packages/platform-rig/profiles/model/config/rush-project.json index 8215b9b1b4e..ff0abdb8bc5 100644 --- a/packages/platform-rig/profiles/model/config/rush-project.json +++ b/packages/platform-rig/profiles/model/config/rush-project.json @@ -3,7 +3,10 @@ "temp/**", "lib/**", "coverage/**", - ".build/**" + ".build/**", + ".validate/**", + ".format/**", + "types" ], "disableBuildCacheForProject": false, @@ -22,8 +25,7 @@ }, { "operationName": "_phase:build", - "outputFolderNames": ["lib", ".build"], - "disableBuildCacheForOperation": true + "outputFolderNames": ["lib", ".build"] }, { "operationName": "_phase:validate", diff --git a/packages/platform-rig/profiles/node/config/rush-project.json b/packages/platform-rig/profiles/node/config/rush-project.json index e82767765ce..32989950761 100644 --- a/packages/platform-rig/profiles/node/config/rush-project.json +++ b/packages/platform-rig/profiles/node/config/rush-project.json @@ -3,7 +3,10 @@ "temp/**", "lib/**", "coverage/**", - ".build/**" + ".build/**", + ".validate/**", + ".format/**", + "types" ], "disableBuildCacheForProject": false, @@ -26,8 +29,7 @@ }, { "operationName": "_phase:build", - "outputFolderNames": ["lib", ".build"], - "disableBuildCacheForOperation": true + "outputFolderNames": ["lib", ".build"] }, { "operationName": "_phase:validate", diff --git a/packages/platform-rig/profiles/package/config/rush-project.json b/packages/platform-rig/profiles/package/config/rush-project.json index 14e7574f463..299895a6747 100644 --- a/packages/platform-rig/profiles/package/config/rush-project.json +++ b/packages/platform-rig/profiles/package/config/rush-project.json @@ -5,7 +5,11 @@ "rush-logs/**", "coverage/**", ".rush/**", - ".build/**" + ".build/**", + ".validate/**", + ".format/**", + "types", + "dist" ], "disableBuildCacheForProject": false, @@ -32,8 +36,7 @@ }, { "operationName": "_phase:build", - "outputFolderNames": ["lib", ".build"], - "disableBuildCacheForOperation": true + "outputFolderNames": ["lib", ".build"] }, { "operationName": "_phase:validate", diff --git a/packages/platform-rig/profiles/ui/config/rush-project.json b/packages/platform-rig/profiles/ui/config/rush-project.json index a56a04780a5..3f05e81ff50 100644 --- a/packages/platform-rig/profiles/ui/config/rush-project.json +++ b/packages/platform-rig/profiles/ui/config/rush-project.json @@ -4,7 +4,10 @@ ".build/**", "coverage/**", "**/*.svelte", - ".build/**" + ".build/**", + ".validate/**", + ".format/**", + "types" ], "disableBuildCacheForProject": false, @@ -23,8 +26,7 @@ }, { "operationName": "_phase:build", - "outputFolderNames": ["lib", ".build"], - "disableBuildCacheForOperation": true + "outputFolderNames": ["lib", ".build"] }, { "operationName": "_phase:validate", diff --git a/rush.json b/rush.json index 315a4c96ce5..317b2a4aac5 100644 --- a/rush.json +++ b/rush.json @@ -16,7 +16,7 @@ * path segment in the "$schema" field for all your Rush config files. This will ensure * correct error-underlining and tab-completion for editors such as VS Code. */ - "rushVersion": "5.113.4", + "rushVersion": "5.115.0", /** * The next field selects which package manager should be installed and determines its version.