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

Support build of projects outside of beats directory #36126

Merged
merged 3 commits into from
Jul 20, 2023

Conversation

jeniawhite
Copy link
Contributor

@jeniawhite jeniawhite commented Jul 20, 2023

What does this PR do?

There are beats that aren't part of the beats repository code-base.
Cloudbeat for example:

When calling the mage package that is based on the beats mage flows we are getting a failure:

Found Elastic Beats dir at /go/pkg/mod/github.com/elastic/beats/v7@v7.0.0-alpha2.0.20230718065235-46adbacfb5a8
exec: git "config" "--global" "--add" "safe.directory" "/go/pkg/mod/github.com/elastic/beats/v7@v7.0.0-alpha2.0.20230718065235-46adbacfb5a8"
>> build: Building cloudbeat-linux-amd64
exec: git "rev-parse" "HEAD"
fatal: detected dubious ownership in repository at '/go/src/github.com/elastic/cloudbeat'
To add an exception for this directory, call:
	git config --global --add safe.directory /go/src/github.com/elastic/cloudbeat
>>> Fixing file ownership issues from Docker at path=build/golang-crossbuild
chown took: 58.803µs, changed 1 files
>>> Fixing file ownership issues from Docker at path=build/golang-crossbuild/cloudbeat-linux-amd64
chown took: 13.401µs, changed 0 files
lstat build/golang-crossbuild/cloudbeat-linux-amd64: no such file or directory
Error: failed to expand template '-X github.com/elastic/beats/v7/libbeat/version.commit={{ commit }} -X github.com/elastic/beats/v7/libbeat/version.buildTime={{ date }}': template: inline:1:57: executing "inline" at <commit>: error calling commit: running "git rev-parse HEAD" failed with exit code 128
Error: failed building for linux/amd64: exit status 1
failed building for linux/amd64: exit status 1

I've investigated the code and saw that the safe.directory only triggers for beats directory:

	mountPoint, err := ElasticBeatsDir()
	if err != nil {
		return err
	}
	if err := sh.Run("git", "config", "--global", "--add", "safe.directory", mountPoint); err != nil {
		return err
	}

I've added the root path of the project as well.

Why is it important?

In order to support the building and packaging of beats that aren't part of the beats repository.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

@jeniawhite jeniawhite added enhancement backport-skip Skip notification from the automated backport with mergify labels Jul 20, 2023
@jeniawhite jeniawhite requested a review from a team as a code owner July 20, 2023 10:57
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Jul 20, 2023
@botelastic
Copy link

botelastic bot commented Jul 20, 2023

This pull request doesn't have a Team:<team> label.

@elasticmachine
Copy link
Collaborator

elasticmachine commented Jul 20, 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-07-20T11:02:47.831+0000

  • Duration: 71 min 0 sec

Test stats 🧪

Test Results
Failed 0
Passed 27533
Skipped 2029
Total 29562

💚 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 and run the E2E tests.

  • /beats-tester : Run the installation tests with beats-tester.

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

Copy link
Collaborator

@jlind23 jlind23 left a comment

Choose a reason for hiding this comment

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

LGTM

@jeniawhite jeniawhite enabled auto-merge (squash) July 20, 2023 12:08
@jeniawhite jeniawhite merged commit 8a9d6f6 into elastic:main Jul 20, 2023
Copy link
Contributor

@michalpristas michalpristas left a comment

Choose a reason for hiding this comment

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

tested this, from my point of view it looks ok

Scholar-Li pushed a commit to Scholar-Li/beats that referenced this pull request Feb 5, 2024
* Add project dir

* Remove comments

* Add changelog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-skip Skip notification from the automated backport with mergify enhancement needs_team Indicates that the issue/PR needs a Team:* label
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants