Closed tamascsaba closed 2 years ago
@robinpellegrims and @ronnetzer thank you very much your response in advance 👍
Hi @tamascsaba,
Thank you for reporting the issue,
NX_WORKSPACE_ROOT_PATH
you get a different error?I'm having the same issue after converting all projects to use separate project.json files instead of the global workspace.json. Might be related to this library still using nx v13? Can we update the nx packages to v14?
Sorry for the late response, but I haven't had time to create an example repository, but maybe I can give you a general description of our project.
"version": 2,
format with lot of buildable libraries and several apps, the main project file is the angular.json
NX_WORKSPACE_ROOT_PATH
I got an error about missing nx.json
file.@robinpellegrims Thanks for reporting,
I have several projects with the new project.json
files format that works just fine with NX 14 so I'm not sure this is the problem.
In order to proceed I'll need some minimal reproduction of this issue
@tamascsaba Regarding your 2nd point, do you mind opening it in a separate issue? its unrelated to this one
I created a minimal reproduction repository here.
It's a fresh nx repository created using npx create-nx-workspace@latest
with the angular-nest
preset. Afterwards I copied the default e-square-io/nx-affected-matrix
workflow configuration from the README.
I hope this helps, let me know if you need anything else.
I opened a separate issue: https://github.com/e-square-io/nx-github-actions/issues/56 as well.
I am having this exact issue with a react-native monorepo that has 9 apps already in place. I have been trying to understand what I'm missing. What's the process that this action goes through to determine the affected matrix?
@robinpellegrims @ronnetzer Repro-Repo here: https://github.com/jason-edstrom/nx-affected-bug-repo
Apparently this is something in NX, https://github.com/nrwl/nx/issues/8968 it was probably fixed in NX 14 but since the actions use 13 and the workspace was generated by 14 we get this error.
as a workaround, please add root
property to each project's project.json
(don't rely on the generators to create it for you)
you can check this fixed minimal reproduction https://github.com/ronnetzer/nx-github-actions-error (cloned from @robinpellegrims's repro)
Please let me know if this fixed is not working for you @jason-edstrom @tamascsaba @robinpellegrims
I have more than 200 project.json
in my project, so if it easier to update this action to version 14 please let me know.
@tamascsaba This is something that can be managed with a simple search & replace, in any case updating to 14 will take time and I can't guarantee that it will be started anytime soon.
Also, there are some issues that block the update, the biggest one is migrating back from github-script action to standalone shell scripts, after that I'll need to do some cleanup of NX internal code I had to overwrite in order to use it in github-script.
I will probably have more time to get into this update after the holidays season in Israel (around November)
@ronnetzer thank you very much your informations. I really appreciate your quick feedback 👍
For those who don't want to deal with the root
attribute, I've done a script which add it automatically so your repo can stay clean on latest NX versions.
setup:
runs-on: ubuntu-latest
name: Affected Matrix
outputs:
hasChanges: ${{ steps.affected.outputs.hasChanges }}
matrix: ${{ steps.affected.outputs.matrix }}
steps:
- name: ⬇️ Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: fix https://github.com/e-square-io/nx-github-actions/issues/53
run: >
addRoot() {
ROOT_PATH=$(dirname "$1")
PROJECT_CONTENT=$(jq ". + {root: \"${ROOT_PATH}\"}" < "$1")
echo "$PROJECT_CONTENT" > "$1"
};
find apps -name project.json | while read file; do addRoot "$file"; done;
find libs -name project.json | while read file; do addRoot "$file"; done;
find tools -name project.json | while read file; do addRoot "$file"; done;
shell: bash
- name: Calculate affected projects
uses: e-square-io/nx-affected-matrix@v2
id: affected
with:
targets: 'lint,test,build'
maxDistribution: 3
checkout: false
Current behavior
Affected matrix generation fail with:
Minimal reproduction of the problem with instructions
I had to add
NX_WORKSPACE_ROOT_PATH
, becauseworkingDirectory
is not working. My configuration looks like:I am using nx
14.4.2
with version 2 projects format.