Add unit tests to build. Pin to specific Alpine tag.

Signed-off-by: Alex Ellis <alexellis2@gmail.com>
This commit is contained in:
Alex Ellis
2017-10-26 21:02:50 +01:00
parent dce748e2a1
commit 12a0c75e91
6 changed files with 17 additions and 14 deletions

View File

@ -13,9 +13,12 @@ COPY queue queue
COPY plugin plugin COPY plugin plugin
COPY server.go . COPY server.go .
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o gateway . # Run a gofmt and exclude all vendored code.
RUN test -z "$(gofmt -l $(find . -type f -name '*.go' -not -path "./vendor/*"))" \
&& go test $(go list ./... | grep -v integration | grep -v /vendor/ | grep -v /template/) -cover \
&& CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o gateway .
FROM alpine:latest FROM alpine:3.6
WORKDIR /root/ WORKDIR /root/
EXPOSE 8080 EXPOSE 8080

View File

@ -12,11 +12,11 @@ import (
"io/ioutil" "io/ioutil"
"github.com/openfaas/faas/gateway/metrics"
"github.com/openfaas/faas/gateway/requests"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/filters"
"github.com/docker/docker/client" "github.com/docker/docker/client"
"github.com/openfaas/faas/gateway/metrics"
"github.com/openfaas/faas/gateway/requests"
) )
func MakeDeleteFunctionHandler(metricsOptions metrics.MetricOptions, c *client.Client) http.HandlerFunc { func MakeDeleteFunctionHandler(metricsOptions metrics.MetricOptions, c *client.Client) http.HandlerFunc {

View File

@ -10,9 +10,9 @@ import (
"net/url" "net/url"
"github.com/Sirupsen/logrus" "github.com/Sirupsen/logrus"
"github.com/gorilla/mux"
"github.com/openfaas/faas/gateway/metrics" "github.com/openfaas/faas/gateway/metrics"
"github.com/openfaas/faas/gateway/queue" "github.com/openfaas/faas/gateway/queue"
"github.com/gorilla/mux"
) )
// MakeQueuedProxy accepts work onto a queue // MakeQueuedProxy accepts work onto a queue

View File

@ -11,11 +11,11 @@ import (
"strings" "strings"
"github.com/openfaas/faas/gateway/metrics"
"github.com/openfaas/faas/gateway/requests"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/filters"
"github.com/docker/docker/client" "github.com/docker/docker/client"
"github.com/openfaas/faas/gateway/metrics"
"github.com/openfaas/faas/gateway/requests"
) )
// MakeFunctionReader gives a summary of Function structs with Docker service stats overlaid with Prometheus counters. // MakeFunctionReader gives a summary of Function structs with Docker service stats overlaid with Prometheus counters.

View File

@ -9,8 +9,8 @@ import (
"strings" "strings"
"testing" "testing"
"github.com/openfaas/faas/gateway/handlers"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/openfaas/faas/gateway/handlers"
) )
func TestBuildEncodedAuthConfig(t *testing.T) { func TestBuildEncodedAuthConfig(t *testing.T) {