Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
166 lines (158 sloc) 5.54 KB
# Golang CircleCI 2.1 configuration file
---
version: 2.1
orbs:
# See https://circleci.com/orbs/registry/orb/circleci/go.
go: circleci/go@0.2.0
jobs:
linters-check:
docker:
# this image is built from Dockerfile
# https://github.com/pouchcontainer/pouchlinter/blob/master/Dockerfile
- image: dragonflyoss/linter:v0.2.7
working_directory: /go/src/github.com/dragonflyoss/Dragonfly
steps:
- checkout
- go/load-cache
- run:
name: use markdownlint v0.5.0 to lint markdown file (https://github.com/markdownlint/markdownlint)
command: |
find ./ -name "*.md" | grep -v commandline | grep -v .github | grep -v swagger | grep -v api | xargs mdl -r ~MD002,~MD007,~MD010,~MD013,~MD024,~MD026,~MD029,~MD033,~MD034,~MD036,~MD046
- run:
name: use markdown-link-check(https://github.com/tcort/markdown-link-check) to check links in markdown files
command: |
set +e
curl -OfsSL https://raw.githubusercontent.com/dragonflyoss/dragonfly-scripts/master/config/markdown-link-check-scripts.json
for name in $(find . -name \*.md | grep -v CHANGELOG); do
if [ -f $name ]; then
markdown-link-check -q -v -c ./markdown-link-check-scripts.json $name;
if [ $? -ne 0 ]; then
code=1
fi
fi
done
bash -c "exit $code";
- run:
name: use opensource tool client9/misspell to correct commonly misspelled English words
command: |
find . -name "*" | xargs misspell -error
- run:
name: use yamllint tool to check the format of all yaml files
command: |
find . -name "*.yml" | xargs yamllint -d "{extends: default, rules: {line-length: disable}}"
- run:
name: use ShellCheck (https://github.com/koalaman/shellcheck) to check the validateness of shell scripts in pouch repo
command: |
find . -name "*.sh" | xargs shellcheck
- run:
name: validate go mod files
command: |
make check-go-mod
- run:
name: validate swagger.yml
command: |
swagger validate "/go/src/github.com/dragonflyoss/Dragonfly/apis/swagger.yml"
- run:
name: use golangci-lint to check gocode of this project.
command: |
make golangci-lint
- run:
name: boilerplate check
command: |
make boilerplate-check
- go/save-cache
unit-test-golang:
docker:
- image: circleci/golang:1.12.10
working_directory: /go/src/github.com/dragonflyoss/Dragonfly
steps:
- checkout
- go/load-cache
- run:
name: build client
command: |
make build
- run:
name: unit test
command: make unit-test
- run:
name: upload code coverage report
command: bash <(curl -s https://codecov.io/bash)
- run:
name: rm coverage.txt
command: rm coverage.txt
- go/save-cache
api-integration-test:
docker:
- image: circleci/golang:1.12.10
working_directory: /go/src/github.com/dragonflyoss/Dragonfly
steps:
- checkout
- go/load-cache
- run:
name: build dragonfly & run all integration test cases in test
command: |
echo "building..."
make build > /dev/null
echo "start integration test..."
make integration-test
- go/save-cache
release:
docker:
- image: circleci/golang:1.12.10
working_directory: /go/src/github.com/dragonflyoss/Dragonfly
steps:
- checkout
- go/load-cache
# TODO(yeya24): consider a better way to inject build date
- run:
name: inject build date
command: echo 'export DATE=$(date "+%Y%m%d-%H:%M:%S")' >> $BASH_ENV
- run: curl -sL https://git.io/goreleaser | bash
- go/save-cache
# TODO(yeya24): Consider changing to use goreleaser to publish images later
publish-images:
docker:
- image: circleci/golang:1.12.10
working_directory: /go/src/github.com/dragonflyoss/Dragonfly
steps:
- checkout
- setup_remote_docker
- run: echo 'export DF_VERSION=${CIRCLE_TAG:1}' >> $BASH_ENV
- go/load-cache
- run: make docker-build
- run:
name: push images
command: |
echo "$DOCKERHUB_PASS" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin
docker tag dfclient:$DF_VERSION dragonflyoss/dfclient:$DF_VERSION
docker tag supernode:$DF_VERSION dragonflyoss/supernode:$DF_VERSION
docker tag dfclient:$DF_VERSION dragonflyoss/dfclient:latest
docker tag supernode:$DF_VERSION dragonflyoss/supernode:latest
docker push dragonflyoss/dfclient:$DF_VERSION
docker push dragonflyoss/supernode:$DF_VERSION
docker push dragonflyoss/dfclient:latest
docker push dragonflyoss/supernode:latest
- go/save-cache
workflows:
version: 2
ci:
jobs:
- linters-check
- unit-test-golang
- api-integration-test
release:
jobs:
- release:
# Only run this job on git tag pushes
filters:
branches:
ignore: /.*/
tags:
only: /^v[0-9]+(\.[0-9]+){2}(-.+|[^-.]*)$/
- publish-images:
filters:
branches:
ignore: /.*/
tags:
only: /^v[0-9]+(\.[0-9]+){2}(-.+|[^-.]*)$/
You can’t perform that action at this time.