Are there functional differences between my 1.0 and 2.0 CircleCI configurations?


#1

Hi There,
I am new to CircleCI. I have 2 sets of configurations. The first one is using CircleCI version 1.0 and the 2nd one is the one I have tried to create for migrating to CircleCI version 2.0.
Hence request you to let me know if the objective of the first version is maintained in the second or will there be functional difference if I use the version 2 .0.

Version 1.0:

    ## Customize the test machine
    machine:

      timezone:
        America/New_York # List of timezones http://en.wikipedia.org/wiki/List_of_tz_database_time_zones

      # Version of ruby to use
      ruby:
        version:
          2.3.1

    ## Customize database setup
    database:
      override:
        # replace Circle's generated database.yml
        - cp config/database.yml.ci config/database.yml
        - bundle exec rake db:create db:schema:load --trace

    test:
      minitest_globs:
        - test/**/*_test.rb

    checkout:
      post:
        - mkdir -p tmp

Version 2.0:

version: 2 # use CircleCI 2.0
jobs: # a collection of steps
  build: # runs not using Workflows must have a `build` job as entry point
    docker: # run the steps with Docker
      - image: circleci/ruby:2.3-jessie # ...with this image as the primary container; this is where all `steps` will run
        environment:
          TZ: "/usr/share/zoneinfo/America/New_York"
    steps: # a collection of executable commands
      - checkout: # special step to check out source code to working directory
          post:
            - mkdir -p tmp
      - run:
          name: override
          command: 
            - cp config/database.yml.ci config/database.yml
            - bundle exec rake db:create db:schema:load --trace
      - test:
          minitest_globs:
            - test/**/*_test.rb

Regards,
Mru


#2

This question is unlikely to attract answers. For volunteer readers, that’s too much work to ask them to do, and for CircleCI employees, I’d wager this would have to be commercial (paid) support. Readers might have a quick read, but to answer this, I think it needs to be run.

Why not just commit the 2.0 version on a branch in your project, try it, and read the build logs to see if every step was OK?


#3

Unless it’s undocumented, there is no post key to the checkout node in the steps list in 2.0.


#4

Hi Grahamw,
Thanks for your reply.
I have added the peice of code with reference to the example shared in the following link:
https://circleci.com/docs/2.0/migrating-from-1-2/
Please view the example in point number 6 under ‘Steps to Configure Required 2.0 Keys’ from the above link.

Request you to suggest the correction needed in the snippet:


#5

Assuming that you need the tmp directory created relative to where the git code will be checked out by default. The steps become:

steps: # a collection of executable commands
  - checkout: # special step to check out source code to working directory
  - run: mkdir -p tmp
  - run:
      name: Setup DB stuff
      command: |
        cp config/database.yml.ci config/database.yml
        bundle exec rake db:create db:schema:load --trace
  - run:
      name: run your ruby tests in this or several run steps as you require
      command: |
        # not being a ruby guy, change this whatever it is required to run the tests as if on your terminal
        # minitest_globs:
        #  - test/**/*_test.rb

Also the command you had for “override” wasn’t correct. You can also use a more descriptive name.
The test key is not valid either, you need to convert them to run commands. Further details for all the valid configuration items for 2.0 can be found here - https://circleci.com/docs/2.0/configuration-reference/


#6

Thanks a ton Grahamw.
Will try implementing the modifications suggested.