Skip to content

Commit

Permalink
add CircleCI config
Browse files Browse the repository at this point in the history
  • Loading branch information
vyzo committed Apr 2, 2021
1 parent e17f6e9 commit 3db4bdb
Showing 1 changed file with 136 additions and 0 deletions.
136 changes: 136 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
version: 2.1
orbs:
go: gotest/tools@0.0.13

executors:
golang:
docker:
- image: circleci/golang:1.15.5
resource_class: 2xlarge
ubuntu:
docker:
- image: ubuntu:20.04

jobs:
mod-tidy-check:
executor: golang
steps:
- go/mod-tidy-check
gofmt:
executor: golang
steps:
- run:
command: "! go fmt ./... 2>&1 | read"
build:
executor: golang
steps:
- go/build
test: &test
parameters: &test-params
executor:
type: executor
default: golang
go-test-flags:
type: string
default: "-timeout 30m"
description: Flags passed to go test.
packages:
type: string
default: "./..."
description: Import paths of packages to be tested.
gotestsum-format:
type: string
default: pkgname-and-test-fails
description: gotestsum format. https://github.com/gotestyourself/gotestsum#format
coverage:
type: string
default: -coverprofile=coverage.txt -coverpkg=github.com/libp2p/go-libp2p-pubsub
description: Coverage flag. Set to the empty string to disable.
codecov-upload:
type: boolean
default: false
description: |
Upload coverage report to https://codecov.io/. Requires the codecov API token to be
set as an environment variable for private projects.
executor: << parameters.executor >>
steps:
- go/install-gotestsum:
gobin: $HOME/.local/bin
version: 0.5.2
- run:
name: go test
command: |
ulimit -n 2048
mkdir -p /tmp/test-reports/<< parameters.test-suite-name >>
mkdir -p /tmp/test-artifacts
gotestsum \
--format << parameters.gotestsum-format >> \
--junitfile /tmp/test-reports/<< parameters.test-suite-name >>/junit.xml \
--jsonfile /tmp/test-artifacts/<< parameters.test-suite-name >>.json \
-- \
<< parameters.coverage >> \
<< parameters.go-test-flags >> \
<< parameters.packages >>
no_output_timeout: 30m
- store_test_results:
path: /tmp/test-reports
- store_artifacts:
path: /tmp/test-artifacts/<< parameters.test-suite-name >>.json
- when:
condition: << parameters.codecov-upload >>
steps:
- go/install: {package: bash}
- go/install: {package: curl}
- run:
shell: /bin/bash -eo pipefail
command: |
bash <(curl -s https://codecov.io/bash)
lint: &lint
description: |
Run golangci-lint.
parameters:
executor:
type: executor
default: golang
golangci-lint-version:
type: string
default: 1.27.0
concurrency:
type: string
default: '2'
description: |
Concurrency used to run linters. Defaults to 2 because NumCPU is not
aware of container CPU limits.
args:
type: string
default: ''
description: |
Arguments to pass to golangci-lint
executor: << parameters.executor >>
steps:
- install-deps
- prepare
- run:
command: make deps
no_output_timeout: 30m
- go/install-golangci-lint:
gobin: $HOME/.local/bin
version: << parameters.golangci-lint-version >>
- run:
name: Lint
command: |
$HOME/.local/bin/golangci-lint run -v --timeout 2m \
--concurrency << parameters.concurrency >> << parameters.args >>
workflows:
version: 2.1
ci:
jobs:
- mod-tidy-check
- gofmt
- build
- test:
codecov-upload: true
test-suite-name: full
- lint:
concurrency: "16" # expend all docker 2xlarge CPUs.

0 comments on commit 3db4bdb

Please sign in to comment.