Late migrating to Circle 2.0 and having trouble

Hi everyone,

So I had some time off and came back realizing the migration from 1.0 to 2.0 I’d put off for months couldn’t be put off anymore. Now I’m trying to do the migration and I’m encountering some issues.

machine:
  node:
version: 8.*
dependencies:
  pre:
- sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
- echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list
- sudo apt-get update
- sudo apt-get install -y mongodb-org=3.0.6 mongodb-org-server=3.0.6 mongodb-org-shell=3.0.6 mongodb-org-mongos=3.0.6 mongodb-org-tools=3.0.6
- nvm install 8
- nvm use 8 && nvm alias default 8
- npm install jest
- npm install react 16
- npm install react-dom 16
- npm install @babel/core
- npm install @babel/preset-env
- npm install webpack
- npm install webpack-cli
test:
  override:
- npm test -- --coverage
  post:
- npm install -g codeclimate-test-reporter
deployment:
production:
  branch: master
  commands:
    - git push --force git@heroku.com:$HEROKU_APP_NAME $CIRCLE_SHA1:master

Now I know I’m doing something wrong here but the new version I have written up is:

version: 2
jobs:
  build:
    docker:
      - image: buildpack-deps:trusty
      - image: circleci/node:chakracore-8
    steps:
      - checkout
      - run:
          name: Setup Environments
          command: |
            sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
            echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list
            sudo apt-get update
            sudo apt-get install -y mongodb-org=3.0.6 mongodb-org-server=3.0.6 mongodb-org-shell=3.0.6 mongodb-org-mongos=3.0.6 mongodb-org-tools=3.0.6
            nvm install 8.*
            nvm use 8.* && nvm alias default 8.*
            npm install jest
            npm install react 16
            npm install react-dom 16
            npm install @babel/core
            npm install @babel/preset-env
            npm install webpack
            npm install webpack-cli
            npm install -g codeclimate-test-reporter
      - run:
          name: Run Tests and Coverages
          command: |
            ./cc-test-reporter before-build
            npm test -- --coverage
            ./cc-test-reporter after-build --exit-code $?
      - run:
          name: Deploy Master to heroku
          command: |
            git push https://heroku:$HEROKU_API_KEY@git.heroku.com/$HEROKU_APP_NAME.git master
workflows:
  version: 2
  build-deploy:
    jobs:
      - build
      - deploy:
          requires:
            - build
          filters:
            branches:
              only: master

When I run this, it runs to an npm install and fails it seems to be installing the dependencies with node 4.6.2 which is weird since the build image is using 8? I’m very confused. Any help would be hugely appreciated

I don’t use NPM, but thought I’d point this out, in case it is the cause of your issue. I see your nvm commands mention 8.* so perhaps I am just not clear on what you are expecting of these two images.

The first of these two images is your build environment, so all your commands are run in a container produced from that image. The second is spun up and becomes a service that you can use over HTTP or TCP - this is often used for key-value stores, databases, web servers, etc. So, I am wondering, is there some Node stuff in the second image you are expecting to be available?

Hmm that could be it! I’ll give that a go. Thanks!

Alright so now we’re at the point where this is the build:

version: 2
jobs:
  build:
    docker:
      - image: buildpack-deps:trusty
    steps:
      - checkout
      - run:
          name: Setup Mongo Environments
          command: |
            sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
            echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list
            sudo apt-get update
            sudo apt-get install -y mongodb-org=3.0.6 mongodb-org-server=3.0.6 mongodb-org-shell=3.0.6 mongodb-org-mongos=3.0.6 mongodb-org-tools=3.0.6
      - run:
          name: Setup NVM for use and Node
          command: |
            wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
            export NVM_DIR=$HOME/.nvm
            touch $HOME/.nvmrc
            source $NVM_DIR/nvm.sh
            nvm install 8.*
            nvm use 8.* && nvm alias default 8.*
            npm install react 16
            npm install react-dom 16
            npm install @babel/core
            npm install @babel/preset-env
            npm install webpack
            npm install webpack-cli
            npm install jest
            #curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
            #chmod +x ./cc-test-reporter
            #./cc-test-reporter before-build
            #npm test -- --coverage
            #./cc-test-reporter after-build --coverage-input-type clover --exit-code $?
    deploy:
      machine:
        enabled: true
      environment:
        HEROKU_APP: "thingygoeshere"
      steps:
        - checkout
        - run:
            name: Deploy Master to heroku
            command: |
              git push https://heroku:$HEROKU_API_KEY@git.heroku.com/picklechat-react-dev.git master

workflows:
  version: 2
  build:
    jobs:
      - deploy
      - deploy:
          requires:
            - deploy
          filters:
            branches:
              only: master

Each time I try to build, it gets through the first bit fine. Then it says:

Cannot find a job named deploy to run in the jobs: section of your configuration file.
If you expected a workflow to run, check your config contains a top-level key called ‘workflows:’

I feel like I’m missing something very obvious here.

Yep - you have run into The Curse Of Yaml, which is an indentation problem. Copy your YAML into this parser to see the issue. Your two jobs build and deploy are keys that should be at the same level, but deploy has become a sub-key of the build object.

Un-indent the deploy section, double-check it with the parser, then commit and push - that should sort it out.

1 Like

Hey there!

You’re 100% right. It was the indent, it was making it believe it wasn’t there. I just got a valid build a couple of minutes ago and was about to update :slight_smile:

Thank you for your assistance!

1 Like

No worries. Unfashionably, I like XML… :smiley_cat:

1 Like

Hahaha weirdo :stuck_out_tongue:

But we need people like you around! You are very helpful

1 Like

Giggle!

Incidentally, Mongo is something that can become a secondary container, in the place you had circleci/node:chakracore-8 previously. You can use any CircleCI convenience image, anything from Docker Hub, or anything from your private registry. As you’d expect, smaller = quicker here, so images based on Alpine (etc) are ideal.

When a secondary container is spun up, the networking stack is merged with the primary container and becomes available on localhost.

However, if your current Mongo install works, I’d suggest not changing it until you’ve got a 2.0 config stable.

1 Like

Oh! That could be very useful! Thank you :slight_smile:

I’ll give that a go because honestly the better I can make this the less I’ll need to mess with it in the future.

1 Like
4 Likes

@claytron5000 These are standard-issue at Circle HQ :wink:

2 Likes

Hahaha that’s brilliant. Might try that set up next time :wink:

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.