Technical recipes for frequently and infrequently recurring problems
To enable validating config.yml
syntax before pushing / creating pull request:
circleci setup
on the command line, this will create a configuration yml file in your home directory with your circleci host and api tokenconfig.yml
run on command line to ensure correct syntax, etc.
circleci config validate
Branch name pattern
with master
, select “Require pull request reviews before merging” and “Require status checks to pass before merging”, then select the appropriate ci/circleci tests (as of May 2020 the check that should be selected is ci/circleci:run-tests
) and save changes.On the command line, from the root of your application
mkdir .circleci
touch .circleci/config.yml
Example configuration
jobs:
build-and-push:
executor: docker/docker
steps:
- setup_remote_docker
- checkout
- docker/check
- docker/build:
image: YOUR-DOCKERHUB-ORGANIZATION/YOUR-DOCKERHUB-REPO
- docker/push:
image: YOUR-DOCKERHUB-ORGANIZATION/YOUR-DOCKERHUB-REPO
run-tests:
docker:
# Image pulled from registry
- image: YOUR-DOCKERHUB-ORGANIZATION/YOUR-DOCKERHUB-REPO:$CIRCLE_SHA1
environment:
POSTGRES_HOST: localhost
POSTGRES_DB: YOUR_APPLICATION_DB_TEST
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
SOLR_CORE: blacklight-test
SOLR_URL: http://localhost:8983/solr
- image: YOUR-DOCKERHUB-ORGANIZATION/dc-solr:79a71ec
command: bash -c 'precreate-core blacklight-test /opt/config; exec solr -f'
- image: circleci/postgres:9.5-alpine-ram
environment:
POSTGRES_DB: YOUR_APPLICATION_DB_TEST
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
executor: docker/docker
steps:
- setup_remote_docker
- checkout
- run:
name: Rubocop
command: bundle exec rubocop --parallel
- run:
name: rspec
# Excludes tests that require Yale VPN access
command: |
bundle exec rspec
publish-latest:
executor: docker/docker
steps:
- setup_remote_docker
- checkout
- docker/check
- docker/build:
image: YOUR-DOCKERHUB-ORGANIZATION/YOUR-DOCKERHUB-REPO
tag: master
- docker/push:
image: YOUR-DOCKERHUB-ORGANIZATION/YOUR-DOCKERHUB-REPO:master
tag: master
orbs:
docker: circleci/docker@1.0.1
version: 2.1
workflows:
commit:
jobs:
- build-and-push:
context: yul-dc
- run-tests:
requires:
- build-and-push
- publish-latest:
context: yul-dc
requires:
- build-and-push
- run-tests
filters:
branches:
only: master