My builds run as 1.0 even though I have the 2.0 file/setup

2.0
#1

I have a repo which is new enough that it was never set up with the 1.0-style circle.yml - it has always had .circle/config.yml. I have just noticed that this entire time it has been running (and passing) as 1.0. I have checked and double-checked that no 1.0-style circle.yml exists in my project. I am not sure how to debug this and I don’t understand why this is happening. Here is my .circle/config.yml for reference in case I have done anything wrong. I am using almost the exact same file on another project (just with the DB names changed) and it runs properly as 2.0 there.

version: 2
jobs:
  build:
    docker:
      - image: circleci/ruby:2.4-stretch-node-browsers
        environment:
          - PGHOST: 127.0.0.1
          - PGUSER: myapp
          - RAILS_ENV: test
      - image: circleci/postgres:9.4
        environment:
          - POSTGRES_USER: myapp
          - POSTGRES_DB: myapp_db_test
          - POSTGRES_PASSWORD: ""

    working_directory: ~/repo

    steps:
      - checkout

      - restore_cache:
          name: Restore cache
          keys:
          - v1-dependencies-{{ checksum "Gemfile.lock" }}
          - v1-dependencies-

      - run:
          name: Install dependencies
          command: |
            bundle install --jobs=4 --retry=3 --path vendor/bundle

      - save_cache:
          name: Save cache
          paths:
            - ./vendor/bundle
          key: v1-dependencies-{{ checksum "Gemfile.lock" }}

      - run:
          name: Database setup
          command: |
            bundle exec rake db:create
            bundle exec rake db:schema:load

      - run:
          name: Rspec
          command: |
            mkdir /tmp/test-results
            TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"

            bundle exec rspec --format progress \
                            --format RspecJunitFormatter \
                            --out /tmp/test-results/rspec.xml \
                            --format progress \
                            $TEST_FILES

      - store_test_results:
          path: /tmp/test-results
      - store_artifacts:
          path: /tmp/test-results
          destination: test-results
#2

Your YAML is incorrectly formatted. It’s valid, but it is producing an unexpected data structure - your environment seems to be an array of objects rather than an array of x=y strings. I suspect the error handling in the CircleCI could do with some better logging/validation :wink:

Here is a snippet of my working config:

version: 2
jobs:
  build:
    working_directory: /app
    environment:
      - PROJECT_REGISTRY=registry.gitlab.com
      - CACHE_REGISTRY=registry.gitlab.com/myuser/xxx-cache
      - GITLAB_USER=myuser
    docker:
      - image: docker:18.06.0-ce-git
    steps:
      - checkout
      - setup_remote_docker
      - run:
          name: Sign into Docker registry
          command: |
            docker login -u ${GITLAB_USER} -p ${GITLAB_REGISTRY_TOKEN} registry.gitlab.com

Try putting my YAML, and your YAML, in this parser, to see the different structures they make.

#3

How is is possible that one repo runs 2.0 and one runs 1.0 using the same file? (Other than the pg names)

#4

Hmm, I may yet have to eat my hat. The reference docs suggest your way is correct.

Try mine anyway, in case the docs are wrong - as far as I know, I use my x=y approach in a couple of projects, and it works fine. I don’t know where I got that style from!

#5

I just pushed a commit to try yours, and it’s still 1.0. I also tried the change in the other repo which is using a file similar to this one other than the db info and which is properly running as 2.0 and it did not seem to adversely affect it, since it still ran green. Seems to work either way.

Is there some setting I am missing in CircleCI which is forcing my app to use 1.0 rather than 2.0?

#6

Aha! You’ve misnamed the folder .circle, it should be .circleci.

Also, make sure you using config.yml and not config.yaml. Technically the spec requires both, but only one works.

Not as far as I know. Defaulting to 1.0 is just CircleCI behaviour if it cannot find a 2.0 config, or cannot make sense of the 2.0 config it can find.

2 Likes
#7

You are my hero. Thank you for your eagle eye!

1 Like
closed #8

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