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

How to make this work with npm ci? #156

Open
Stupidism opened this issue May 25, 2018 · 8 comments
Open

How to make this work with npm ci? #156

Stupidism opened this issue May 25, 2018 · 8 comments

Comments

@Stupidism
Copy link

Stupidism commented May 25, 2018

I tried in travis and circleci:

install:
  - npm i -g npm@6
  - npm ci

# greenkeeper update npm lockfile
before_install:
  - npm install -g greenkeeper-lockfile@1
  - greenkeeper-lockfile-update
after_success:
  - greenkeeper-lockfile-upload
  - bash <(curl -s https://codecov.io/bash)
      - run:
          name: Install greenkeeper-lockfile
          command: npm i greenkeeper-lockfile@1
      - run:
          name: Update lock file
          command: ./node_modules/.bin/greenkeeper-lockfile-update
      - run:
          name: Install dependencies in ci mode
          command: npm ci
# Prevent to upload lockfile twice, because travis will upload, too.
#      - run:
#          name: Upload new lock file
#          command: ./node_modules/.bin/greenkeeper-lockfile-upload

But it always complains:

This build should not update the lockfile. It could be a PR, not a branch build.

ci scripts: travis
circleci

ci results: travis
circleci

@freaktechnik
Copy link

It seems travis now defaults to npm ci, which means this is much more often a problem.

Traivs CI run: https://travis-ci.org/freaktechnik/github-stub/builds/386634973
.travis.yml: https://github.com/freaktechnik/github-stub/blob/67273161087b04074aa829be1f134dd52088f2ee/.travis.yml

@daffl
Copy link

daffl commented Jun 2, 2018

It looks like this will be happening now for all new Greenkeeper PRs with a breaking version change that run on the latest Node. It can be solved by reverting the default script in your .travis.yml to

install: npm install

I ended up getting the same error message as @Stupidism setting up greenkeeper-lockfile and digging into the code a little, I'm wondering if the travis.correctBuild flag at https://github.com/greenkeeperio/greenkeeper-lockfile/blob/master/ci-services/travis.js#L14 should really check if it is a Greenkeeper PR branch.

That's what seems to be happening for some other CI services already (e.g. for Codeship at https://github.com/greenkeeperio/greenkeeper-lockfile/blob/master/ci-services/codeship.js#L33).

@espy
Copy link
Contributor

espy commented Jun 3, 2018

Hi @daffl , thanks for jumping in here, that is indeed the way to go for now 👍

We’ve got the problem on our list and will deal with it within the monorepo PR for gk-lockfile that we’re currently working on.

sneakypete81 added a commit to sneakypete81/updatescanner that referenced this issue Jun 4, 2018
lholmquist added a commit to lholmquist/openshift-config-loader that referenced this issue Jun 4, 2018
lholmquist added a commit to nodeshift-archived/openshift-config-loader that referenced this issue Jun 4, 2018
sneakypete81 added a commit to sneakypete81/updatescanner that referenced this issue Jun 4, 2018
@BerkeleyTrue
Copy link

I've created a script that will conditionally use npm install/npm ci on travis ci depending on whether the branch is a greenkeeper branch.

A gist including travis config example. https://gist.github.com/BerkeleyTrue/ff98c0aa27c21e1616f6bf910f444aee

@freaktechnik
Copy link

install: case $TRAVIS_BRANCH in greenkeeper*) npm i;; *) npm ci;; esac; is a one-liner to make the same choice as the script by @BerkeleyTrue directly in the .travis.yml.

palashmon added a commit to siddharthkp/bundlesize that referenced this issue Jul 8, 2018
This fixes the issue where greenkeeper ci build was failing due to `npm ci`

Ref: greenkeeperio/greenkeeper-lockfile#156
busterc added a commit to busterc/crwlr that referenced this issue Aug 25, 2018
Evidently, travis using `npm ci` doesn't like greenkeeper not sticking to the package-lock.json.

^ This was suggested from: greenkeeperio/greenkeeper-lockfile#156 (comment)
busterc added a commit to busterc/crwlr that referenced this issue Aug 25, 2018
busterc added a commit to busterc/mixed-content-crawler that referenced this issue Aug 25, 2018
mamodom added a commit to mamodom/package-json-dependencies-navigation that referenced this issue Nov 17, 2018
cmfcmf added a commit to hpi-schul-cloud/gamification that referenced this issue Dec 2, 2018
StefanSchoof pushed a commit to StefanSchoof/espresso that referenced this issue Dec 3, 2018
greenkeeper does not work with npm ci, see greenkeeperio/greenkeeper-lockfile#156
nokome added a commit to stencila/dockta that referenced this issue Dec 3, 2018
janrenz pushed a commit to hpi-schul-cloud/gamification that referenced this issue Dec 4, 2018
@karolis-sh
Copy link

For node 9 I had to add:

before_install:
  - if [[ `npm -v` != 6* ]]; then npm install -g npm@6; fi

So the full'ish script:

node_js:
  - '10'
  - '9'
  - '8'
before_install:
  - if [[ `npm -v` != 6* ]]; then npm install -g npm@6; fi
install: case $TRAVIS_BRANCH in greenkeeper*) npm i;; *) npm ci;; esac;

@idolize
Copy link

idolize commented Dec 10, 2019

Any update as to when we can expect a more official fix? Thanks!

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

No branches or pull requests

7 participants