Skip to content
Permalink
Browse files

(make): Add makefile and TravisCI config

  • Loading branch information...
erbesharat committed Sep 6, 2019
1 parent 3b9c11f commit 41d1787e07b553c51bb64fe7f165a4d586984bfc
Showing with 50 additions and 0 deletions.
  1. +7 −0 .travis.yml
  2. +7 −0 Dockerfile
  3. +36 −0 Makefile
@@ -0,0 +1,7 @@
language: minimal

services:
- docker

script:
- make docker-test
@@ -0,0 +1,7 @@
FROM alpine:3.10

RUN apk --no-cache add ca-certificates

ADD gomods /gomods

CMD ["/gomods"]
@@ -0,0 +1,36 @@
BIN := gomods
MAINTAINER := okkur
VERSION := 0.0.1
IMAGE := $(MAINTAINER)/$(BIN):$(VERSION)

BUILD_GOOS := $(if $(GOOS),$(GOOS),linux)
BUILD_GOARCH := $(if $(GOARCH),$(GOARCH),amd64)

CONTAINER ?= $(BIN)

.DEFAULT_GOAL := build

build:
cd cmd/gomods && \
GO111MODULE=on CGO_ENABLED=0 GOARCH=$(BUILD_GOARCH) GOOS=$(BUILD_GOOS) go build -ldflags="-s -w"
mv cmd/gomods/gomods ./$(BIN)

test:
GO111MODULE=on go test -v `go list ./... | grep -v .`

image-build: docker-build
docker build -t $(IMAGE) .

docker-run: image-build
docker run --name $(CONTAINER) $(IMAGE)

docker-test:
docker run --network=host -v $(shell pwd):/source -v $(GOPATH)/pkg/mod:/go/pkg/mod golang:1.13-alpine /bin/sh \
-c "cd /source && apk add git gcc musl-dev make && GOROOT=\"/usr/local/go\" make test"

docker-build:
docker run --network=host -v $(shell pwd):/source -v $(GOPATH)/pkg/mod:/go/pkg/mod golang:1.13-alpine /bin/sh \
-c "cd /source && apk add git gcc musl-dev make && make build"

version:
@echo $(VERSION)

0 comments on commit 41d1787

Please sign in to comment.
You can’t perform that action at this time.