Unable to test config files locally due to validation error

Greetings!

I’m currently trying to test my local config.yml file using the CircleCI Testing Config Files Locally instructions.

Here’s my bash script used to trigger the test (token and repo name changed for security):

CIRCLE_TOKEN=1234
LATEST_REVISION=$(git rev-parse HEAD)
CURRENT_BRANCH=$(git branch | grep \* | cut -d ' ' -f2)

curl --user ${CIRCLE_TOKEN}: \
     --request POST \
     --form revision=${LATEST_REVISION}\
     --form config=@".circleci/config.yml" \
     --form notify=false \
        https://circleci.com/api/v1.1/project/github/org/project/tree/${CURRENT_BRANCH}

When I run this it returns a long JSON response:

{
  "compare" : null,
  "previous_successful_build" : {
    "build_num" : 60,
    "status" : "success",
    "build_time_millis" : 25894
  },
  "build_parameters" : { },
  "oss" : false,
  "committer_date" : null,
  "body" : null,
  "usage_queued_at" : "2019-04-30T16:30:34.991Z",
  "fail_reason" : null,
  "retry_of" : null,
  "reponame" : [redacted],
  "ssh_users" : [ ],
  "build_url" : "https://circleci.com/gh/[org/project]/63",
  "parallel" : 1,
  "failed" : null,
  "branch" : "develop",
  "username" : [redacted],
  "author_date" : null,
  "why" : "api",
  "user" : {
    "is_user" : true,
    "login" : [redacted],
    "avatar_url" : [redacted],
    "name" : "Jason Adams",
    "vcs_type" : "github",
    "id" : [redacted]
  },
  "vcs_revision" : "e739febfe3c4ec60c296463dd0f3048614c52a3f",
  "vcs_tag" : null,
  "build_num" : 63,
  "infrastructure_fail" : false,
  "committer_email" : null,
  "previous" : {
    "build_num" : 62,
    "status" : "canceled",
    "build_time_millis" : 635264
  },
  "status" : "not_running",
  "committer_name" : null,
  "retries" : null,
  "subject" : null,
  "vcs_type" : "github",
  "timedout" : false,
  "dont_build" : null,
  "lifecycle" : "not_running",
  "no_dependency_cache" : false,
  "stop_time" : null,
  "ssh_disabled" : true,
  "build_time_millis" : null,
  "picard" : null,
  "circle_yml" : {
    "string" : "[removed to shorten snippet]"
  },
  "messages" : [ {
    "type" : "warning",
    "message" : "Your config file has errors and may not run correctly:<br/><pre>jobs: 12 schema violations found<br/>  jobs: checkout: -codeonly 0 subschema matches out of 2<br/>    jobs: checkout: -codeextraneous key [executor] is not permitted<br/>    jobs: checkout: -code0 subschemas matched instead of one<br/>      jobs: checkout: -coderequired key [machine] not found<br/>      jobs: checkout: -coderequired key [docker] not found<br/>      jobs: checkout: -coderequired key [macos] not found<br/>  jobs: build: only 0 subschema matches out of 2<br/>    jobs: build: extraneous key [executor] is not permitted<br/>    jobs: build: 0 subschemas matched instead of one<br/>      jobs: build: required key [machine] not found<br/>      jobs: build: required key [docker] not found<br/>      jobs: build: required key [macos] not found<br/>  jobs: deploy: -devonly 0 subschema matches out of 2<br/>    jobs: deploy: -devextraneous key [executor] is not permitted<br/>    jobs: deploy: -dev0 subschemas matched instead of one<br/>      jobs: deploy: -devrequired key [machine] not found<br/>      jobs: deploy: -devrequired key [docker] not found<br/>      jobs: deploy: -devrequired key [macos] not found</pre>"
  } ],
  "is_first_green_build" : false,
  "job_name" : null,
  "start_time" : null,
  "canceler" : null,
  "platform" : "2.0",
  "outcome" : null,
  "vcs_url" : "https://github.com/[org/project]",
  "author_name" : null,
  "node" : null,
  "canceled" : false,
  "author_email" : null
}

What’s confusing is that when I run circleci config validate it says everything is great. Furthermore, the workflow does not get run. I’m not really sure what the issue is. Any help would be appreciated!

Thank you!

Hi @JasonTheAdams, can you try the instructions linked at the top of that Docs page?

Note: This document describes how to test and validate your config through the CircleCI API. It is also possible to install the CircleCI CLI, which allows you to validate your CircleCI config locally.

Specifically:

https://circleci.com/docs/2.0/local-cli/#run-a-job-in-a-container-on-your-machine

I think the main body of information on that Docs page is outdated, unfortunately, but running a local job with the CLI should do what you want here.

And if you don’t mind, please file an issue about these instructions on our documentation’s GitHub repository:

Thank you!

1 Like

Hi @rose!

In this case, I’m intentionally not using the CLI due to it’s limitations. Namely, it does not support executors, workflows, and caching — all of which I use in my config. The job I want to run requires the previous jobs in order to work.

Does that make sense?

Yeah, for sure @JasonTheAdams—makes sense! In that case, I think there isn’t actually a way to do what you’re trying to do at the moment… Although a revamped API is coming soon and may change that.

1 Like

Got it, thank you for clearing that up, @rose. It would be very helpful to have a sandbox or be able to run local configurations. Especially when working on the config, it can result in a lot of commits just to test things out.

Thank you!

1 Like

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