e-square-io / nx-github-actions

A set of Github Actions for NX workspaces
MIT License
30 stars 6 forks source link

Improve Artifact Upload documentation #50

Closed tfohlmeister closed 2 years ago

tfohlmeister commented 2 years ago

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[ ] Feature request
[X] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:

Current behavior

It is unclear to me how artifact upload works. If I use the default setup as described in the examples I can see the action searching for files in folder /coverage. I don't see a way to configure this path to e.g. /dist. The code seems to use a glob variable but I have no idea how to set it.

Expected behavior

Add documentation and/or examples on how to configure artifact paths

Minimal reproduction of the problem with instructions

Run a github action with the config provided as part of the README.

What is the motivation / use case for changing the behavior?

Since artifact upload is a feature of this action, I think it should be made a bit clearer on how to configure it.

Environment


- Nx version: 13.8.7 
- Node version: 16  
- Platform: Mac 

Others:

ronnetzer commented 2 years ago

Hi @tfohlmeister

Did you read the README of 'nx-distributed-task'?

There's a bit more explanation over there about uploading the artifacts but I do agree that we should add more details on how the paths to upload are retrieved.

The 'uploadOutputs' is a Boolean input, which means you can only turn it off or on, there is no other configuration.

The paths to upload are being retrieved and constructed automatically by NX, and they're taken directly from the 'outputs' array in the target's configuration. Normally for tests, nx has a default configuration with an output set to the coverage dir and that's why you see it searching for it to upload as artifact.

If you take a look at any job that runs the build target, you should see that it will try to upload 'dist/path/to/project' (as defined in the outputs of the build configuration of that project)

tfohlmeister commented 2 years ago

Thanks for clarifiying. I was thinking about Github Action Outputs and had no idea this is about the outputPath of nx. Makes sense then!

Is there any way to define dependencies between the targets? E.g. only run build if test and e2e were sucessfull? Or would I need to run nx-affected-matrix and nx-distributed-task twice?

ronnetzer commented 2 years ago

Unfortunately, it's impossible to have job that depends on another job in the same matrix. So in this case you're forced to run nx-affected-matrix twice (which is super fast in any case and doesn't require any previous steps in order to run), and have 2 nx-distributed-task matrix jobs: one for test and e2e and the other for build which has the first matrix in its needs array. Note that the entire build matrix wont run when one of the tests/e2e fails, this is why I think its better to let them all run together and if one failed the next jobs wont run anyway. in case you want the next jobs to run although one of the matrix jobs failed, you can use the artifacts in the next jobs, you can download all the artifacts & if you don't have a build directory you know the build failed, same goes for test & e2e.

btw it might be supported in the new version of the actions #18

tfohlmeister commented 2 years ago

Cool, thank you very much!