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

kie-issues#1566: Remove pkg dependency from image-env-to-json on kie-tools, as it's deprecated #2901

Merged
merged 26 commits into from
Feb 22, 2025

Conversation

ljmotta
Copy link
Contributor

@ljmotta ljmotta commented Feb 10, 2025

Closes: apache/incubator-kie-issues#1566
Closes: #2578

Description

Fully rewrite using Golang to simplify generate native binaries.

Obs: Some usages weren't updated to use the new Darwin and Windows binaries, since they are placed inside a Linux container.

@ljmotta ljmotta added area:dependencies Pull requests that update a dependency file area:monorepo labels Feb 10, 2025
@ljmotta ljmotta requested a review from thiagoelg February 10, 2025 22:31
@ljmotta ljmotta self-assigned this Feb 10, 2025
@ljmotta ljmotta requested a review from tiagobento as a code owner February 10, 2025 22:31
build-all: build-darwin-amd64 build-darwin-arm64 build-linux-amd64 build-linux-arm64 build-win-amd64 build-win-arm64

build-darwin:
CGO_ENABLED=0 GOOS=darwin GOARCH=$(GOARCH) go build -ldflags $(LDFLAGS) -o $(BIN_PATH)/$(BIN_BUILD_DARWIN) $(MAIN_PATH)
Copy link
Member

Choose a reason for hiding this comment

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

I know it's not ideal, but in other packages, we use cross-env here to avoid OS-specific errors when cross-building.

Comment on lines 17 to 31
"build": "run-script-os",
"build:darwin": "pnpm setup:env make build-darwin",
"build:darwin:amd": "pnpm setup:env make build-darwin-amd64",
"build:darwin:arm": "pnpm setup:env make build-darwin-arm64",
"build:dev": "rimraf -rf dist && pnpm build",
"build:linux": "pnpm setup:env make build-linux",
"build:linux:amd": "pnpm setup:env make build-linux-amd64",
"build:linux:arm": "pnpm setup:env make build-linux-arm64",
"build:prod": "rimraf -rf dist && run-script-os && pnpm test",
"build:prod:darwin": "rimraf dist && pnpm setup:env make build-all",
"build:prod:linux": "rimraf dist && pnpm setup:env make build-all",
"build:prod:win32": "rimraf dist && pnpm setup:env:win32 make build-all",
"build:win32": "pnpm setup:env:win32 make build-win",
"build:win32:amd": "pnpm setup:env:win32 make build-win-amd64",
"build:win32:arm": "pnpm setup:env:win32 make build-win-arm64",
Copy link
Member

Choose a reason for hiding this comment

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

I think we should build all binaries every time (on build:dev and build:prod). It should be quick, and we can avoid issues where, for example, we test the binary in a macOS ARM environment but then run it inside a Linux x64 container.

It would also simplify this list of scripts in the package.json.

"install": "go mod tidy",
"powershell": "@powershell -NoProfile -ExecutionPolicy Unrestricted -Command",
"setup:env": "cross-env PLUGIN_VERSION=$(build-env imageEnvToJson.version)",
"setup:env:win32": "pnpm powershell \"cross-env PLUGIN_VERSION=$(build-env imageEnvToJson.version)\"",
Copy link
Member

Choose a reason for hiding this comment

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

Is powershell needed even with cross-env?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, we need to set the environment variables before the make.

@tiagobento
Copy link
Contributor

Please add tests for when env vars contain JSON strings too. Thank you!

@tiagobento tiagobento merged commit 3286396 into apache:main Feb 22, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:dependencies Pull requests that update a dependency file area:monorepo
Projects
None yet
3 participants