forked from launchdarkly-labs/ldc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ci build and release flow (launchdarkly-labs#6)
Also make a bunch of lint fixes and start running golangci lint.
- Loading branch information
1 parent
009cbe0
commit c1dd36e
Showing
16 changed files
with
435 additions
and
231 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
version: 2 | ||
|
||
experimental: | ||
notify: | ||
branches: | ||
only: | ||
- master | ||
|
||
defaults: | ||
environment: &environment | ||
CIRCLE_TEST_REPORTS: /tmp/circle-reports | ||
CIRCLE_ARTIFACTS: /tmp/circle-artifacts | ||
COMMON_GO_PACKAGES: > | ||
github.com/jstemmer/go-junit-report | ||
github.com/kyoh86/richgo | ||
build_steps: &build_steps | ||
working_directory: &working_dir /go/src/github.com/launchdarkly/ldc | ||
steps: | ||
- checkout | ||
- run: go get -u $COMMON_GO_PACKAGES | ||
- run: curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh | ||
- run: dep ensure -dry-run | ||
- run: make init | ||
- run: make lint | ||
- run: | ||
name: Set up Code Climate test-reporter | ||
command: | | ||
curl -sS -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter | ||
chmod +x ./cc-test-reporter | ||
- run: | ||
name: Run tests | ||
command: | | ||
mkdir -p $CIRCLE_TEST_REPORTS | ||
mkdir -p $CIRCLE_ARTIFACTS | ||
trap "go-junit-report < $CIRCLE_ARTIFACTS/report.txt > $CIRCLE_TEST_REPORTS/junit.xml" EXIT | ||
if [ -z "$DISABLE_COVERAGE" ]; then | ||
go_cover_args="-covermode=atomic -coverpkg=./... -coverprofile /tmp/circle-artifacts/coverage.txt" | ||
fi | ||
go test -race $go_cover_args -v $(go list ./... | grep -v /vendor/) | tee >(richgo testfilter) > $CIRCLE_ARTIFACTS/report.txt | ||
if [[ -z "$DISABLE_COVERAGE" && -n "$CC_TEST_REPORTER_ID" ]]; then | ||
./cc-test-reporter format-coverage $CIRCLE_ARTIFACTS/coverage.txt -t gocov --output $CIRCLE_ARTIFACTS/coverage.json | ||
./cc-test-reporter upload-coverage --input $CIRCLE_ARTIFACTS/coverage.json | ||
fi | ||
- run: | ||
name: Generate coverage report | ||
command: | | ||
if [ -z "$DISABLE_COVERAGE" ]; then | ||
go tool cover -html=$CIRCLE_ARTIFACTS/coverage.txt -o $CIRCLE_ARTIFACTS/coverage.html | ||
fi | ||
when: always | ||
- store_test_results: | ||
path: /tmp/circle-reports | ||
- store_artifacts: | ||
path: /tmp/circle-artifacts | ||
|
||
jobs: | ||
go-test: | ||
docker: | ||
- &build_image | ||
image: circleci/golang:1.11 | ||
environment: | ||
<<: *environment | ||
|
||
<<: *build_steps | ||
|
||
test-publish: | ||
docker: | ||
- <<: *build_image | ||
|
||
working_directory: *working_dir | ||
steps: | ||
- checkout | ||
- run: make release-snapshot | ||
- store_artifacts: | ||
path: dist/ | ||
|
||
publish: | ||
docker: | ||
- <<: *build_image | ||
|
||
working_directory: *working_dir | ||
steps: | ||
- checkout | ||
- run: | ||
name: Releasing and publishing | ||
command: | | ||
make release | ||
- store_artifacts: | ||
path: dist/ | ||
|
||
workflows: | ||
version: 2 | ||
test: | ||
jobs: | ||
- go-test | ||
- test-publish | ||
- publish: | ||
filters: | ||
tags: | ||
only: /\d+\.\d+\.\d+(-.*)?/ | ||
branches: | ||
only: /v\d+/ | ||
requires: | ||
- go-test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
/ldc | ||
/ldc | ||
/bin | ||
/dist | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
project_name: ldc | ||
|
||
run: | ||
deadline: 120s | ||
tests: false | ||
|
||
linters: | ||
enable-all: true | ||
disable: | ||
- gochecknoinits | ||
- gochecknoglobals | ||
- gofmt | ||
- lll | ||
- maligned | ||
- prealloc | ||
- unparam | ||
fast: false | ||
|
||
linter-settings: | ||
goimports: | ||
local-prefixes: github.com/launchdarkly/ldc | ||
|
||
issues: | ||
exclude: | ||
- "G104: Errors unhandled." # Let errcheck handle these | ||
exclude-use-default: false | ||
max-same-issues: 1000 | ||
max-per-linter: 1000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
project_name: ldc | ||
|
||
builds: | ||
- env: | ||
- CGO_ENABLED=0 | ||
main: . | ||
binary: ldc | ||
# Default is `-s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}}`. | ||
ldflags: | ||
- -s -w -X cmd.Version={{.Version}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
GOLANGCI_VERSION=v1.12.5 | ||
|
||
SHELL=/bin/bash | ||
|
||
test: lint | ||
go test ./... | ||
|
||
lint: | ||
./bin/golangci-lint run ./... | ||
|
||
init: | ||
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s $(GOLANGCI_VERSION) | ||
|
||
RELEASE_CMD=curl -sL https://git.io/goreleaser | bash -s -- --rm-dist | ||
|
||
publish: | ||
$(RELEASE_CMD) | ||
|
||
publish-snapshot: | ||
$(RELEASE_CMD) | ||
|
||
release: | ||
$(RELEASE_CMD) --skip-publish --skip-validate | ||
|
||
release-snapshot: | ||
$(RELEASE_CMD) --skip-publish --skip-validate --snapshot | ||
|
||
.PHONY: docker init lint publish-snapshot release release-snapshot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.