Skip to content

Commit

Permalink
Merge pull request #5590 from gooddata/IMJ-STL-952
Browse files Browse the repository at this point in the history
chore: fix __version.ts generation and add build-generate-version
  • Loading branch information
pbenes authored Nov 25, 2024
2 parents 5e6569a + 3471cd3 commit c959a87
Show file tree
Hide file tree
Showing 17 changed files with 60 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/actions/rush/set-up-rush/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/rw-rush-build-basic-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
8 changes: 8 additions & 0 deletions common/config/rush/command-line.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions libs/api-client-tiger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down
9 changes: 6 additions & 3 deletions libs/api-client-tiger/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions libs/sdk-backend-tiger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
9 changes: 6 additions & 3 deletions libs/sdk-backend-tiger/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions libs/sdk-ui-dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
15 changes: 10 additions & 5 deletions libs/sdk-ui-dashboard/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
build $1
1 change: 1 addition & 0 deletions tools/app-toolkit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 5 additions & 0 deletions tools/app-toolkit/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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))"
Expand Down
1 change: 1 addition & 0 deletions tools/catalog-export/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 4 additions & 2 deletions tools/catalog-export/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions tools/mock-handling/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 4 additions & 2 deletions tools/mock-handling/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions tools/plugin-toolkit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 5 additions & 0 deletions tools/plugin-toolkit/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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))"
Expand Down

0 comments on commit c959a87

Please sign in to comment.