# The builder and linter for this repository
# Notice how we depend upon nothing twitch specific: just pulling the core golang docker image
FROM golang:1.15.6

# Do this first so this step is cached
RUN GO111MODULE=on go get honnef.co/go/tools/cmd/staticcheck@c6fa781e62570f5844fcf7ee0a156d49c11a1560
ENV GOFLAGS=-mod=vendor
# Go modules don't need to be in GOPATH.  Just build/test inside app
WORKDIR /app

# Add our code, build it, test it, etc
ADD . .
# Make sure our code builds
RUN go build ./...
# Lint our code
#RUN staticcheck ./...  # RIP the lint
# Run the unit tests with the race detector
RUN go test -race -cover -coverprofile=coverage.txt -covermode=atomic ./...
# Upload code coverage
RUN curl -s https://codecov.xarth.tv/bash | CODECOV_TOKEN=ghe bash -s - || true
