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

npx nx-ignore <app> not working on Vercel Build #86

Open
seloner opened this issue Jul 8, 2022 · 8 comments
Open

npx nx-ignore <app> not working on Vercel Build #86

seloner opened this issue Jul 8, 2022 · 8 comments
Assignees

Comments

@seloner
Copy link

seloner commented Jul 8, 2022

Current Behavior

I make a change to a shared library our nx environment. The app with name connector uses that shared library. Locally npx nx-ignore connector returns that the build can proceed.

I commit my code to Gitlab and then Vercel starts to automatically build. I added in npx nx-ignore connector in the Vercel settings. However, when this script is triggered in the Vercel build it skips over it and says "The Deployment has been canceled as a result of running the command defined in the "Ignored Build Step" setting

Expected Behavior

I expect it to build because that app was affected as I could see that it was affected locally.

Environment

nx : 14.3.6
@nrwl/angular : Not Found
@nrwl/cypress : 14.3.6
@nrwl/detox : Not Found
@nrwl/devkit : 14.3.6
@nrwl/eslint-plugin-nx : 14.3.6
@nrwl/express : Not Found
@nrwl/jest : 14.3.6
@nrwl/js : 14.3.6
@nrwl/linter : 14.3.6
@nrwl/nest : Not Found
@nrwl/next : 14.3.6
@nrwl/node : 14.3.6
@nrwl/nx-cloud : Not Found
@nrwl/nx-plugin : Not Found
@nrwl/react : 14.3.6
@nrwl/react-native : Not Found
@nrwl/schematics : Not Found
@nrwl/storybook : 14.3.6
@nrwl/web : 14.3.6
@nrwl/workspace : 14.3.6
typescript : 4.7.4

Community plugins:
@jscutlery/semver: 2.23.4

@AgentEnder AgentEnder transferred this issue from nrwl/nx Jul 8, 2022
@theresasogunle
Copy link

I can confirm I am also experiencing this issue.

@hophuochoanggia
Copy link

I am also experience the same issue. There are two different errors on 2 different projects.

  • 1st one having trouble to compare the commit to the ref on main branch
  • 2nd one cancelled the build as it determines that the merge not affecting the project

@seloner
Copy link
Author

seloner commented Sep 6, 2022

I believe the issue it which root folder you choose. If you choose the root folder of the monorepo in the project of vercel as root it works. But in a vercel project you can choose as root folder a subfolder . So the npx nx-ignore is running in the subfolder instead in top level.

@sigginjals
Copy link

sigginjals commented Oct 6, 2022

I'm only seeing builds showing a false positive. They should be deployed due to a change but aren't.
One reason could be that the project in question is labeled as a "library" but has a storybook deployment attached to it.
This used to work, so not sure what changed.
Edit
Perhaps this line?

@jeniabrook
Copy link

I'm also having this problem.
I have a monorepo with Nx and 2 apps are deployed via Vercel.

I've added npx nx-ignore [app-name] to each app and when I'm changing one of them (for instance 'backoffice' app) and push the code to branch I get this error message:

[14:14:40.471] Cloning github.com/jeniabrook/nx-monorepo-poc (Branch: update-shop-app, Commit: d2c701d)
[14:14:40.790] Cloning completed: 318.332ms
[14:14:40.790] Running "npx nx-ignore backoffice --verbose"
[14:15:02.147] ≫ Using Nx to determine if this project (backoffice) is affected by the commit...
[14:15:02.147] ≫ Running from /vercel/.npm/_npx/258/lib/node_modules/nx-ignore/src
[14:15:02.148] 
[14:15:02.148] ≫ Validating base ref: af43bb12b0c659dcb710818588c4360c8d09d692
[14:15:02.148] 
[14:15:02.152] fatal: bad object af43bb12b0c659dcb710818588c4360c8d09d692
[14:15:02.152] 
[14:15:02.152] ≫ Invalid base ref passed: af43bb12b0c659dcb710818588c4360c8d09d692. Defaulting to HEAD^.
[14:15:02.152] 
[14:15:02.152] 
[14:15:02.152] ≫ Comparing HEAD^...HEAD
[14:15:02.153] 
[14:15:02.261] ≫ Affected projects:
[14:15:02.261] 
[14:15:02.261] 🛑 - Build cancelled since backoffice is not affected
[14:15:03.009] The Deployment has been canceled as a result of running the command defined in the "Ignored Build Step" setting.

As @seloner mentioned, I have subfolders for the apps, this is how Vercel is working with monorepos.

For instance:
Screen Shot 2022-11-28 at 14 33 24

Anyone found a solution for it ?

@seloner
Copy link
Author

seloner commented Nov 28, 2022

Try to cd out in the root folder when running npx nx-ignore .
The issue is that you need to run the command in the root folder but because the setup of subfolders the command runs in the sub folder .

@jeniabrook
Copy link

@seloner I've tried the following: cd ../.. && npx nx-ignore backoffice.
Monorepo structure:

root
   |
   |---apps
           |
           |---backoffice
           |
   |---packages

Maybe the the command that I'm using is not correct.

@jaredh159
Copy link

jaredh159 commented Dec 8, 2023

fwiw, i think i fixed this problem by manually specifying the workspace root, which for some reason nx-ignore was not figuring out, like so:

npx nx-ignore --root="$(dirname $(dirname $PWD))" --verbose @friends-library/evans

the double dirname is to go up two levels (from where my app was). you could also try hardcoding /vercel/path0 as the root

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

No branches or pull requests

7 participants