mirror of https://github.com/knative/func.git
chore: run GH actions on Windows and macOS
This commit is contained in:
parent
7a648d2d23
commit
b7670a3f7b
|
@ -5,7 +5,10 @@ on: [pull_request]
|
|||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
os: ['ubuntu-latest', 'windows-latest', 'macos-latest']
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-go@v2
|
||||
|
|
4
Makefile
4
Makefile
|
@ -68,10 +68,10 @@ latest:
|
|||
docker push $(REPO):latest
|
||||
|
||||
bin/golangci-lint:
|
||||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ./bin v1.27.0
|
||||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ./bin v1.28.0
|
||||
|
||||
check: bin/golangci-lint
|
||||
./bin/golangci-lint run
|
||||
./bin/golangci-lint run --timeout 300s
|
||||
|
||||
release: build test
|
||||
go get -u github.com/git-chglog/git-chglog/cmd/git-chglog
|
||||
|
|
|
@ -1,75 +1,76 @@
|
|||
package faas
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestPathToDomain validatest the calculation used to derive a default domain
|
||||
// for a Function from the current directory path (used as a default
|
||||
// for a Function from the current directory filepath (used as a default
|
||||
// in the absence of an explicit setting).
|
||||
// NOTE: although the implementation uses os.PathSeparator and is developed with
|
||||
// non-unix platforms in mind, these tests are written using unix-style paths.
|
||||
func TestPathToDomain(t *testing.T) {
|
||||
var noLimit = -1
|
||||
tests := []struct {
|
||||
Path string // input path
|
||||
Path string // input filepath
|
||||
Limit int // upward recursion limit
|
||||
Domain string // Expected returned domain value
|
||||
}{
|
||||
// empty input should not find a domain.
|
||||
{"", noLimit, ""},
|
||||
{filepath.Join(""), noLimit, ""},
|
||||
|
||||
// trailing slashes ignored
|
||||
{"/home/user/example.com/admin/", noLimit, "admin.example.com"},
|
||||
{filepath.Join("home", "user", "example.com", "admin"), noLimit, "admin.example.com"},
|
||||
|
||||
// root path should not find a domain.
|
||||
{"/", noLimit, ""},
|
||||
// root filepath should not find a domain.
|
||||
{filepath.Join(""), noLimit, ""},
|
||||
|
||||
// valid path but without a domain should find no domain.
|
||||
{"/home/user", noLimit, ""},
|
||||
// valid filepath but without a domain should find no domain.
|
||||
{filepath.Join("home","user"), noLimit, ""},
|
||||
|
||||
// valid domain as the current directory should be found.
|
||||
{"/home/user/example.com", noLimit, "example.com"},
|
||||
{filepath.Join("home","user","example.com"), noLimit, "example.com"},
|
||||
|
||||
// valid domain as the current directory should be found even with recursion disabled.
|
||||
{"/home/user/example.com", 0, "example.com"},
|
||||
{filepath.Join("home", "user", "example.com"), 0, "example.com"},
|
||||
|
||||
// Subdomain
|
||||
{"/src/example.com/www", noLimit, "www.example.com"},
|
||||
{filepath.Join("src", "example.com", "www"), noLimit, "www.example.com"},
|
||||
|
||||
// Subdomain with recursion disabled should not find the domain.
|
||||
{"/src/example.com/www", 0, ""},
|
||||
{filepath.Join("src", "example.com", "www"), 0, ""},
|
||||
|
||||
// Sub-subdomain
|
||||
{"/src/example.com/www/test1", noLimit, "test1.www.example.com"},
|
||||
{filepath.Join("src", "example.com", "www", "test1"), noLimit, "test1.www.example.com"},
|
||||
|
||||
// Sub-subdomain with exact recursion limit to catch the domain
|
||||
{"/src/example.com/www/test1", 2, "test1.www.example.com"},
|
||||
{filepath.Join("src", "example.com", "www", "test1"), 2, "test1.www.example.com"},
|
||||
|
||||
// CWD a valid TLD+1 (not suggested, but supported)
|
||||
{"/src/my.example.com", noLimit, "my.example.com"},
|
||||
{filepath.Join("src", "my.example.com"), noLimit, "my.example.com"},
|
||||
|
||||
// Multi-level TLDs
|
||||
{"/src/example.co.uk", noLimit, "example.co.uk"},
|
||||
{filepath.Join("src", "example.co.uk"), noLimit, "example.co.uk"},
|
||||
|
||||
// Multi-level TLDs with sub
|
||||
{"/src/example.co.uk/www", noLimit, "www.example.co.uk"},
|
||||
{filepath.Join("src", "example.co.uk", "www"), noLimit, "www.example.co.uk"},
|
||||
|
||||
// Expected behavior is `test1.my.example.com` but will yield `test1.my`
|
||||
// because .my is a TLD hence the reason why dots in directories to denote
|
||||
// multiple levels of subdomain are technically supported but not
|
||||
// recommended: unexpected behavior because the public suffices list is
|
||||
// shifty.
|
||||
{"/src/example.com/test1.my", noLimit, "test1.my"},
|
||||
{filepath.Join("src", "example.com", "test1.my"), noLimit, "test1.my"},
|
||||
|
||||
// Ensure that cluster.local is explicitly allowed.
|
||||
{"/src/cluster.local/www", noLimit, "www.cluster.local"},
|
||||
{filepath.Join("src", "cluster.local", "www"), noLimit, "www.cluster.local"},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
domain := pathToDomain(test.Path, test.Limit)
|
||||
if domain != test.Domain {
|
||||
t.Fatalf("expected path '%v' (limit %v) to yield domain '%v', got '%v'", test.Path, test.Limit, test.Domain, domain)
|
||||
t.Fatalf("expected filepath '%v' (limit %v) to yield domain '%v', got '%v'", test.Path, test.Limit, test.Domain, domain)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package faas
|
|||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"testing"
|
||||
)
|
||||
|
||||
|
@ -30,10 +31,12 @@ func TestTemplatesEmbeddedFileMode(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if runtime.GOOS != "windows" {
|
||||
if dest.Mode() != sourceMode {
|
||||
t.Fatalf("The dest mode should be %v but was %v", sourceMode, dest.Mode())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TestTemplatesExtensibleFileMode ensures that files from a file-system
|
||||
// derived template is written with mode retained.
|
||||
|
@ -64,7 +67,9 @@ func TestTemplatesExtensibleFileMode(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if runtime.GOOS != "windows" {
|
||||
if dest.Mode() != source.Mode() {
|
||||
t.Fatalf("The dest mode should be %v but was %v", source.Mode(), dest.Mode())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue