Lint running well
Lint breaks
After upgrading to v8.7.0 from v8.6.0 lint breaks with the following error message on our CI:
Error: Command failed: git merge-base master HEAD
fatal: Not a valid object name master
command:
$ npm run lint
> nx workspace-lint && nx affected:lint --parallel --all --maxParallel 4
Runs well locally.
Runs well on CI with v8.6.0.
nx affected:lint --parallel --all --maxParallel 4
Error: Command failed: git merge-base master HEAD
fatal: Not a valid object name master
at checkExecSyncError (child_process.js:629:11)
at Object.execSync (child_process.js:666:13)
at getFilesUsingBaseAndHead (/builds/[repo]/node_modules/@nrwl/workspace/src/command-line/shared.js:108:39)
at Object.parseFiles (/builds/[repo]/node_modules/@nrwl/workspace/src/command-line/shared.js:93:20)
at Object.affected (/builds/[repo]/node_modules/@nrwl/workspace/src/command-line/affected.js:16:35)
at Object.exports.commandsObject.yargs.usage.command.command.command.command.command.command.command.command.command.command.command.args [as handler] (/builds/[repo]/node_modules/@nrwl/workspace/src/command-line/nx-commands.js:66:138)
at Object.runCommand (/builds/[repo]/node_modules/@nrwl/workspace/node_modules/yargs/lib/command.js:235:44)
at Object.parseArgs [as _parseArgs] (/builds/[repo]/node_modules/@nrwl/workspace/node_modules/yargs/yargs.js:1022:30)
at Object.get [as argv] (/builds/[repo]/node_modules/@nrwl/workspace/node_modules/yargs/yargs.js:965:21)
at Object.<anonymous> (/builds/[repo]/node_modules/@nrwl/cli/bin/nx.js:38:26)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [repo]@1.0.0 lint: `nx workspace-lint && nx affected:lint --parallel --all --maxParallel 4`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [repo]@1.0.0 lint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
@merobal can you reproduce this within a small repo?
I am also seeing this (on all affected:* commands), but on a gitlab runner. Do you need someone to create a repro with a gitlab runner?
Yes, that would help
Checking in to report the same issue. We do not work with a master branch and therefore after the update from NX to 8.7.0 all the commands with --all are broken.
It seems it's fixed in v8.8.x by https://github.com/nrwl/nx/pull/2000, related: https://github.com/nrwl/nx/issues/1988
When using Merge Requests on GitLab CI git merge-base master HEAD won't work on the runners. You'll need to run git fetch origin before anything else.
@bboehm86 I did call git fetch origin, however, I still seem to get this issue.
Were you able to fix the same?
I can confirm that git fetch origin helps on Gitlab CI.
.gitlab-ci.yml:
image: node:lts
before_script:
- yarn install
- git fetch origin
stages:
- lint
Linters:
stage: lint
script:
- yarn lint
package.json:
"scripts": {
"lint": "nx affected --target=lint --base=remotes/origin/master --parallel"
}
Most helpful comment
When using Merge Requests on GitLab CI
git merge-base master HEADwon't work on the runners. You'll need to rungit fetch originbefore anything else.