facebook / buck2

Build system, successor to Buck
https://buck2.build/
Apache License 2.0
3.35k stars 195 forks source link

Read output of `actions.run` from BXL #572

Closed cbarrete closed 3 months ago

cbarrete commented 3 months ago

Is there a way to read the output of a command (or even an arbitrary file tracked by buck2) into BXL? I'd like to somehow get a string back that I could further process.

In case this is an XY problem, my use case is that I want to run the tests for the files touched in the current commit (for CI purposes). I intended to iterate over the output of git diff-tree -r --name-only --no-commit-id HEAD, find the owners of those files and build/test them, but I cannot figure out a way of getting the file names into BXL, either via stdout or a declared output that I dumped the output of git into.

Thanks!

stepancheg commented 3 months ago

Is there a good reason to do it in BXL?

For CI purpose it looks more reasonable to find the files with git, then find file owners with buck2 cquery or something, and then build.

BXL is quite power tool, but it cannot replace everything.

(I think what you ask is not easily possible, but I can be wrong, and this feature could be added to buck2).

Also check https://github.com/facebookincubator/buck2-change-detector project. CC @ndmitchell

cbarrete commented 3 months ago

It doesn't have to be I suppose, but I figured that getting the right targets to build and/or test afterwards would be easier from BXL.

That link is a 404 for me, but it sounds interesting, is it private?

stepancheg commented 3 months ago

Sorry, the project is not published yet.

getting the right targets to build and/or test afterwards would be easier from BXL

Also, consider this issue: if build fails, and users want to reproduce it, it would be easier for them if there was buck2 build or buck2 test command in CI logs which users could just copy-paste.

Anyway, BXL cannot do it now easily, but may be able to do it one day if there's demand for it.

cbarrete commented 3 months ago

Sorry, the project is not published yet.

That's too bad, do you know if there are plans to publish it? More out of curiosity really, I'm going to get this working on our side now either way.

Also, consider this issue: if build fails, and users want to reproduce it, it would be easier for them if there was buck2 build or buck2 test command in CI logs which users could just copy-paste.

That's a good point.

Anyway, BXL cannot do it now easily, but may be able to do it one day if there's demand for it.

Thanks for the clarification!

stepancheg commented 3 months ago

@cbarrete buck2-change-detector is public now.

cbarrete commented 3 months ago

Thanks for letting me know!