Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitHub actions #160

Closed
wants to merge 12 commits into from
118 changes: 118 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
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

orbs:
codecov: codecov/[email protected]

jobs:
pull-sources:
<<: *docker_job
steps:
- checkout
- run:
name: go mod tidy
command: go mod tidy
- persist_to_workspace:
root: /go/src/github.com/VolantMQ
paths:
- volantmq
lint:
<<: *docker_job
steps:
- <<: *workspace
- run:
name: Install golangci-lint
command: |
go get -u github.com/golangci/golangci-lint/cmd/golangci-lint
- run:
name: lint
command: |
golangci-lint run
test:
<<: *docker_job
steps:
- <<: *workspace
- run:
shell: /bin/bash
name: Tests
command: |
./go.test.codecov.sh
- codecov/upload:
file: coverage.txt
test-build-docker:
<<: *docker_job
steps:
- <<: *workspace
- run:
name: Docker build
command: |
./dockerBuildLocal.sh
build-docker:
<<: *docker_job
steps:
- <<: *workspace
- run:
name: Docker build
command: |
./dockerBuildLocal.sh volantmq/volantmq:${CIRCLE_TAG}
docker login -u \$DOCKER_USERNAME -p \$DOCKER_PASSWORD
docker push volantmq/volantmq:${CIRCLE_TAG}

workflows:
version: 2.1
test-on-commit:
jobs:
- pull-sources:
filters:
tags:
ignore: /.*/
- lint:
requires:
- pull-sources
filters:
tags:
ignore: /.*/
- test:
requires:
- lint
filters:
tags:
ignore: /.*/
- test-build-docker:
requires:
- test
filters:
tags:
ignore: /.*/
release:
jobs:
- 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-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: /.*/
- build-docker:
context: volantmq
requires:
- test
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: /.*/
22 changes: 22 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
on: [push, pull_request]
name: Validate
strategy:
matrix:
go-version: [1.13.6]
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
with:
go-version: ${{ matrix.go-version }}
jobs:
lint:
steps:
- name: Install Go
uses: actions/setup-go@v1
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v1
- name: Install golangci-lint
run: curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(go env GOPATH)/bin v1.22.2
- name: lint
run: golangci-lint run
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