Skip to content

Commit

Permalink
Merge pull request #5 from erbesharat/feature/travis
Browse files Browse the repository at this point in the history
[make]: Add Makefile and TravisCI config
  • Loading branch information
stp-ip authored Sep 6, 2019
2 parents 3b9c11f + adc60ce commit 070f22f
Show file tree
Hide file tree
Showing 5 changed files with 410 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
language: minimal

services:
- docker

script:
- make docker-test
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM alpine:3.10

RUN apk --no-cache add ca-certificates

ADD gomods /gomods

CMD ["/gomods"]
36 changes: 36 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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)
9 changes: 9 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module go.okkur.org/gomods

go 1.13

require (
github.com/caddyserver/caddy v1.0.3
github.com/gomods/athens v0.5.0
github.com/spf13/afero v1.2.2
)
Loading

0 comments on commit 070f22f

Please sign in to comment.