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

Add bazel build support #43

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

marcosgriselli
Copy link
Contributor

πŸ’¬ Summary of Changes

Add bazel build support

🧾 Checklist

  • 🧐 Performed a self-review of the changes
  • βœ… Added tests to cover changes
  • 🏎 Ran Unit Tests and they all passed
  • 🏷 Labeled this PR appropriately

πŸ“ Items of Note

@iampatbrown
Copy link
Collaborator

Hey @marcosgriselli, thanks for taking the time to submit this pull request. I'm not too familiar with Bazel so I'm not too sure of the implications of this change. I will run it by the team and get back to you.

My only concern is that it might require additional maintenance as the library changes over time. For example, some features that we have been experimenting with depend on files and environment variables created by SPM or Xcode, is it likely that this will work the same in Bazel builds?

@blaknite Have you had much experience with Bazel?

@marcosgriselli
Copy link
Contributor Author

@iampatbrown understandable if this is not a priority. Unfortunately the collector won't work effectively with caching out of the box with Bazel projects since changing the environment variables would break hermetics.

Happy to help in case Bazel support is a feature this library wants to have.

@0xLucasMarcal
Copy link

@marcosgriselli Are you using test collector with Bazel? How did you fixed the broken hermetics?

@blaknite blaknite requested a review from a team March 3, 2024 22:12
@marcosgriselli
Copy link
Contributor Author

@lucasmarcal-faire we took the collection portion of the library, write the outputs to a standard output path and upload via the API at the end of our testing pipeline which includes more than just the bazel invocation.

@gchan gchan requested a review from DechengMa March 5, 2024 00:54
@gchan
Copy link

gchan commented Mar 5, 2024

I asked one of our BK engineers who is more experienced than me on Bazel for feedback on this PR. Here's what they said:

looks like correct bazel to me, and shouldn't impact users not using bazel. my biggest concern would be accidentally breaking it one day - maybe a bazel build should be added to the CI

Does that make sense to you?

cc @DechengMa @thebhumilsoni

Comment on lines +3 to +9
swift_library(
name = "BuildkiteTestCollector",
srcs = glob(["Sources/**/*.swift"]),
module_name = "BuildkiteTestCollector",
visibility = ["//visibility:public"],
deps = [],
)
Copy link
Contributor

@DechengMa DechengMa Apr 8, 2024

Choose a reason for hiding this comment

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

Hi @marcosgriselli, sorry for the late reply, I've made some attempts and encountered some build issues. To address them, I ended up with the following configuration:

Suggested change
swift_library(
name = "BuildkiteTestCollector",
srcs = glob(["Sources/**/*.swift"]),
module_name = "BuildkiteTestCollector",
visibility = ["//visibility:public"],
deps = [],
)
swift_library(
name = "Core",
testonly = True,
srcs = glob(["Sources/Core/**/*.swift"]),
visibility = ["//visibility:public"]
)
swift_library(
name = "BuildkiteTestCollector",
testonly = True,
srcs = glob(["Sources/BuildkiteTestCollector/**/*.swift"]),
deps = [
":Core",
],
)
  • Separating into two modules to resolve a problem where we have two files with the same name.
  • Adding testonly = True, to workaround error: no such module 'XCTest'

Would love your thoughts on this code, much appreciated! πŸ™

Furthermore, I'm curious about the contents of the WORKSPACE file. Given the code you've provided, it's currently empty. Should it include the workspace snippet we could copy from the release? Or, since this is a library, should it be left to the consumer to figure out?

Choose a reason for hiding this comment

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

SGTM! testonly is really necessary because it adds XCTest to search paths.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This change looks good imo. Although this point is still valid in a bazel setup, expecting environment variables that change with every commit will break hermeticity, so extracting the uploading to a post bazel action might be the best course for folks with this setup.
The empty WORKSPACE file is actually expected by bazel to define the root of the project.

Copy link
Contributor

Choose a reason for hiding this comment

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

Make sense πŸ‘ , just to understand it clearly, so #49 would still be essential for supporting Bazel, and this PR is just make it support the Bazel building process?

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

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

Successfully merging this pull request may close these issues.

5 participants