.circleci/config.yml
defaults: &defaults
docker:
- image: circleci/golang:1.13
environment:
CIRCLECI: 1
- image: circleci/postgres:12.2
environment:
POSTGRES_USER: db_test_user
POSTGRES_PASSWORD: db_test_password
POSTGRES_DB: db_test_database
working_directory: /go/src/github.com/{{ORG_NAME}}/{{REPO_NAME}}
version: 2
jobs:
checkout:
<<: *defaults
steps:
- checkout
- attach_workspace:
at: /go/src/github.com/{{ORG_NAME}}/{{REPO_NAME}}
- restore_cache:
keys:
- go-mod-v4-{{ checksum "go.sum" }}
- run:
name: Dependencies
command: go get -v -t -d ./...
- save_cache:
key: go-mod-v4-{{ checksum "go.sum" }}
paths:
- "/go/pkg/mod"
- persist_to_workspace:
root: .
paths: .
unit-test:
<<: *defaults
steps:
- attach_workspace:
at: /go/src/github.com/{{ORG_NAME}}/{{REPO_NAME}}
- run:
name: Unit Tests
command: |
./test.sh -s
full-test:
<<: *defaults
steps:
- attach_workspace:
at: /go/src/github.com/{{ORG_NAME}}/{{REPO_NAME}}
# Wait for Postgres to be ready before proceeding
- run:
name: Waiting for Postgres to be ready
command: dockerize -wait tcp://localhost:5432 -timeout 1m
- run:
name: Tests with Coverage
command: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
./cc-test-reporter before-build
go test -coverprofile c.out ./...
./cc-test-reporter after-build -t gocov -p github.com/gogjango/gjango -r ${TEST_REPORTER_ID}
workflows:
version: 2
test-deploy-purge:
jobs:
- checkout
- unit-test:
filters:
branches:
ignore:
- master
- develop
requires:
- checkout
- full-test:
filters:
branches:
only:
- master
- develop
requires:
- checkout