nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.65k stars 2.36k forks source link

nx:noop executor fails the task with "not found in schema" when given arguments #18312

Closed richard-ling closed 6 months ago

richard-ling commented 1 year ago

Current Behavior

We sometimes use nx:noop executor where a target doesn't make sense for a particular package. For example, in a docs package which contains no code, the test target uses nx:noop executor. All other packages use @nrwl/jest:jest.

However if we do nx affected --target=test --base=master --onlyChanged, and docs is affected, it will run nx test docs --onlyChanged and the noop executor will fail the task with this message:

> [ NX ] 'onlyChanged' is not found in schema

This is because the schema for noop executor doesn't accept any arguments, but it makes the above use case impossible.

Expected Behavior

The nx:noop executor should ignore the arguments and the task should succeed.

GitHub Repo

https://github.com/nrwl/nx-examples

Steps to Reproduce

Should be self-explanatory.

Nx Report

Node : 16.14.0
   OS   : darwin x64
   yarn : 1.22.19

   nx : 15.2.0
   @nrwl/angular : Not Found
   @nrwl/cypress : 15.2.0
   @nrwl/detox : Not Found
   @nrwl/devkit : 15.2.0
   @nrwl/esbuild : Not Found
   @nrwl/eslint-plugin-nx : 15.2.0
   @nrwl/expo : Not Found
   @nrwl/express : Not Found
   @nrwl/jest : 15.2.0
   @nrwl/js : 15.2.0
   @nrwl/linter : 15.2.0
   @nrwl/nest : Not Found
   @nrwl/next : Not Found
   @nrwl/node : Not Found
   @nrwl/nx-cloud : 15.0.2
   @nrwl/nx-plugin : Not Found
   @nrwl/react : 15.2.0
   @nrwl/react-native : Not Found
   @nrwl/rollup : 15.2.0
   @nrwl/schematics : Not Found
   @nrwl/storybook : 15.2.0
   @nrwl/web : 14.6.5
   @nrwl/webpack : 15.2.0
   @nrwl/workspace : 15.2.0
   typescript : 4.3.5
   ---------------------------------------
   Local workspace plugins:
   ---------------------------------------
   Community plugins:

Failure Logs

No response

Operating System

Additional Information

Are we misusing nx:noop here? This seems like a perfect use-case for it - we can't imagine any other use for it.

NexZhu commented 11 months ago

Similar use case when lint targets just need to call eslint and stylelint, want to be able to pass the --fix argument:

    lint: {
      inputs: [...inputsIgnore],
      dependsOn: [
        // To pass `--fix`
        { project: 'self', target: 'eslint', params: 'forward' },
        { project: 'self', target: 'stylelint', params: 'forward' }
      ],
    },
    eslint: {
      executor: 'nx:run-commands',
      options: {
        command: 'FIX={args.fix}; echo eslint --fix=${FIX:-false}',
      },
    },
    stylelint: {
      executor: 'nx:run-commands',
      options: {
        command: 'FIX={args.fix}; echo stylelint --fix=${FIX:-false}',
      },
    },

nx run web:eslint --fix and nx run web:stylelint --fix both work

but nx run web:lint --fix will complain 'fix' is not found in schema

FrozenPandaz commented 6 months ago

This was fixed with https://github.com/nrwl/nx/commit/8a0707df86217f8ec1aa94b529ac9f2eeb136e15 :tada:

github-actions[bot] commented 5 months ago

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.