From 3471cd3e623818e80eec4a7949ab722f2811aa66 Mon Sep 17 00:00:00 2001 From: ivanmjartan Date: Mon, 25 Nov 2024 11:22:43 +0100 Subject: [PATCH] chore: fix __version.ts generation and add build-generate-version risk: nonprod --- .github/actions/rush/set-up-rush/action.yml | 2 +- .github/workflows/rw-rush-build-basic-checks.yml | 4 ++++ common/config/rush/command-line.json | 8 ++++++++ libs/api-client-tiger/package.json | 1 + libs/api-client-tiger/scripts/build.sh | 9 ++++++--- libs/sdk-backend-tiger/package.json | 1 + libs/sdk-backend-tiger/scripts/build.sh | 9 ++++++--- libs/sdk-ui-dashboard/package.json | 1 + libs/sdk-ui-dashboard/scripts/build.sh | 15 ++++++++++----- tools/app-toolkit/package.json | 1 + tools/app-toolkit/scripts/build.sh | 5 +++++ tools/catalog-export/package.json | 1 + tools/catalog-export/scripts/build.sh | 6 ++++-- tools/mock-handling/package.json | 1 + tools/mock-handling/scripts/build.sh | 6 ++++-- tools/plugin-toolkit/package.json | 1 + tools/plugin-toolkit/scripts/build.sh | 5 +++++ 17 files changed, 60 insertions(+), 16 deletions(-) diff --git a/.github/actions/rush/set-up-rush/action.yml b/.github/actions/rush/set-up-rush/action.yml index ce94c9a94d1..3e1d5c4d458 100644 --- a/.github/actions/rush/set-up-rush/action.yml +++ b/.github/actions/rush/set-up-rush/action.yml @@ -32,7 +32,7 @@ runs: shell: bash - name: Enable rush build cache via environment variable - run: echo "RUSH_BUILD_CACHE_ENABLED=0" >> $GITHUB_ENV + run: echo "RUSH_BUILD_CACHE_ENABLED=1" >> $GITHUB_ENV shell: bash # Restore cache for global rush installation diff --git a/.github/workflows/rw-rush-build-basic-checks.yml b/.github/workflows/rw-rush-build-basic-checks.yml index fe6ad64c1a1..b704f8ae297 100644 --- a/.github/workflows/rw-rush-build-basic-checks.yml +++ b/.github/workflows/rw-rush-build-basic-checks.yml @@ -73,6 +73,8 @@ jobs: run: | # build libs first, then the app node common/scripts/install-run-rush.js build + - name: Rush generate dynamic files related to build + run: node common/scripts/install-run-rush.js build-generate-version - name: Rush validate run: | # build libs first, then the app @@ -101,6 +103,8 @@ jobs: run: | # build libs first, then the app node common/scripts/install-run-rush.js build + - name: Rush generate dynamic files related to build + run: node common/scripts/install-run-rush.js build-generate-version - name: Rush test-ci run: | node common/scripts/install-run-rush.js test-ci diff --git a/common/config/rush/command-line.json b/common/config/rush/command-line.json index 3967affa1da..e38e226750c 100644 --- a/common/config/rush/command-line.json +++ b/common/config/rush/command-line.json @@ -120,6 +120,14 @@ "enableParallelism": true, "allowWarningsInSuccessfulBuild": false }, + { + "commandKind": "bulk", + "name": "build-generate-version", + "summary": "This command will generate dynamic __version.ts files after build is restored from cache, because this files are generated only during build and are not stored in cache.", + "enableParallelism": true, + "allowWarningsInSuccessfulBuild": true, + "ignoreMissingScript": true + }, { "commandKind": "global", "name": "audit", diff --git a/libs/api-client-tiger/package.json b/libs/api-client-tiger/package.json index 6cdc9fc3ced..d245bb0649d 100644 --- a/libs/api-client-tiger/package.json +++ b/libs/api-client-tiger/package.json @@ -23,6 +23,7 @@ "scripts": { "clean": "rm -rf ci dist esm coverage *.log tsconfig.tsbuildinfo", "build": "bash scripts/build.sh", + "build-generate-version": "bash scripts/build.sh --genVersionOnly", "openapi-generate": "./scripts/generate.js", "generate-client": "rm -rf src/generated/* && npm run openapi-generate && fix-esm-import-path ./src && npm run prettier-write", "api-extractor": "mkdir -p api && [ -z \"${CI}\" ] && (api-extractor run -l) || (api-extractor run)", diff --git a/libs/api-client-tiger/scripts/build.sh b/libs/api-client-tiger/scripts/build.sh index 53158656f4a..192dab7a2fc 100644 --- a/libs/api-client-tiger/scripts/build.sh +++ b/libs/api-client-tiger/scripts/build.sh @@ -14,8 +14,11 @@ _common-build() { build() { _common-build - tsc -p tsconfig.json - npm run api-extractor + + if [[ $1 != "--genVersionOnly" ]]; then + tsc -p tsconfig.json + npm run api-extractor + fi } -build +build $1 diff --git a/libs/sdk-backend-tiger/package.json b/libs/sdk-backend-tiger/package.json index 374c61d9875..778f422a9f8 100644 --- a/libs/sdk-backend-tiger/package.json +++ b/libs/sdk-backend-tiger/package.json @@ -24,6 +24,7 @@ "clean": "rm -rf ci dist esm coverage *.log tsconfig.tsbuildinfo", "clear-recordings": "rm -rf ./tests/wiremock/recordings/*", "build": "bash scripts/build.sh", + "build-generate-version": "bash scripts/build.sh --genVersionOnly", "api-extractor": "mkdir -p api && [ -z \"${CI}\" ] && (api-extractor run -l) || (api-extractor run)", "integrated-test": "./scripts/integrated-test.sh", "integrated-test-live-backend": "./scripts/integrated-test-live-backend.sh", diff --git a/libs/sdk-backend-tiger/scripts/build.sh b/libs/sdk-backend-tiger/scripts/build.sh index 61c100bbd27..192dab7a2fc 100644 --- a/libs/sdk-backend-tiger/scripts/build.sh +++ b/libs/sdk-backend-tiger/scripts/build.sh @@ -14,8 +14,11 @@ _common-build() { build() { _common-build - tsc -p tsconfig.json - npm run api-extractor + + if [[ $1 != "--genVersionOnly" ]]; then + tsc -p tsconfig.json + npm run api-extractor + fi } -build \ No newline at end of file +build $1 diff --git a/libs/sdk-ui-dashboard/package.json b/libs/sdk-ui-dashboard/package.json index 2e93410d958..5e9715c97e1 100644 --- a/libs/sdk-ui-dashboard/package.json +++ b/libs/sdk-ui-dashboard/package.json @@ -36,6 +36,7 @@ "clean": "rm -rf ci dist esm coverage *.log styles/css tsconfig.tsbuildinfo", "api-extractor": "mkdir -p api && [ -z \"${CI}\" ] && (api-extractor run -l; exit 0) || (api-extractor run)", "build": "bash scripts/build.sh", + "build-generate-version": "bash scripts/build.sh --genVersionOnly", "prepack": "cp -f ../../NOTICE ./NOTICE", "prepublishOnly": "npm run build", "test": "vitest --watch", diff --git a/libs/sdk-ui-dashboard/scripts/build.sh b/libs/sdk-ui-dashboard/scripts/build.sh index 2deebd6314a..d1d9c5d59d8 100644 --- a/libs/sdk-ui-dashboard/scripts/build.sh +++ b/libs/sdk-ui-dashboard/scripts/build.sh @@ -20,18 +20,23 @@ _assets() { svgo -rqf src/assets esm/assets } -_common-build() { +styles-build() { _assets - _build_styles +} +_common-build() { _version } build() { _common-build - tsc -p tsconfig.json - npm run api-extractor + + if [[ $1 != "--genVersionOnly" ]]; then + styles-build + tsc -p tsconfig.json + npm run api-extractor + fi } -build \ No newline at end of file +build $1 diff --git a/tools/app-toolkit/package.json b/tools/app-toolkit/package.json index de6cec98270..67c650f1832 100644 --- a/tools/app-toolkit/package.json +++ b/tools/app-toolkit/package.json @@ -28,6 +28,7 @@ "clean": "rm -rf ci dist esm build coverage *.log tsconfig.tsbuildinfo", "prepublishOnly": "npm run build", "build": "bash scripts/build.sh", + "build-generate-version": "bash scripts/build.sh --genVersionOnly", "prepack": "cp -f ../../NOTICE ./NOTICE", "test": "vitest watch --passWithNoTests", "test-once": "vitest run --passWithNoTests", diff --git a/tools/app-toolkit/scripts/build.sh b/tools/app-toolkit/scripts/build.sh index 48c9c5cf884..d9a1b3701f1 100644 --- a/tools/app-toolkit/scripts/build.sh +++ b/tools/app-toolkit/scripts/build.sh @@ -6,6 +6,11 @@ echo '// (C) 2021 GoodData Corporation' >src/__version.ts echo '// DO NOT CHANGE THIS FILE, IT IS RE-GENERATED ON EVERY BUILD' >>src/__version.ts node -p "'export const LIB_VERSION = ' + JSON.stringify(require('./package.json').version) + ';' +'\n\n' + 'export const LIB_DESCRIPTION =' + '\n ' + JSON.stringify(require('./package.json').description) + ';' +'\n\n' + 'export const LIB_NAME = ' + JSON.stringify(require('./package.json').name) + ';'" >>src/__version.ts +if [[ $1 == "--genVersionOnly" ]]; then + #we need just version file and it is generated, so we can exit + exit 0 +fi; + set -e PACKAGE_DIR="$(echo $(cd $(dirname $0)/.. && pwd -P))" diff --git a/tools/catalog-export/package.json b/tools/catalog-export/package.json index eb5ebdb7a7f..83c9e6e7e78 100644 --- a/tools/catalog-export/package.json +++ b/tools/catalog-export/package.json @@ -24,6 +24,7 @@ "scripts": { "clean": "rm -rf ci dist esm coverage *.log tsconfig.tsbuildinfo", "build": "bash scripts/build.sh", + "build-generate-version": "bash scripts/build.sh --genVersionOnly", "test": "vitest watch", "test-once": "vitest run", "test-ci": "vitest run --reporter=junit --outputFile=./ci/results/test-results.xml", diff --git a/tools/catalog-export/scripts/build.sh b/tools/catalog-export/scripts/build.sh index de6e066bbef..69a10b42e7d 100644 --- a/tools/catalog-export/scripts/build.sh +++ b/tools/catalog-export/scripts/build.sh @@ -15,7 +15,9 @@ _common-build() { build() { _common-build - tsc -p tsconfig.json + if [[ $1 != "--genVersionOnly" ]]; then + tsc -p tsconfig.json + fi } -build +build $1 diff --git a/tools/mock-handling/package.json b/tools/mock-handling/package.json index 24d514964e8..902919d69cd 100644 --- a/tools/mock-handling/package.json +++ b/tools/mock-handling/package.json @@ -24,6 +24,7 @@ "scripts": { "clean": "rm -rf ci dist esm coverage *.log tsconfig.tsbuildinfo", "build": "bash scripts/build.sh", + "build-generate-version": "bash scripts/build.sh --genVersionOnly", "test": "vitest watch", "test-once": "vitest run", "test-ci": "vitest run --reporter=junit --outputFile=./ci/results/test-results.xml", diff --git a/tools/mock-handling/scripts/build.sh b/tools/mock-handling/scripts/build.sh index 387b4ccdcca..2cb65698288 100644 --- a/tools/mock-handling/scripts/build.sh +++ b/tools/mock-handling/scripts/build.sh @@ -15,7 +15,9 @@ _common-build() { build() { _common-build - tsc -p tsconfig.json + if [[ $1 != "--genVersionOnly" ]]; then + tsc -p tsconfig.json + fi } -build +build $1 diff --git a/tools/plugin-toolkit/package.json b/tools/plugin-toolkit/package.json index 57d146b236c..4adb573ad5d 100644 --- a/tools/plugin-toolkit/package.json +++ b/tools/plugin-toolkit/package.json @@ -29,6 +29,7 @@ "clean": "rm -rf ci dist esm build coverage *.log tsconfig.tsbuildinfo", "prepublishOnly": "npm run build", "build": "bash scripts/build.sh", + "build-generate-version": "bash scripts/build.sh --genVersionOnly", "prepack": "cp -f ../../NOTICE ./NOTICE", "test": "vitest watch", "test-once": "vitest run", diff --git a/tools/plugin-toolkit/scripts/build.sh b/tools/plugin-toolkit/scripts/build.sh index 7ed8264ef37..83fecf1164a 100644 --- a/tools/plugin-toolkit/scripts/build.sh +++ b/tools/plugin-toolkit/scripts/build.sh @@ -6,6 +6,11 @@ echo '// (C) 2021 GoodData Corporation' >src/__version.ts echo '// DO NOT CHANGE THIS FILE, IT IS RE-GENERATED ON EVERY BUILD' >>src/__version.ts node -p "'export const LIB_VERSION = ' + JSON.stringify(require('./package.json').version) + ';' +'\n\n' + 'export const LIB_DESCRIPTION = ' + JSON.stringify(require('./package.json').description) + ';' +'\n\n' + 'export const LIB_NAME = ' + JSON.stringify(require('./package.json').name) + ';'" >>src/__version.ts +if [[ $1 == "--genVersionOnly" ]]; then + #we need just version file and it is generated, so we can exit + exit 0 +fi; + set -e PACKAGE_DIR="$(echo $(cd $(dirname $0)/.. && pwd -P))"