Stop build if gofmt returns files need to be re-formatted
Fix syntax for stack/stack.go and stack/stack_test.go Signed-off-by: Minh-Quan TRAN <account@itscaro.me>
This commit is contained in:
committed by
Alex Ellis
parent
76a9dd8dd8
commit
09c255a550
@@ -4,7 +4,7 @@ WORKDIR /go/src/github.com/alexellis/faas-cli
|
||||
COPY . .
|
||||
|
||||
# Run a gofmt and exclude all vendored code.
|
||||
RUN gofmt -l -d $(find . -type f -name '*.go' -not -path "./vendor/*")
|
||||
RUN test -z "$(gofmt -l $(find . -type f -name '*.go' -not -path "./vendor/*"))"
|
||||
|
||||
RUN GIT_COMMIT=$(git rev-list -1 HEAD) \
|
||||
&& CGO_ENABLED=0 GOOS=linux go build --ldflags "-s -w -X github.com/alexellis/faas-cli/commands.GitCommit=${GIT_COMMIT}" -a -installsuffix cgo -o faas-cli .
|
||||
|
||||
@@ -4,7 +4,7 @@ WORKDIR /go/src/github.com/alexellis/faas-cli
|
||||
COPY . .
|
||||
|
||||
# Run a gofmt and exclude all vendored code.
|
||||
RUN gofmt -l -d $(find . -type f -name '*.go' -not -path "./vendor/*")
|
||||
RUN test -z "$(gofmt -l $(find . -type f -name '*.go' -not -path "./vendor/*"))"
|
||||
|
||||
# ldflags "-s -w" strips binary
|
||||
# ldflags -X injects commit version into binary
|
||||
|
||||
4
build.sh
4
build.sh
@@ -1,9 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
# gofmt
|
||||
test 0 -ne `gofmt -l . | wc -l` && echo "gofmt needed for:\n" && gofmt -l . && exit 1
|
||||
|
||||
# build
|
||||
docker build --build-arg http_proxy=$http_proxy --build-arg https_proxy=$https_proxy -t faas-cli . && \
|
||||
docker create --name faas-cli faas-cli && \
|
||||
docker cp faas-cli:/root/faas-cli . && \
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
# gofmt
|
||||
test 0 -ne `gofmt -l . | wc -l` && echo "gofmt needed for:\n" && gofmt -l . && exit 1
|
||||
|
||||
# build
|
||||
docker build --build-arg http_proxy=$http_proxy --build-arg https_proxy=$https_proxy -t faas-cli . -f Dockerfile.redist && \
|
||||
docker create --name faas-cli faas-cli && \
|
||||
docker cp faas-cli:/root/faas-cli . && \
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
package stack
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"regexp"
|
||||
"errors"
|
||||
|
||||
"github.com/ryanuber/go-glob"
|
||||
yaml "gopkg.in/yaml.v2"
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
package stack
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"reflect"
|
||||
"sort"
|
||||
"testing"
|
||||
)
|
||||
|
||||
const TestData_1 string = `provider:
|
||||
@@ -49,152 +49,152 @@ const TestData_2 string = `provider:
|
||||
`
|
||||
|
||||
var ParseYAMLTests_Regex = []struct {
|
||||
title string
|
||||
searchTerm string
|
||||
functions []string
|
||||
file string
|
||||
expectError bool
|
||||
title string
|
||||
searchTerm string
|
||||
functions []string
|
||||
file string
|
||||
expectError bool
|
||||
}{
|
||||
{
|
||||
title: "Regex search for functions only containing 'node'",
|
||||
searchTerm: "node",
|
||||
functions: []string{"nodejs-echo"},
|
||||
file: TestData_1,
|
||||
expectError: false,
|
||||
title: "Regex search for functions only containing 'node'",
|
||||
searchTerm: "node",
|
||||
functions: []string{"nodejs-echo"},
|
||||
file: TestData_1,
|
||||
expectError: false,
|
||||
},
|
||||
{
|
||||
title: "Regex search for functions only containing 'echo'",
|
||||
searchTerm: "echo",
|
||||
functions: []string{"nodejs-echo", "ruby-echo"},
|
||||
file: TestData_1,
|
||||
expectError: false,
|
||||
title: "Regex search for functions only containing 'echo'",
|
||||
searchTerm: "echo",
|
||||
functions: []string{"nodejs-echo", "ruby-echo"},
|
||||
file: TestData_1,
|
||||
expectError: false,
|
||||
},
|
||||
{
|
||||
title: "Regex search for functions only containing '.+-.+'",
|
||||
searchTerm: ".+-.+",
|
||||
functions: []string{"abcd-eeee", "nodejs-echo", "ruby-echo", "url-ping"},
|
||||
file: TestData_1,
|
||||
expectError: false,
|
||||
title: "Regex search for functions only containing '.+-.+'",
|
||||
searchTerm: ".+-.+",
|
||||
functions: []string{"abcd-eeee", "nodejs-echo", "ruby-echo", "url-ping"},
|
||||
file: TestData_1,
|
||||
expectError: false,
|
||||
},
|
||||
{
|
||||
title: "Regex search for all functions: '.*'",
|
||||
searchTerm: ".*",
|
||||
functions: []string{"abcd-eeee", "imagemagick", "nodejs-echo", "ruby-echo", "url-ping"},
|
||||
file: TestData_1,
|
||||
expectError: false,
|
||||
title: "Regex search for all functions: '.*'",
|
||||
searchTerm: ".*",
|
||||
functions: []string{"abcd-eeee", "imagemagick", "nodejs-echo", "ruby-echo", "url-ping"},
|
||||
file: TestData_1,
|
||||
expectError: false,
|
||||
},
|
||||
{
|
||||
title: "Regex search for no functions: '----'",
|
||||
searchTerm: "----",
|
||||
functions: []string{},
|
||||
file: TestData_1,
|
||||
expectError: false,
|
||||
title: "Regex search for no functions: '----'",
|
||||
searchTerm: "----",
|
||||
functions: []string{},
|
||||
file: TestData_1,
|
||||
expectError: false,
|
||||
},
|
||||
{
|
||||
title: "Regex search for functions without dashes: '^[^-]+$'",
|
||||
searchTerm: "^[^-]+$",
|
||||
functions: []string{"imagemagick"},
|
||||
file: TestData_1,
|
||||
expectError: false,
|
||||
title: "Regex search for functions without dashes: '^[^-]+$'",
|
||||
searchTerm: "^[^-]+$",
|
||||
functions: []string{"imagemagick"},
|
||||
file: TestData_1,
|
||||
expectError: false,
|
||||
},
|
||||
{
|
||||
title: "Regex search for functions with 8 characters: '^.{8}$'",
|
||||
searchTerm: "^.{8}$",
|
||||
functions: []string{"url-ping"},
|
||||
file: TestData_1,
|
||||
expectError: false,
|
||||
title: "Regex search for functions with 8 characters: '^.{8}$'",
|
||||
searchTerm: "^.{8}$",
|
||||
functions: []string{"url-ping"},
|
||||
file: TestData_1,
|
||||
expectError: false,
|
||||
},
|
||||
{
|
||||
title: "Regex search for function with repeated 'e': 'e{2}'",
|
||||
searchTerm: "e{2}",
|
||||
functions: []string{"abcd-eeee"},
|
||||
file: TestData_1,
|
||||
expectError: false,
|
||||
title: "Regex search for function with repeated 'e': 'e{2}'",
|
||||
searchTerm: "e{2}",
|
||||
functions: []string{"abcd-eeee"},
|
||||
file: TestData_1,
|
||||
expectError: false,
|
||||
},
|
||||
{
|
||||
title: "Regex empty search term: ''",
|
||||
searchTerm: "",
|
||||
functions: []string{"abcd-eeee", "imagemagick", "nodejs-echo", "ruby-echo", "url-ping"},
|
||||
file: TestData_1,
|
||||
expectError: false,
|
||||
title: "Regex empty search term: ''",
|
||||
searchTerm: "",
|
||||
functions: []string{"abcd-eeee", "imagemagick", "nodejs-echo", "ruby-echo", "url-ping"},
|
||||
file: TestData_1,
|
||||
expectError: false,
|
||||
},
|
||||
{
|
||||
title: "Regex invalid regex 1: '['",
|
||||
searchTerm: "[",
|
||||
functions: []string{},
|
||||
file: TestData_1,
|
||||
expectError: true,
|
||||
title: "Regex invalid regex 1: '['",
|
||||
searchTerm: "[",
|
||||
functions: []string{},
|
||||
file: TestData_1,
|
||||
expectError: true,
|
||||
},
|
||||
{
|
||||
title: "Regex invalid regex 2: '*'",
|
||||
searchTerm: "*",
|
||||
functions: []string{},
|
||||
file: TestData_1,
|
||||
expectError: true,
|
||||
title: "Regex invalid regex 2: '*'",
|
||||
searchTerm: "*",
|
||||
functions: []string{},
|
||||
file: TestData_1,
|
||||
expectError: true,
|
||||
},
|
||||
{
|
||||
title: "Regex invalid regex 3: '(\\w)\\1'",
|
||||
searchTerm: `(\w)\1`,
|
||||
functions: []string{},
|
||||
file: TestData_1,
|
||||
expectError: true,
|
||||
title: "Regex invalid regex 3: '(\\w)\\1'",
|
||||
searchTerm: `(\w)\1`,
|
||||
functions: []string{},
|
||||
file: TestData_1,
|
||||
expectError: true,
|
||||
},
|
||||
{
|
||||
title: "Regex empty search term in empty YAML file: ",
|
||||
searchTerm: "",
|
||||
functions: []string{},
|
||||
file: TestData_2,
|
||||
expectError: false,
|
||||
title: "Regex empty search term in empty YAML file: ",
|
||||
searchTerm: "",
|
||||
functions: []string{},
|
||||
file: TestData_2,
|
||||
expectError: false,
|
||||
},
|
||||
}
|
||||
|
||||
var ParseYAMLTests_Filter = []struct {
|
||||
title string
|
||||
searchTerm string
|
||||
functions []string
|
||||
file string
|
||||
title string
|
||||
searchTerm string
|
||||
functions []string
|
||||
file string
|
||||
}{
|
||||
{
|
||||
title: "Wildcard search for functions ending with 'echo'",
|
||||
searchTerm: "*echo",
|
||||
functions: []string{"nodejs-echo", "ruby-echo"},
|
||||
file: TestData_1,
|
||||
title: "Wildcard search for functions ending with 'echo'",
|
||||
searchTerm: "*echo",
|
||||
functions: []string{"nodejs-echo", "ruby-echo"},
|
||||
file: TestData_1,
|
||||
},
|
||||
{
|
||||
title: "Wildcard search for functions with a - in between two words: '*-*'",
|
||||
searchTerm: "*-*",
|
||||
functions: []string{"abcd-eeee", "nodejs-echo", "ruby-echo", "url-ping"},
|
||||
file: TestData_1,
|
||||
title: "Wildcard search for functions with a - in between two words: '*-*'",
|
||||
searchTerm: "*-*",
|
||||
functions: []string{"abcd-eeee", "nodejs-echo", "ruby-echo", "url-ping"},
|
||||
file: TestData_1,
|
||||
},
|
||||
{
|
||||
title: "Wildcard search for specific function: 'imagemagick'",
|
||||
searchTerm: "imagemagick",
|
||||
functions: []string{"imagemagick"},
|
||||
file: TestData_1,
|
||||
title: "Wildcard search for specific function: 'imagemagick'",
|
||||
searchTerm: "imagemagick",
|
||||
functions: []string{"imagemagick"},
|
||||
file: TestData_1,
|
||||
},
|
||||
{
|
||||
title: "Wildcard search for all functions: '*'",
|
||||
searchTerm: "*",
|
||||
functions: []string{"abcd-eeee", "imagemagick", "nodejs-echo", "ruby-echo", "url-ping"},
|
||||
file: TestData_1,
|
||||
title: "Wildcard search for all functions: '*'",
|
||||
searchTerm: "*",
|
||||
functions: []string{"abcd-eeee", "imagemagick", "nodejs-echo", "ruby-echo", "url-ping"},
|
||||
file: TestData_1,
|
||||
},
|
||||
{
|
||||
title: "Wildcard empty search term: ''",
|
||||
searchTerm: "",
|
||||
functions: []string{"abcd-eeee", "imagemagick", "nodejs-echo", "ruby-echo", "url-ping"},
|
||||
file: TestData_1,
|
||||
title: "Wildcard empty search term: ''",
|
||||
searchTerm: "",
|
||||
functions: []string{"abcd-eeee", "imagemagick", "nodejs-echo", "ruby-echo", "url-ping"},
|
||||
file: TestData_1,
|
||||
},
|
||||
{
|
||||
title: "Wildcard multiple wildcard characters: '**'",
|
||||
searchTerm: "**",
|
||||
functions: []string{"abcd-eeee", "imagemagick", "nodejs-echo", "ruby-echo", "url-ping"},
|
||||
file: TestData_1,
|
||||
title: "Wildcard multiple wildcard characters: '**'",
|
||||
searchTerm: "**",
|
||||
functions: []string{"abcd-eeee", "imagemagick", "nodejs-echo", "ruby-echo", "url-ping"},
|
||||
file: TestData_1,
|
||||
},
|
||||
{
|
||||
title: "Wildcard empty search term in empty YAML file: ''",
|
||||
searchTerm: "",
|
||||
functions: []string{},
|
||||
file: TestData_2,
|
||||
title: "Wildcard empty search term in empty YAML file: ''",
|
||||
searchTerm: "",
|
||||
functions: []string{},
|
||||
file: TestData_2,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user