Skip to content

Commit

Permalink
Fixes to devops CI (#5239)
Browse files Browse the repository at this point in the history
* Fixes to devops CI

Add devops badge to README
Fix lint and vet steps

* limit linter to subset of repo

fix golint errors

* more linter fixes

* more linter fixes

* add remaining tests

* include combined output when running git commands

* enable dotglob so hidden dirs are moved
  • Loading branch information
jhendrixMSFT authored Jul 15, 2019
1 parent b5629c7 commit acb8940
Show file tree
Hide file tree
Showing 11 changed files with 105 additions and 87 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

[![Build Status](https://travis-ci.org/Azure/azure-sdk-for-go.svg?branch=master)](https://travis-ci.org/Azure/azure-sdk-for-go)

[![Build Status](https://dev.azure.com/azure-sdk/public/_apis/build/status/go/Azure.azure-sdk-for-go?branchName=latest)](https://dev.azure.com/azure-sdk/public/_build/latest?definitionId=640&branchName=latest)

[![Go Report Card](https://goreportcard.com/badge/github.com/Azure/azure-sdk-for-go)](https://goreportcard.com/report/github.com/Azure/azure-sdk-for-go)

azure-sdk-for-go provides Go packages for managing and using Azure services.
Expand Down
20 changes: 16 additions & 4 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ variables:
GOROOT: '/usr/local/go1.12'
GOPATH: '$(system.defaultWorkingDirectory)/work'
sdkPath: '$(GOPATH)/src/github.com/$(build.repository.name)'
IGNORE_BREAKING_CHANGES: true

steps:
- script: |
set -e
mkdir -p '$(GOPATH)/bin'
mkdir -p '$(sdkPath)'
shopt -s extglob
shopt -s dotglob extglob
mv !(work) '$(sdkPath)'
echo '##vso[task.prependpath]$(GOROOT)/bin'
echo '##vso[task.prependpath]$(GOPATH)/bin'
Expand All @@ -20,7 +21,7 @@ steps:
set -e
curl -sSL https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
dep ensure -v
go install ./vendor/golang.org/x/lint/golint
go get -u golang.org/x/lint/golint
workingDirectory: '$(sdkPath)'
displayName: 'Install Dependencies'
- script: go vet $(go list ./... | grep -v vendor)
Expand All @@ -29,17 +30,28 @@ steps:
- script: go build -v $(go list ./... | grep -v vendor)
workingDirectory: '$(sdkPath)'
displayName: 'Build'
- script: go test $(dirname $(find . -path ./vendor -prune -o -name '*_test.go' -print) | sort -u)
workingDirectory: '$(sdkPath)'
displayName: 'Run Tests'
- script: go run ./tools/apidiff/main.go packages ./services FETCH_HEAD~1 FETCH_HEAD --copyrepo --breakingchanges || $IGNORE_BREAKING_CHANGES
workingDirectory: '$(sdkPath)'
displayName: 'Display Breaking Changes'
- script: go run ./tools/pkgchk/main.go ./services --exceptions ./tools/pkgchk/exceptions.txt
workingDirectory: '$(sdkPath)'
displayName: 'Verify Package Directory'
- script: grep -L -r --include *.go --exclude-dir vendor -P "Copyright (\d{4}|\(c\)) Microsoft" ./ | tee >&2
workingDirectory: '$(sdkPath)'
displayName: 'Copyright Header Check'
failOnStderr: true
condition: succeededOrFailed()
- script: gofmt -s -l -w $(go list ./... | grep -v vendor) >&2
- script: gofmt -s -l -w $(find . -path ./vendor -prune -o -name '*.go' -print) >&2
workingDirectory: '$(sdkPath)'
displayName: 'Format Check'
failOnStderr: true
condition: succeededOrFailed()
- script: golint $(go list ./... | grep -v vendor) >&2
- script: |
golint ./storage/... >&2
golint ./tools/... >&2
workingDirectory: '$(sdkPath)'
displayName: 'Linter Check'
failOnStderr: true
Expand Down
4 changes: 4 additions & 0 deletions storage/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ const fourMB = uint64(4194304)
const oneTB = uint64(1099511627776)

// Export maximum range and file sizes

// MaxRangeSize defines the maximum size in bytes for a file range.
const MaxRangeSize = fourMB

// MaxFileSize defines the maximum size in bytes for a file.
const MaxFileSize = oneTB

// File represents a file on a share.
Expand Down
6 changes: 3 additions & 3 deletions tools/apidiff/cmd/packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ type CommitPkgsReport struct {
CommitsReports map[string]pkgsReport `json:"deltas"`
}

// returns true if the report contains no data
// IsEmpty returns true if the report contains no data.
func (c CommitPkgsReport) IsEmpty() bool {
for _, r := range c.CommitsReports {
if !r.isEmpty() {
Expand All @@ -201,7 +201,7 @@ func (c CommitPkgsReport) IsEmpty() bool {
return true
}

// returns true if the report contains breaking changes
// HasBreakingChanges returns true if the report contains breaking changes.
func (c CommitPkgsReport) HasBreakingChanges() bool {
for _, r := range c.CommitsReports {
if r.hasBreakingChanges() {
Expand All @@ -211,7 +211,7 @@ func (c CommitPkgsReport) HasBreakingChanges() bool {
return false
}

// returns true if the package contains additive changes
// HasAdditiveChanges returns true if the package contains additive changes.
func (c CommitPkgsReport) HasAdditiveChanges() bool {
for _, r := range c.CommitsReports {
if r.hasAdditiveChanges() {
Expand Down
74 changes: 37 additions & 37 deletions tools/apidiff/delta/delta_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ func Test_GetAddedExports(t *testing.T) {
}

cAdded := map[string]exports.Const{
"Blue": exports.Const{Type: "Color", Value: "Blue"},
"Green": exports.Const{Type: "Color", Value: "Green"},
"Red": exports.Const{Type: "Color", Value: "Red"},
"Holiday": exports.Const{Type: "DayOfWeek", Value: "Holiday"},
"Blue": {Type: "Color", Value: "Blue"},
"Green": {Type: "Color", Value: "Green"},
"Red": {Type: "Color", Value: "Red"},
"Holiday": {Type: "DayOfWeek", Value: "Holiday"},
}

for k, v := range cAdded {
Expand All @@ -72,12 +72,12 @@ func Test_GetAddedExports(t *testing.T) {
}

fAdded := map[string]exports.Func{
"DoNothing2": exports.Func{},
"Client.ExportData": exports.Func{Params: strPtr("context.Context,string,string,ExportRDBParameters"), Returns: strPtr("ExportDataFuture,error")},
"Client.ExportDataPreparer": exports.Func{Params: strPtr("context.Context,string,string,ExportRDBParameters"), Returns: strPtr("*http.Request,error")},
"Client.ExportDataSender": exports.Func{Params: strPtr("*http.Request"), Returns: strPtr("ExportDataFuture,error")},
"Client.ExportDataResponder": exports.Func{Params: strPtr("*http.Response"), Returns: strPtr("autorest.Response,error")},
"ExportDataFuture.Result": exports.Func{Params: strPtr("Client"), Returns: strPtr("autorest.Response,error")},
"DoNothing2": {},
"Client.ExportData": {Params: strPtr("context.Context,string,string,ExportRDBParameters"), Returns: strPtr("ExportDataFuture,error")},
"Client.ExportDataPreparer": {Params: strPtr("context.Context,string,string,ExportRDBParameters"), Returns: strPtr("*http.Request,error")},
"Client.ExportDataSender": {Params: strPtr("*http.Request"), Returns: strPtr("ExportDataFuture,error")},
"Client.ExportDataResponder": {Params: strPtr("*http.Response"), Returns: strPtr("autorest.Response,error")},
"ExportDataFuture.Result": {Params: strPtr("Client"), Returns: strPtr("autorest.Response,error")},
}

for k, v := range fAdded {
Expand All @@ -100,12 +100,12 @@ func Test_GetAddedExports(t *testing.T) {
}

iAdded := map[string]exports.Interface{
"NewInterface": exports.Interface{Methods: map[string]exports.Func{
"One": exports.Func{Params: strPtr("int")},
"Two": exports.Func{Returns: strPtr("error")},
"NewInterface": {Methods: map[string]exports.Func{
"One": {Params: strPtr("int")},
"Two": {Returns: strPtr("error")},
}},
"SomeInterface": exports.Interface{Methods: map[string]exports.Func{
"NewMethod": exports.Func{Params: strPtr("string"), Returns: strPtr("bool,error")},
"SomeInterface": {Methods: map[string]exports.Func{
"NewMethod": {Params: strPtr("string"), Returns: strPtr("bool,error")},
}},
}

Expand All @@ -129,23 +129,23 @@ func Test_GetAddedExports(t *testing.T) {
}

sAdded := map[string]exports.Struct{
"ExportDataFuture": exports.Struct{
"ExportDataFuture": {
AnonymousFields: []string{"azure.Future"},
Fields: map[string]string{"NewField": "string"},
},
"ExportRDBParameters": exports.Struct{
"ExportRDBParameters": {
Fields: map[string]string{
"Format": "*string",
"Prefix": "*string",
"Container": "*string",
},
},
"CreateProperties": exports.Struct{
"CreateProperties": {
Fields: map[string]string{
"NewField": "*float64",
},
},
"DeleteFuture": exports.Struct{
"DeleteFuture": {
Fields: map[string]string{
"NewField": "string",
},
Expand Down Expand Up @@ -174,10 +174,10 @@ func Test_GetAddedStructFields(t *testing.T) {
}

added := map[string]exports.Struct{
"CreateProperties": exports.Struct{
"CreateProperties": {
Fields: map[string]string{"NewField": "*float64"},
},
"DeleteFuture": exports.Struct{
"DeleteFuture": {
Fields: map[string]string{"NewField": "string"},
},
}
Expand All @@ -197,9 +197,9 @@ func Test_GetAddedInterfaceMethods(t *testing.T) {
}

added := map[string]exports.Interface{
"SomeInterface": exports.Interface{
"SomeInterface": {
Methods: map[string]exports.Func{
"NewMethod": exports.Func{Params: strPtr("string"), Returns: strPtr("bool,error")},
"NewMethod": {Params: strPtr("string"), Returns: strPtr("bool,error")},
},
},
}
Expand Down Expand Up @@ -268,23 +268,23 @@ func Test_GetFuncSigChanges(t *testing.T) {
}

changed := map[string]delta.FuncSig{
"DoNothing": delta.FuncSig{
"DoNothing": {
Params: &delta.Signature{From: delta.None, To: "string"},
},
"DoNothingWithParam": delta.FuncSig{
"DoNothingWithParam": {
Params: &delta.Signature{From: "int", To: delta.None},
},
"Client.List": delta.FuncSig{
"Client.List": {
Params: &delta.Signature{From: "context.Context", To: "context.Context,string"},
Returns: &delta.Signature{From: "ListResultPage,error", To: "ListResult,error"},
},
"Client.ListPreparer": delta.FuncSig{
"Client.ListPreparer": {
Params: &delta.Signature{From: "context.Context", To: "context.Context,string"},
},
"Client.Delete": delta.FuncSig{
"Client.Delete": {
Params: &delta.Signature{From: "context.Context,string,string", To: "context.Context,string"},
},
"Client.DeletePreparer": delta.FuncSig{
"Client.DeletePreparer": {
Params: &delta.Signature{From: "context.Context,string,string", To: "context.Context,string"},
},
}
Expand Down Expand Up @@ -313,10 +313,10 @@ func Test_GetInterfaceMethodSigChanges(t *testing.T) {
}

changed := map[string]delta.InterfaceDef{
"SomeInterface": delta.InterfaceDef{
"SomeInterface": {
MethodSigs: map[string]delta.FuncSig{
"One": delta.FuncSig{Params: &delta.Signature{From: delta.None, To: "string"}},
"Two": delta.FuncSig{Params: &delta.Signature{From: "bool", To: "bool,int"}},
"One": {Params: &delta.Signature{From: delta.None, To: "string"}},
"Two": {Params: &delta.Signature{From: "bool", To: "bool,int"}},
},
},
}
Expand Down Expand Up @@ -345,15 +345,15 @@ func Test_GetStructFieldChanges(t *testing.T) {
}

changed := map[string]delta.StructDef{
"CreateProperties": delta.StructDef{
"CreateProperties": {
Fields: map[string]delta.Signature{
"SubnetID": delta.Signature{From: "*string", To: "*int"},
"RedisConfiguration": delta.Signature{From: "map[string]*string", To: "interface{}"},
"SubnetID": {From: "*string", To: "*int"},
"RedisConfiguration": {From: "map[string]*string", To: "interface{}"},
},
},
"ListResult": delta.StructDef{
"ListResult": {
Fields: map[string]delta.Signature{
"NextLink": delta.Signature{From: "*string", To: "string"},
"NextLink": {From: "*string", To: "string"},
},
},
}
Expand Down
10 changes: 5 additions & 5 deletions tools/apidiff/exports/package_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,23 +104,23 @@ func Test_Interfaces(t *testing.T) {
}{
{"SomeInterface", exports.Interface{
Methods: map[string]exports.Func{
"One": exports.Func{
"One": {
Params: nil,
Returns: nil,
},
"Two": exports.Func{
"Two": {
Params: strPtr("bool"),
Returns: nil,
},
"Three": exports.Func{
"Three": {
Params: nil,
Returns: strPtr("string"),
},
"Four": exports.Func{
"Four": {
Params: strPtr("int"),
Returns: strPtr("error"),
},
"Five": exports.Func{
"Five": {
Params: strPtr("int,bool"),
Returns: strPtr("int,error"),
},
Expand Down
2 changes: 1 addition & 1 deletion tools/deprecate/cmd/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func addDeprecationComment(cg *ast.CommentGroup, message string) {
}
// create a new comment and add it to the beginning of the comment group
nd := []*ast.Comment{
&ast.Comment{
{
Text: fmt.Sprintf("// Deprecated: %s", message),
Slash: cg.Pos() - 1,
},
Expand Down
4 changes: 2 additions & 2 deletions tools/profileBuilder/model/latest.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ var versionLE = func() func(string, string) (bool, error) {
// inconsistencies in the directory structure (e.g. v1, 6.2, v1.0 etc). given this we must always check
// the API version strategry first as the semver strategy can match an API version yielding incorrect results.
wellKnownStrategies := []strategyTuple{
strategyTuple{
{
match: regexp.MustCompile(`^(?P<year>\d{4})-(?P<month>\d{2})-(?P<day>\d{2})(?:[\.\-](?P<tag>.+))?$`),
handler: func(leftMatch, rightMatch []string) (bool, error) {
var err error
Expand Down Expand Up @@ -197,7 +197,7 @@ var versionLE = func() func(string, string) (bool, error) {
return true, nil
},
},
strategyTuple{
{
match: regexp.MustCompile(`(?P<major>\d+)(?:\.(?P<minor>\d+)(?:\.(?P<patch>\d+))?-?(?P<tag>.*))?`),
handler: func(leftMatch, rightMatch []string) (bool, error) {
for i := 1; i <= 3; i++ {
Expand Down
Loading

0 comments on commit acb8940

Please sign in to comment.