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

fix(write_source_files): fix writing to workspace root #53

Merged
merged 1 commit into from
Mar 31, 2022

Conversation

jbedard
Copy link
Collaborator

@jbedard jbedard commented Mar 30, 2022

Currently contains #54, see the second commit.

cmd = "mkdir -p $@ && echo 'test' > $@/test.txt",
visibility = ["//visibility:private"],
)
write_source_files(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@gregmagolan did you actually get your write_dist running as a test? This only failed previously when doing bazel run and not bazel test...

Copy link
Collaborator

Choose a reason for hiding this comment

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

Needs an integration test but I'd prefer to avoid the added complexity of bazel-in-bazel

name = "write_source_file_root-test",
diff_test = False,
files = {"test-out/dist/write_source_file_root-test": ":write_source_file_root"},
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Want to add //visibility:private to this as well?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Shouldn't tests be public?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hm, the angle I was gettting at was whether this should be available to anyone who depends on our repository.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It is private by default unless there is a default_visiblity in the BUILD to set another default

@kormide
Copy link
Collaborator

kormide commented Mar 30, 2022

Nothing actually runs this test, right? I'm wondering if we should just leave it out of WORKSPACE.

@kormide
Copy link
Collaborator

kormide commented Mar 30, 2022

Nothing actually runs this test, right? I'm wondering if we should just leave it out of WORKSPACE.

Or at least call it out as a manual test that ought to be some sort of e2e test.

@jbedard
Copy link
Collaborator Author

jbedard commented Mar 30, 2022

This is the same as what @gregmagolan did in lib/tests/write_source_files:write_dist. I think we should find a way to actually run them in CI...

@kormide
Copy link
Collaborator

kormide commented Mar 30, 2022

This is the same as what @gregmagolan did in lib/tests/write_source_files:write_dist. I think we should find a way to actually run them in CI...

That should be pretty easy to do. Just add another run step in .github/workflows/ci.yaml.

- name: manual integration test
  run: bazel run //:write_source_file_root-test

@@ -266,7 +266,7 @@ def _write_source_file_impl(ctx):
else:
fail("in file %s must be a single file or a target that provides DefaultOutputPathInfo or DirectoryPathInfo" % ctx.attr.in_file.label)

out_path = "/".join([ctx.label.package, ctx.attr.out_file])
out_path = "/".join([ctx.label.package, ctx.attr.out_file]) if len(ctx.label.package) > 0 else ctx.attr.out_file
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe you can shorten this to

out_path = "/".join([ctx.label.package, ctx.attr.out_file]) if ctx.label.package else ctx.attr.out_file

empty string is a falsy in starlark

@jbedard jbedard force-pushed the write-source-root branch 2 times, most recently from 86bc900 to 50b5490 Compare March 30, 2022 23:46
@jbedard jbedard merged commit a2e228d into bazel-contrib:main Mar 31, 2022
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.

3 participants