Skip to content

Commit

Permalink
Circleci (#162)
Browse files Browse the repository at this point in the history
ci: enable circleci
  • Loading branch information
troian authored Jan 24, 2020
1 parent 3595842 commit 66df1d5
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 61 deletions.
82 changes: 53 additions & 29 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
version: 2
version: 2.1
docker_job_setup: &docker_job
docker:
- image: circleci/golang:1.13.6
working_directory: /go/src/github.com/VolantMQ/volantmq

attach_workspace: &workspace
attach_workspace:
at: /go/src/github.com/VolantMQ/volantmq
at: /go/src/github.com/VolantMQ

orbs:
codecov: codecov/[email protected]
docker: circleci/[email protected]

jobs:
pull-sources:
Expand All @@ -23,6 +27,7 @@ jobs:
lint:
<<: *docker_job
steps:
- <<: *workspace
- run:
name: Install golangci-lint
command: |
Expand All @@ -36,74 +41,93 @@ jobs:
steps:
- <<: *workspace
- run:
name: Setup Code Climate test-reporter
command: |
# download test reporter as a static binary
mkdir -p /tmp/codeclimate
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > /tmp/codeclimate/cc-test-reporter
chmod +x /tmp/codeclimate/cc-test-reporter
- run:
shell: /bin/bash
name: Tests
command: |
/tmp/codeclimate/cc-test-reporter before-build
./go.test.sh
/tmp/codeclimate/cc-test-reporter --coverage-input-type coverage --exit-code $?
test-build-docker:
./go.test.codecov.sh
- codecov/upload:
file: coverage.txt
test-docker-build:
<<: *docker_job
steps:
- <<: *workspace
- run:
name: Docker build
command: |
./dockerBuildLocal.sh
build-docker:
- setup_remote_docker
- docker/build:
dockerfile: local.Dockerfile
image: volantmq/volantmq
tag: 'latest'
release-docker:
<<: *docker_job
steps:
- <<: *workspace
- setup_remote_docker
- docker/build:
dockerfile: local.Dockerfile
lint-dockerfile: false
treat-warnings-as-errors: false
image: volantmq/volantmq
tag: 'latest'
- run:
name: Docker build
name: Tag docker image
command: |
./dockerBuildLocal.sh volantmq/volantmq:${CIRCLE_TAG}
docker login -u \$DOCKER_USERNAME -p \$DOCKER_PASSWORD
docker push volantmq/volantmq:${CIRCLE_TAG}
docker tag volantmq/volantmq:latest volantmq/volantmq:${CIRCLE_TAG}
- docker/check:
docker-username: DOCKER_LOGIN
docker-password: DOCKER_PASSWORD
- docker/push:
image: volantmq/volantmq
tag: '${CIRCLE_TAG},latest'
workflows:
version: 2
version: 2.1
test-on-commit:
jobs:
- pull-sources:
filters:
tags:
ignore: /.*/
- test:
- lint:
requires:
- pull-sources
filters:
tags:
ignore: /.*/
- test-build-docker:
- test:
requires:
- lint
filters:
tags:
ignore: /.*/
- test-docker-build:
requires:
- test
filters:
tags:
ignore: /.*/
release:
jobs:
- pull-source:
- pull-sources:
filters:
tags:
only: /^[vV]?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(\-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$/
branches:
ignore: /.*/
- lint:
requires:
- pull-sources
filters:
tags:
only: /^[vV]?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(\-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$/
branches:
ignore: /.*/
- test:
requires:
- pull-source
- lint
filters:
tags:
only: /^[vV]?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(\-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$/
branches:
ignore: /.*/
- build-docker:
- release-docker:
context: volantmq
requires:
- test
Expand Down
32 changes: 0 additions & 32 deletions .travis.yml

This file was deleted.

15 changes: 15 additions & 0 deletions go.test.codeclimate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

set -e

echo "starting tests"

for pkg in $(go list ./... | grep -v main); do
go test -coverprofile=$(echo ${pkg} | tr / -).cover ${pkg}
done

echo "mode: set" > c.out
grep -h -v "^mode:" ./*.cover >> c.out
rm -f *.cover

echo "tests finished"
1 change: 1 addition & 0 deletions go.test.sh → go.test.codecov.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env bash

set -e

echo "" > coverage.txt

for d in $(go list ./... | grep -v vendor); do
Expand Down

0 comments on commit 66df1d5

Please sign in to comment.