Nx: Lint broken with latest version on our CI

Created on 7 Nov 2019  路  8Comments  路  Source: nrwl/nx

Expected Behavior

Lint running well

Current Behavior

Lint breaks

Failure Information (for bugs)

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.

Steps to Reproduce

nx affected:lint --parallel --all --maxParallel 4

Context

  • nx v8.7.0
  • gitlab CI
  • works well with nx v8.6.0

Failure Logs

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.
more info needed bug

Most helpful comment

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.

All 8 comments

@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.

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"
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

danieldanielecki picture danieldanielecki  路  3Comments

Koslun picture Koslun  路  3Comments

zpydee picture zpydee  路  3Comments

jon301 picture jon301  路  3Comments

IonFoXx picture IonFoXx  路  3Comments