greenkeeperio / greenkeeper-lockfile

:lock: Your lockfile, up to date, all the time
https://greenkeeper.io
183 stars 73 forks source link

Sample CircleCI config #90

Open mwickett opened 6 years ago

mwickett commented 6 years ago

Hey all, I'm new to CI config, and feeling a bit lost around getting this working with CircleCI. Would someone be willing to share an example of a basic CircleCI config file?

Really appreciate it!

hardchor commented 6 years ago

https://github.com/hardchor/electron-redux/blob/master/.circleci/config.yml there you go mate

bennycode commented 6 years ago

@hardchor Thanks for referencing your CircleCI configuration. From your configuration I can see that it runs greenkeeper-lockfile-update and greenkeeper-lockfile-upload but doesn't it also need to run yarn global add greenkeeper-lockfile@1 first?

I tried to get greenkeeper-lockfile running with CircleCI v2 but it always tells me Command "greenkeeper-lockfile-update" not found. I was able to find a configuration for CircleCI v1 but that doesn't help me much.

In the Greenkeeper documentation it's mentioned to use a lockfile job but how should such a job look like? Maybe @ethanrubio can help here?

This is my current configuration (which doesn't work yet):

version: 2
jobs:
  build:
    # https://circleci.com/docs/2.0/circleci-images/#nodejs
    docker:
      - image: circleci/node:latest
    # https://circleci.com/docs/2.0/configuration-reference/#steps
    steps:
      - checkout
      - restore_cache:
          keys:
          - v1-dependencies-{{ checksum "package.json" }}
      - run: yarn global add greenkeeper-lockfile@1
      - run: yarn greenkeeper-lockfile-update
      - run: yarn install
      - save_cache:
          paths:
            - node_modules
          key: v1-dependencies-{{ checksum "package.json" }}
      - run: yarn test
      - run: yarn greenkeeper-lockfile-upload

!/bin/bash -eo pipefail

yarn greenkeeper-lockfile-update yarn run v1.3.2 error Command "greenkeeper-lockfile-update" not found. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. Exited with code 1

hardchor commented 6 years ago

I've installed greenkeeper-lockfile locally (https://github.com/hardchor/electron-redux/blob/master/packages/electron-redux/package.json#L39), but globally will work just as well. You're running it as a yarn command (yarn greenkeeper-lockfile-update as opposed to just greenkeeper-lockfile-update), and yarn gets confused, because that command doesn't show up in your package.json. Just remove the yarn and you should be good to go.

bennycode commented 6 years ago

I got it working! Thank you so much @hardchor!

Here is my running configuration:

version: 2
jobs:
  build:
    # https://circleci.com/docs/2.0/circleci-images/#nodejs
    docker:
      - image: node:8.0
    # https://circleci.com/docs/2.0/configuration-reference/#steps
    steps:
      - run:
          name: "Checking Versions"
          command: |
            node --version
            npm --version
      - checkout
      - restore_cache:
          keys:
          - v1-dependencies-{{ checksum "package.json" }}
      - run: yarn global add greenkeeper-lockfile@1
      - run: yarn install
      - run: greenkeeper-lockfile-update
      - save_cache:
          paths:
            - node_modules
          key: v1-dependencies-{{ checksum "package.json" }}
      - run: yarn test
      - run: greenkeeper-lockfile-upload
pkyeck commented 6 years ago

can someone post an example using workflows? that would be great. thanks

keimlink commented 6 years ago

@pkyeck @bennyn I'm using CircleCI 2.0 workflows with greenkeeper-lockfile in keimlink/docker-sphinx-doc. Unfortunately it doesn't work completey so far. I have reported the problem in #100.

KagamiChan commented 6 years ago

I'm using CircleCI 2.0 and find that yarn's global bin path is not included in $PATH env for the image I choose (circleci/node:9). If anyone is told Command "greenkeeper-lockfile-update" not found even with yarn global add, it might be the case.

Solution:

      - run:
          name: prepare greenkeeper-lockfile
          command: |
            echo 'export PATH=$(yarn global bin):$PATH' >> $BASH_ENV
            source $BASH_ENV
            yarn global add greenkeeper-lockfile@1