Skip to content

Commit

Permalink
Merge pull request #73 from operable/cm/travis
Browse files Browse the repository at this point in the history
Add initial Travis CI configuration
  • Loading branch information
christophermaier authored Mar 14, 2017
2 parents fc1a6f4 + 253add5 commit 726704b
Show file tree
Hide file tree
Showing 1,700 changed files with 360,667 additions and 73 deletions.
21 changes: 0 additions & 21 deletions .buildkite/scripts/build_executable.sh

This file was deleted.

20 changes: 0 additions & 20 deletions .buildkite/scripts/smoke_test.sh

This file was deleted.

1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
vendor/*/
*-test
*.test
**/*.test
Expand Down
16 changes: 16 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
sudo: required

services:
- docker

before_install:
- docker build -t operable/go-relay-testing -f Dockerfile.ci .

# Need the job ID in order to upload the Coveralls data
script:
- docker run -it --rm --env="TRAVIS_JOB_ID=${TRAVIS_JOB_ID}" operable/go-relay-testing make ci-coveralls
- scripts/smoke_test.sh

notifications:
slack:
secure: d0xJV5ZZ6wUqeQiUuMbM+6Goeejv38HpqK3UybzIEf8B7tjc7eljWZTU/+qYlqjzCzd5Kxwd+I3da5rP0oMeCuuWdjFWMTrrYOf2uGx9uVJ5D5dgNBvTWGQqE1KWWkoEEHAFChR/tw6KVqj5WG+yAEBJp0kVw2JiNdfo0X1YoaEvJcnJU1iqf3TtHHNk/XPQrwz2WSN9zNtzYKYrpnBEy+uK86SmgpUH7iggx8ZqwpKHknO6uPffD7PyPQq/zFEeWenbmeSSd9mT0F3rp6m8Zd0xnfRM3To0buu+isx1TBMECTli67G7kQlTDbmb6nL6F6yq1u/Vl1uJa8bm53wfwfKM25CMwTOkxyzgHFuKzaSiuyjfLESoz6wKmoQYFsMAoH4ZOmopsoQkJ49h472HMEa0iMkobJD01Mpjr5AhU1lazo8Fafz3BKoACH8GLIDrcHQmD0uC2plXsSWZAroy6DK0V8xkw27W7lnOi0Xq/yS5Ike2hqw+KBnLdwNUO8Nr2HmtkShXql+ovdIwxAA0JGj/h4DDkntoofAMIAeH3MHGa/6NoBlC+FXfpgFLM9vcStU9dFxFYufOcIlkIaZoBGVKOXPAgPaq6039XShGsXSQv+szFXiYi0H3fX3vSBaGOIhcw98EzUWH8LtByvMyiYCRUntZm/Xjnz8uGbS9b/Q=
1 change: 1 addition & 0 deletions Dockerfile.builder
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ FROM ubuntu:16.10
# running `go version`)
ENV GO_PACKAGE_VERSION 2:1.6.1+1ubuntu2
ENV GOPATH /gopath
ENV PATH=${GOPATH}/bin:${PATH}

RUN apt-get update && \
apt-get install -y \
Expand Down
4 changes: 4 additions & 0 deletions Dockerfile.ci
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
FROM operable/go:1.6.3

ENV PATH=${GOPATH}/bin:${PATH}
# Add goveralls for sending stats to coveralls.io in Travis CI
RUN go get github.com/mattn/goveralls

COPY . $GOPATH/src/github.com/operable/go-relay
WORKDIR $GOPATH/src/github.com/operable/go-relay
60 changes: 32 additions & 28 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
GOVENDOR_BIN = $(shell go env GOPATH)/bin/govendor
GOLINT_BIN = $(shell go env GOPATH)/bin/golint
PKG_DIRS := $(shell find . -type d | grep relay | grep -v vendor)
FULL_PKGS := $(sort $(foreach pkg, $(PKG_DIRS), $(subst ./, github.com/operable/go-relay/, $(pkg))))
SOURCES := $(shell find . -name "*.go" -type f)
VET_FLAGS = -v
BUILD_STAMP := $(shell date -u '+%Y%m%d%H%M%S')
BUILD_HASH := $(shell git rev-parse HEAD)
BUILD_TAG ?= $(shell scripts/build_tag.sh)
Expand All @@ -22,33 +19,48 @@ endif

all: test exe

exe: $(BUILD_DIR)/$(EXENAME)
deps:
govendor sync

tools: $(GOVENDOR_BIN) $(GOLINT_BIN)
vet:
govendor vet -x +local

$(BUILD_DIR)/$(EXENAME): $(BUILD_DIR) $(SOURCES) tools deps
@rm -f `find . -name "*flymake*.go"`
@rm -rf relay_*_amd64
CGO_ENABLED=0 go build -ldflags "$(LINK_VARS)" -o $@ github.com/operable/go-relay
test:
govendor test +local -cover

lint: tools
@for pkg in $(FULL_PKGS); do $(GOLINT_BIN) $$pkg; done
# This is only intended to run in Travis CI and requires goveralls to
# be installed.
ci-coveralls: tools deps
goveralls -service=travis-ci

exe: clean-dev | $(BUILD_DIR)
CGO_ENABLED=0 govendor build -ldflags "$(LINK_VARS)" -o $(BUILD_DIR)/$(EXENAME)

test: tools deps lint
@rm -rf relay_*_amd64
@go vet $(VET_FLAGS) $(FULL_PKGS)
@go test -v -cover $(FULL_PKGS)
docker: export GOOS=linux
docker: export GOARCH=amd64
docker: clean exe do-docker-build

clean:
clean: clean-dev
rm -rf $(BUILD_DIR) relay-test
find . -name "*.test" -type f | xargs rm -fv
find . -name "*-test" -type f | xargs rm -fv

deps:
@$(GOVENDOR_BIN) sync
# Remove editor files (here, Emacs)
clean-dev:
rm -f `find . -name "*flymake*.go"`

$(BUILD_DIR):
mkdir -p $@

$(GOVENDOR_BIN):
go get -u github.com/kardianos/govendor
########################################################################
# The targets below stand to be cleaned up. Everything above here is
# analogous to what's in circuit-driver
#

tools: $(GOLINT_BIN)

lint: tools
@for pkg in $(FULL_PKGS); do $(GOLINT_BIN) $$pkg; done

$(GOLINT_BIN):
go get -u github.com/golang/lint/golint
Expand All @@ -62,16 +74,8 @@ $(TARBALL_NAME): test exe
tar czf $(TARBALL_NAME).tar.gz $(TARBALL_NAME)
rm -rf $(TARBALL_NAME)

docker:
make clean
GOOS=linux GOARCH=amd64 make exe
make do-docker-build

# Providing this solely for CI-built images. We will have already
# built the executable in a separate step. We split things up because
# we build inside a Docker image in CI (we don't have Go on builders).
do-docker-build:
docker build -t $(DOCKER_IMAGE) .

$(BUILD_DIR):
mkdir -p $@
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Relay

[![Build Status](https://travis-ci.org/operable/go-relay.svg?branch=master)](https://travis-ci.org/operable/go-relay)
[![Coverage Status](https://coveralls.io/repos/github/operable/go-relay/badge.svg?branch=master)](https://coveralls.io/github/operable/go-relay?branch=master)
[![Ebert](https://ebertapp.io/github/operable/go-relay.svg)](https://ebertapp.io/github/operable/go-relay)

## Dependencies

* Go v1.6+
Expand All @@ -14,13 +18,19 @@
git clone [email protected]:operable/go-relay.git $GOPATH/src/github.com/operable
```

2. Download deps and compile an executable
2. Install preqrequisites

```sh
go get -u github.com/kardianos/govendor
```

3. Download deps and compile an executable

```
make
```

3. Set environment variables and run `relay`.
4. Set environment variables and run `relay`.

You'll need to have a docker machine running and have environment variables
set for the docker client to connect to it. If you haven't already, run the
Expand Down
2 changes: 1 addition & 1 deletion scripts/build_tag.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Writes the current tag to standard out. If the current commit isn't
# tagged then the current branch name is used.
tag=`git describe --tags --exact-match`
tag=$(git describe --tags --exact-match 2>/dev/null)
if [ "$?" != 0 ]
then
tag=$(git rev-parse --abbrev-ref HEAD)
Expand Down
51 changes: 51 additions & 0 deletions scripts/smoke_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash

# Build a statically-linked Linux executable and then ensure that it
# can run on the specified platform.
#
# (We're specifically asserting here that the Relay executable can run
# on both glibc-based (e.g. Ubuntu) and musl-based (e.g. Alpine)
# Linuxes.)
#
# Intended for running in Travis CI.

# ENVIRONMENT VARIABLES:
########################################################################
#
# * TRAVIS_BUILD_ID
# * TRAVIS_COMMIT

set -euo pipefail

########################################################################
# Build the executable inside a Docker image and then extract that
# executable.

image="operable/relay:builder-${TRAVIS_BUILD_ID}-${TRAVIS_COMMIT}"
echo "--- Building ${image}"
docker build -t "$image" -f Dockerfile.builder .

executable_name="relay-${TRAVIS_BUILD_ID}-${TRAVIS_COMMIT}"
echo "--- Extracting executable as ${executable_name}"
container_id=$(docker create --entrypoint sh "$image")
docker cp "${container_id}:/usr/local/bin/relay" "${executable_name}"
docker rm "${container_id}"

########################################################################
# Run a minimal smoke test on the executable: try to find out the
# version of relay. We're just verifying that the executable can even
# run on this platform.

chmod a+x "${executable_name}"

for PLATFORM in alpine:3.4 ubuntu:16.10
do
echo "--- Running ${executable_name} on ${PLATFORM}"
set -x
docker run \
-it \
--rm \
-v "$(pwd):/testing" \
"${PLATFORM}" "/testing/${executable_name}" --version
set +x
done
22 changes: 22 additions & 0 deletions vendor/github.com/Microsoft/go-winio/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions vendor/github.com/Microsoft/go-winio/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 726704b

Please sign in to comment.