Incorrect Validation of config.yml

The local CLI cleared my config.yml as valid, but I was getting failures on all builds when pushed to my repository.

The errors I was getting:

2 schema violations found
  required key [jobs] not found
  required key [version] not found

And the config.yml that passed CLI validation, but threw these errors:

version: 2

jobs:
    checkout_code:
        <<: *machine_config
        steps:
            - <<: *restore_repo
            - <<: *install_dependencies
            - <<: *cache_dependencies
            - checkout
            - save_cache:
                key: client-ios-{{ .Branch }}
                paths: .

    test_all:
        <<: *machine_config
        steps:
            - <<: *simulator_warmup
            - <<: *restore_dependencies
            - run:
                name: Run Fastlane Tests
                command: bundle exec fastlane test_all

            - store_artifacts:
                path: output
            - store_test_results:
                path: output/scan

    deploy_adhoc:
        <<: *machine_config
        steps:
            - run: bundle exec fastlane time
            
workflows:
    version: 2
    test:
        jobs:
            - checkout_code
            - test_all:
                requires:
                    - checkout_code
    adhoc:
        jobs:
            - deploy_adhoc

references:
    machine_config: &machine_config
        macos:
            xcode: "9.3.0"
        working_directory: ~/Workspaces/client-ios
        environment:
            FL_OUTPUT_DIR: output
        shell: /bin/bash --login -o pipefail

    simulator_warmup: &simulator_warmup
        run:
            name: pre-start simulator
            command: xcrun instruments -w "iPhone 7 (10.2) [" || true

    install_dependencies: &install_dependencies
        run:
            name: Fetch CocoaPod Specs
            command: |
                curl https://cocoapods-specs.circleci.com/fetch-cocoapods-repo-from-s3.sh | bash -s cf

        run:
            name: Install CocoaPods
            command: pod install --verbose

        run:
            name: Install Bundle Dependencies
            command: bundle install

    cache_dependencies: &cache_dependencies
        save_cache:
            key: dependency-cache-{{ checksum "Gemfile.lock" }}
            paths: vendor/bundle

    restore_dependencies: &restore_dependencies
        restore_cache:
            key: dependency-cache-{{ checksum "Gemfile.lock" }}

    restore_repo: &restore_repo
        restore_cache:
            key: client-ios-{{ .Branch }}

I’ve resolved this issue thanks to a separate online YAML validator, but it raised concerns with me that the local validator was giving me false positives.

(The issue appears to have been that I had the references dictionary at the end of the file; shunting it to the start allowed builds to run once more. Erroneously, but that’s a matter of incorrect commands and not the point of this post!)

1 Like

Related question.

1 Like

@halfer There are some useful links in that thread. Perhaps I should have made this post in the Bug Reports forum?

Good idea, I changed it for you. The comments from an employee on the other thread suggest they know about it. I used an ordinary YAML validator too - the problems in a CircleCI configuration are usually just malformed YAML.

Or you use a YAML-aware IDE too, of course - my NetBeans does this for me.

1 Like

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