Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify CI test matrix, Add windows #2249

Merged
merged 10 commits into from
Nov 16, 2018
67 changes: 31 additions & 36 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,55 +1,50 @@
language: go

sudo: required

os:
- linux
- osx
- windows
go:
- 1.6.x
- 1.7.x
- 1.8.x
- 1.9.x
- 1.10.x
- 1.11.x
- tip

matrix:
allow_failures:
- go: tip
- os: windows
exclude:
# OSX 1.6.4 is not present in travis.
# https://github.com/travis-ci/travis-ci/issues/10309
- go: 1.6.x
os: osx
include:
- os: linux
sudo: required
go: 1.5.x
# Use Go 1.5's vendoring experiment for 1.5 tests.
env: GO15VENDOREXPERIMENT=1
- os: linux
sudo: required
go: 1.6.x
- os: linux
sudo: required
go: 1.7.x
- os: linux
sudo: required
go: 1.8.x
- os: linux
sudo: required
go: 1.9.x
- os: linux
sudo: required
go: 1.10.x
- os: linux
sudo: required
go: 1.11.x
- os: linux
sudo: required
go: tip
- os: osx
go: 1.7.x
- os: osx
go: 1.8.x
- os: osx
go: 1.9.x
- os: osx
go: 1.10.x
- os: osx
go: 1.11.x
- os: osx
go: tip
- os: windows
go: 1.5.x
# Use Go 1.5's vendoring experiment for 1.5 tests.
env: GO15VENDOREXPERIMENT=1

script:
- if [ $TRAVIS_GO_VERSION == "tip" ] ||
[ $TRAVIS_GO_VERSION == "1.11.x" ] ||
[ $TRAVIS_GO_VERSION == "1.10.x" ]; then
make ci-test;
if [[ $TRAVIS_OS_NAME == 'windows' ]]; then
make get-deps unit-old-go-race-cover;
else
make ci-test;
fi
else
make unit-old-go-race-cover;
make unit-old-go-race-cover;
fi

branches:
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ gen-protocol-test: get-deps-codegen
gen-endpoints: get-deps-codegen
go generate ./models/endpoints/

cleanup-models:
cleanup-models: get-deps-codegen
@echo "Cleaning up stale model versions"
@./cleanup_models.sh
go run -tags codegen ./private/model/cli/cleanup-models/* "./models/apis/*/*/api-2.json"

unit: get-deps verify
@echo "go test SDK and vendor packages"
Expand Down Expand Up @@ -186,7 +186,7 @@ get-deps-integ: get-deps-tests
@echo "go get SDK integ testing dependencies"
go get github.com/gucumber/gucumber/cmd/gucumber

get-deps-codegen:
get-deps-codegen: get-deps-x-tests
@echo "go get SDK codegen dependencies"
go get golang.org/x/net/html

Expand Down
17 changes: 17 additions & 0 deletions aws/session/custom_ca_bundle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"net"
"net/http"
"os"
"runtime"
"strings"
"testing"
"time"
Expand Down Expand Up @@ -40,7 +41,17 @@ func TestMain(m *testing.M) {
os.Exit(code)
}

// Skips the unit test on travis environment.
func skipTravisTest(t *testing.T) {
// Travis windows environment fails with TLS error when trying to run the unit test.
if ver, goos := os.Getenv("TRAVIS_GO_VERSION"), runtime.GOOS; len(ver) != 0 && goos == "windows" {
t.Skipf("skipping test, not functional with %s, %s", ver, goos)
}
}

func TestNewSession_WithCustomCABundle_Env(t *testing.T) {
skipTravisTest(t)

oldEnv := initSessionTestEnv()
defer awstesting.PopEnv(oldEnv)

Expand Down Expand Up @@ -93,6 +104,8 @@ func TestNewSession_WithCustomCABundle_EnvNotExists(t *testing.T) {
}

func TestNewSession_WithCustomCABundle_Option(t *testing.T) {
skipTravisTest(t)

oldEnv := initSessionTestEnv()
defer awstesting.PopEnv(oldEnv)

Expand Down Expand Up @@ -128,6 +141,8 @@ func TestNewSession_WithCustomCABundle_Option(t *testing.T) {
}

func TestNewSession_WithCustomCABundle_OptionPriority(t *testing.T) {
skipTravisTest(t)

oldEnv := initSessionTestEnv()
defer awstesting.PopEnv(oldEnv)

Expand Down Expand Up @@ -198,6 +213,8 @@ func TestNewSession_WithCustomCABundle_UnsupportedTransport(t *testing.T) {
}

func TestNewSession_WithCustomCABundle_TransportSet(t *testing.T) {
skipTravisTest(t)

oldEnv := initSessionTestEnv()
defer awstesting.PopEnv(oldEnv)

Expand Down
9 changes: 0 additions & 9 deletions cleanup_models.sh

This file was deleted.

2 changes: 2 additions & 0 deletions internal/shareddefaults/shared_config_other_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !windows

package shareddefaults_test

import (
Expand Down
2 changes: 2 additions & 0 deletions internal/shareddefaults/shared_config_windows_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build windows

package shareddefaults_test

import (
Expand Down
2 changes: 1 addition & 1 deletion private/model/api/customization_passes.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func mergeServicesCustomizations(a *API) {
p := strings.Replace(a.path, info.srcName, info.dstName, -1)

if info.serviceVersion != "" {
index := strings.LastIndex(p, "/")
index := strings.LastIndex(p, string(filepath.Separator))
files, _ := ioutil.ReadDir(p[:index])
if len(files) > 1 {
panic("New version was introduced")
Expand Down
9 changes: 6 additions & 3 deletions private/model/api/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ func ExpandModelGlobPath(globs ...string) ([]string, error) {
return modelPaths, nil
}

func trimModelServiceVersions(modelPaths []string) []string {
// TrimModelServiceVersions sorts the model paths by service version then
// returns recent model versions, and model version excluded.
func TrimModelServiceVersions(modelPaths []string) (include, exclude []string) {
sort.Strings(modelPaths)

// Remove old API versions from list
Expand All @@ -115,13 +117,14 @@ func trimModelServiceVersions(modelPaths []string) []string {

if _, ok := m[svc]; ok {
// Removed unused service version
modelPaths = append(modelPaths[:i], modelPaths[i+1:]...)
exclude = append(exclude, modelPaths[i])
continue
}
include = append(include, modelPaths[i])
m[svc] = struct{}{}
}

return modelPaths
return include, exclude
}

// Attach opens a file by name, and unmarshal its JSON data.
Expand Down
39 changes: 25 additions & 14 deletions private/model/api/load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package api

import (
"path/filepath"
"reflect"
"strconv"
"testing"
Expand Down Expand Up @@ -35,30 +36,40 @@ func TestResolvedReferences(t *testing.T) {

func TestTrimModelServiceVersions(t *testing.T) {
cases := []struct {
Paths []string
Expect []string
Paths []string
Include []string
Exclude []string
}{
{
Paths: []string{
"foo/baz/2018-01-02",
"foo/baz/2019-01-02",
"foo/baz/2017-01-02",
"foo/bar/2019-01-02",
"foo/bar/2013-04-02",
"foo/bar/2019-01-03",
filepath.Join("foo", "baz", "2018-01-02"),
filepath.Join("foo", "baz", "2019-01-02"),
filepath.Join("foo", "baz", "2017-01-02"),
filepath.Join("foo", "bar", "2019-01-02"),
filepath.Join("foo", "bar", "2013-04-02"),
filepath.Join("foo", "bar", "2019-01-03"),
},
Expect: []string{
"foo/bar/2019-01-03",
"foo/baz/2019-01-02",
Include: []string{
filepath.Join("foo", "baz", "2019-01-02"),
filepath.Join("foo", "bar", "2019-01-03"),
},
Exclude: []string{
filepath.Join("foo", "baz", "2018-01-02"),
filepath.Join("foo", "baz", "2017-01-02"),
filepath.Join("foo", "bar", "2019-01-02"),
filepath.Join("foo", "bar", "2013-04-02"),
},
},
}

for i, c := range cases {
t.Run(strconv.Itoa(i), func(t *testing.T) {
result := trimModelServiceVersions(c.Paths)
if e, a := c.Expect, result; !reflect.DeepEqual(e, a) {
t.Errorf("expect %v, got %v", e, a)
include, exclude := TrimModelServiceVersions(c.Paths)
if e, a := c.Include, include; !reflect.DeepEqual(e, a) {
t.Errorf("expect include %v, got %v", e, a)
}
if e, a := c.Exclude, exclude; !reflect.DeepEqual(e, a) {
t.Errorf("expect exclude %v, got %v", e, a)
}
})
}
Expand Down
27 changes: 27 additions & 0 deletions private/model/cli/cleanup-models/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// +build codegen

package main

import (
"fmt"
"os"
"path/filepath"

"github.com/aws/aws-sdk-go/private/model/api"
)

func main() {
glob := filepath.FromSlash(os.Args[1])
modelPaths, err := api.ExpandModelGlobPath(glob)
if err != nil {
fmt.Fprintf(os.Stderr, "failed to expand glob, %v\n", err)
os.Exit(1)
}

_, excluded := api.TrimModelServiceVersions(modelPaths)

for _, exclude := range excluded {
fmt.Println("removing:", exclude)
os.Remove(exclude)
}
}
10 changes: 9 additions & 1 deletion private/model/cli/gen-api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,19 @@ func main() {
api.LogDebug(os.Stdout)
}

modelPaths, err := api.ExpandModelGlobPath(flag.Args()...)
// Make sure all paths are based on platform's pathing not Unix
globs := flag.Args()
for i, g := range globs {
globs[i] = filepath.FromSlash(g)
}
svcPath = filepath.FromSlash(svcPath)

modelPaths, err := api.ExpandModelGlobPath(globs...)
if err != nil {
fmt.Fprintln(os.Stderr, "failed to glob file pattern", err)
os.Exit(1)
}
modelPaths, _ = api.TrimModelServiceVersions(modelPaths)

apis, err := api.LoadAPIs(modelPaths, svcImportPath)
if err != nil {
Expand Down