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

[crossbuild] Fix path separators #3310

Merged
merged 2 commits into from
Sep 5, 2023

Conversation

ycombinator
Copy link
Contributor

@ycombinator ycombinator commented Aug 29, 2023

What does this PR do?

This PR fixes the path separators in the crossBuild target, so if this target is invoked on a Windows host, it creates the correct build command to be run inside a Linux-based Docker container.

Why is it important?

So we can build Elastic Agent on Windows hosts.

Without this PR, e.g. from main, we get the following error while building an Elastic Agent package on a Windows host:

$ EXTERNAL=true SNAPSHOT=true DEV=true PLATFORMS=windows/amd64 mage package 
...
sh: 1: buildmage-linux-amd64: not found
...

@elasticmachine
Copy link
Contributor

Pinging @elastic/elastic-agent (Team:Elastic-Agent)

@elasticmachine
Copy link
Contributor

elasticmachine commented Aug 29, 2023

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2023-08-29T19:05:15.776+0000

  • Duration: 29 min 50 sec

Test stats 🧪

Test Results
Failed 0
Passed 6217
Skipped 43
Total 6260

💚 Flaky test report

Tests succeeded.

🤖 GitHub comments

Expand to view the GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

  • /package : Generate the packages.

  • run integration tests : Run the Elastic Agent Integration tests.

  • run end-to-end tests : Generate the packages and run the E2E Tests.

  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@elasticmachine
Copy link
Contributor

elasticmachine commented Aug 29, 2023

🌐 Coverage report

Name Metrics % (covered/total) Diff
Packages 98.765% (80/81) 👍
Files 67.368% (192/285) 👍
Classes 66.105% (353/534) 👍
Methods 52.921% (1105/2088) 👍
Lines 38.502% (12601/32728) 👎 -0.054
Conditionals 100.0% (0/0) 💚

Copy link
Member

@aleksmaus aleksmaus left a comment

Choose a reason for hiding this comment

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

I don't have windows dev environment to validate.
This change look ok to me.

@ycombinator ycombinator enabled auto-merge (squash) August 29, 2023 15:06
@ycombinator
Copy link
Contributor Author

CI failures are unrelated to the changes in this PR. @pierrehilbert @cmacknz would you mind force merging this PR?

// buildCmd will be `\`. But the buildCmd is executed inside a Linux Docker
// container. So we replace all `\` path separators with `/`.
if GOOS == "windows" {
buildCmd = strings.ReplaceAll(buildCmd, "\\", "/")
Copy link
Contributor

Choose a reason for hiding this comment

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

would you consider using filepath.ToSlash ? I think if we do that we don't have to have the GOOS == "windows" check. If the os.PathSeparator is / it won't do anything, otherwise it will replace all instances of os.PathSeparator with /.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like it, thanks for the suggestion @leehinman. Changed in 39daec4.

@pierrehilbert
Copy link
Contributor

I let you reply to @leehinman's question and then I will force merge things.

@pierrehilbert
Copy link
Contributor

@leehinman could you review this again please?

Copy link
Contributor

@leehinman leehinman left a comment

Choose a reason for hiding this comment

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

LGTM

@pierrehilbert
Copy link
Contributor

I'm force merging as the failures are not related

@pierrehilbert pierrehilbert merged commit c3dc575 into elastic:main Sep 5, 2023
12 checks passed
@ycombinator ycombinator deleted the fix-crossbuild-windows branch September 11, 2023 16:45
cmacknz pushed a commit to cmacknz/elastic-agent that referenced this pull request Sep 25, 2023
* Fix path separators

* Use filepath.ToSlash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants