Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
update circle
  • Loading branch information
Ale Paredes committed Sep 4, 2018
1 parent f61ae42 commit 72aafb4
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 32 deletions.
55 changes: 37 additions & 18 deletions .circleci/config.yml
Expand Up @@ -13,13 +13,14 @@ jobs:
release_linux:
docker:
- image: circleci/golang
working_directory: /go/src/github.com/codeclimate/test-reporter
setup_remote_docker:
docker_layer_caching: true
steps:
- checkout
- run: pip install awscli
- run: make build-all VERSION=head # TODO: build only linux outside docker
- run: make publish-head # TODO: only linux
- run: sudo apt-get install awscli
- run: make build-linux-all VERSION=head
- run: make publish-head

test_macos:
macos:
Expand All @@ -41,13 +42,31 @@ jobs:
cd $GOPATH/src/github.com/codeclimate/test-reporter
make test
# release_macos:
# macos:
# xcode: "9.0"
# steps:
# - checkout
# - run: echo "TODO install go"
# - run: echo "TODO build and release macos versions (outside of docker)"
release_macos:
macos:
xcode: "9.0"
steps:
- checkout
- run: pip install awscli
- run: brew install golang
- run:
name: Setup gopath
command: |
mkdir -p ~/gopath/src/github.com/codeclimate/test-reporter
echo 'export GOPATH=$HOME/gopath' >> "$BASH_ENV"
. "$BASH_ENV"
cd $GOPATH/src/github.com/codeclimate/test-reporter
cp -r ~/project/ $GOPATH/src/github.com/codeclimate/test-reporter/
- run:
name: Build
command: |
cd $GOPATH/src/github.com/codeclimate/test-reporter
make build-darwin VERSION=head
- run:
name: Publish
command: |
cd $GOPATH/src/github.com/codeclimate/test-reporter
make publish-head
workflows:
version: 2
Expand All @@ -63,14 +82,14 @@ workflows:
branches:
only:
- master
# - release_macos:
# requires:
# - test_linux
# - test_macos
# filters:
# branches:
# only:
# - master
- release_macos:
requires:
- test_linux
- test_macos
filters:
branches:
only:
- master

notify:
webhooks:
Expand Down
54 changes: 40 additions & 14 deletions Makefile
@@ -1,4 +1,4 @@
.PHONY: test-docker build-docker build-linux-cgo build-all build-all-latest release test-excoveralls
.PHONY: test-docker build-docker build-linux-cgo release test-excoveralls

AWS ?= $(shell which aws)
DOCKER_RUN ?= $(shell which docker) run --rm
Expand All @@ -10,7 +10,7 @@ MAN_FILES = $(wildcard man/*.md)
MAN_PAGES = $(patsubst man/%.md,man/%,$(MAN_FILES))

PROJECT = github.com/codeclimate/test-reporter
VERSION ?= netcgo
VERSION ?= 0.6.2
BUILD_VERSION = $(shell git log -1 --pretty=format:'%H')
BUILD_TIME = $(shell date +%FT%T%z)
LDFLAGS = -ldflags "-X $(PROJECT)/version.Version=${VERSION} -X $(PROJECT)/version.BuildVersion=${BUILD_VERSION} -X $(PROJECT)/version.BuildTime=${BUILD_TIME}"
Expand All @@ -26,26 +26,41 @@ test:
benchmark:
go test -bench . $(shell go list ./... | grep -v /vendor/)

build: BUILD_TAGS ?= ""
build:
go build -v ${LDFLAGS} -tags ${BUILD_TAGS} -o $(PREFIX)bin/test-reporter$(BINARY_SUFFIX)
if [ -z "${BUILD_TAGS}" ]; then \
go build -v ${LDFLAGS} -o $(PREFIX)bin/test-reporter$(BINARY_SUFFIX); \
else \
go build -v ${LDFLAGS} -tags ${BUILD_TAGS} -o $(PREFIX)bin/test-reporter$(BINARY_SUFFIX); \
fi

build-all:
build-linux-all:
$(MAKE) build-linux
$(MAKE) build-linux-cgo
$(MAKE) build-darwin

build-linux:
$(MAKE) build \
PREFIX=artifacts/ \
BINARY_SUFFIX=-$(VERSION)-linux-amd64 \
CGO_ENABLED=0

build-docker-linux:
$(MAKE) build-docker GOOS=linux GOARCH=amd64 CGO_ENABLED=0

build-docker-linux-cgo:
$(MAKE) build-docker GOOS=linux GOARCH=amd64 CGO_ENABLED=1 \
BUILD_TAGS="netcgo" BINARY_SUFFIX=-$(VERSION)-netcgo-linux-amd64

build-linux-cgo:
$(MAKE) build-docker GOOS=linux GOARCH=amd64 CGO_ENABLED=1 BUILD_TAGS="netcgo"
$(MAKE) build \
PREFIX=artifacts/ \
BINARY_SUFFIX=-$(VERSION)-netcgo-linux-amd64 \
CGO_ENABLED=1 \
BUILD_TAGS="netcgo"

build-darwin:
$(MAKE) build PREFIX=artifacts/ BINARY_SUFFIX=-$(VERSION)-darwin-amd64

build-all-latest:
$(MAKE) build-all VERSION=latest
$(MAKE) build \
PREFIX=artifacts/ \
BINARY_SUFFIX=-$(VERSION)-darwin-amd64

test-docker:
$(DOCKER_RUN) \
Expand All @@ -61,10 +76,11 @@ benchmark-docker:
--workdir "/src/$(PROJECT)" \
golang:1.8 make benchmark

build-docker: BINARY_SUFFIX ?= -$(VERSION)-$$GOOS-$$GOARCH
build-docker:
$(DOCKER_RUN) \
--env PREFIX=/artifacts/ \
--env BINARY_SUFFIX=-$(VERSION)-$$GOOS-$$GOARCH \
--env BINARY_SUFFIX=${BINARY_SUFFIX} \
--env GOARCH \
--env GOOS \
--env GOPATH=/ \
Expand Down Expand Up @@ -114,8 +130,9 @@ publish-latest:
--include "test-reporter-latest-*" \
artifacts/bin/ s3://codeclimate/test-reporter/

publish-version: GOOS ?= linux
publish-version:
if [ "$(shell curl https://s3.amazonaws.com/codeclimate/test-reporter/test-reporter-$(VERSION)-linux-amd64 --output /dev/null --write-out %{http_code})" -eq 403 ]; then \
if [ "$(shell curl https://s3.amazonaws.com/codeclimate/test-reporter/test-reporter-$(VERSION)-$(GOSS)-amd64 --output /dev/null --write-out %{http_code})" -eq 403 ]; then \
$(AWS) s3 cp \
--acl public-read \
--recursive \
Expand All @@ -135,4 +152,13 @@ clean:
sudo $(RM) -r ./artifacts
$(RM) $(MAN_PAGES)

release: build-all build-all-latest publish-version publish-latest tag
release:
$(MAKE) build-docker-linux
$(MAKE) build-docker-linux-cgo
$(MAKE) build-darwin
$(MAKE) build-docker-linux VERSION=latest
$(MAKE) build-docker-linux-cgo VERSION=latest
$(MAKE) build-darwin VERSION=latest
$(MAKE) publish-version
$(MAKE) publish-latest
$(MAKE) tag

0 comments on commit 72aafb4

Please sign in to comment.