Efficiently testing configuration file (migrating to 2.0)

config
configuration

#1

Hi! I need to migrate our existing CircleCI 1.x config to the new 2.0 format. The docs are helpful but inevitably I’m hitting various pitfalls.

Having just begun, the way I am testing my changes is:

  1. make changes to .circleci/config.yml
  2. commit changes in git
  3. push commit to GitHub
  4. wait for CircleCI to notice the push and start running the build

Is there any more efficient way to do this? Nothing in my repo is actually changing, other than the .circleci/config.yml file. It would be cool if there was a way to directly edit that file in the web UI, but while I can view that file in the CircleCI app, I didn’t see any way to edit it.

Is there a better way, or is the way I’m doing it just how you do it?


#2

I’ve been using this for more complex config.yml files where I want to iterate quickly.

	curl --user ${CIRCLE_TOKEN}: \
		--request POST \
		--form revision=${GIT_SHA} \
		--form config=@config.yml \
		--form notify=false \
		https://circleci.com/api/v1.1/project/github/${ORG}/${PROJECT}/tree/circleci-beta

This will tell CircleCI to run a build using $GIT_SHA from the repo history, putting the build in the circle_beta branch (regardless of whether that SHA is actually in the branch or not). It’ll upload your config.yml file and that will supersede a config file from the checkout.

You can alias this or put it in a script for less typing. Finally, if you’re a vim user like me, you can bind this with something like nnoremap <leader>rr :!circleci_upload_and_trigger<cr>.


#3

Eric, thank you! That worked for me, and is really helpful.

It’s faster and less cumbersome (especially when automated from your editor), and doing it this way also reduces useless output from any bots that might be watching for git pushes to the project, and then e.g. posting messages to Slack or whatever.

For posterity, I converted your curl command to a ruby script suitable for dropping into a project’s bin dir:

Cheers,

— Mason


#4