From bc83b84928bfb7545631d6360a1285492eb8a4ac Mon Sep 17 00:00:00 2001 From: Arcturus Date: Fri, 18 Oct 2019 17:07:06 +0800 Subject: [PATCH] Update configuration (#1469) * Modify config for modulization * Add more test in moduler pipeline * Move from go 1.12 to go 1.13 * Track 1 should remain go 1.12 * Changed to match new requirement --- azure-pipelines.yml | 77 +++++++++++++++++++++++++++++------ moduler-pipelines.yml | 95 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 160 insertions(+), 12 deletions(-) create mode 100644 moduler-pipelines.yml diff --git a/azure-pipelines.yml b/azure-pipelines.yml index a5d740abb453..e63506d2df7c 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -1,14 +1,67 @@ -trigger: - branches: - include: - - master +jobs: + - job: Build_Test + strategy: + matrix: + Linux_Go112: + vm.image: 'ubuntu-18.04' + go.version: '1.12' + GOROOT: '/usr/local/go$(go.version)' + Linux_Go113: + vm.image: 'ubuntu-18.04' + go.version: '1.13' + GOROOT: '/usr/local/go$(go.version)' -stages: - - stage: Build_Test - jobs: - - template: .azure-pipelines/BuildTest.yml + pool: + vmImage: $(vm.image) - - stage: Module_Release - condition: and(succeeded(), in(variables['Build.Reason'], 'IndividualCI')) - jobs: - - template: .azure-pipelines/ModuleRelease.yml + variables: + GOPATH: '$(system.defaultWorkingDirectory)/work' + sdkPath: '$(GOPATH)/src/github.com/Azure/azure-sdk-for-go' + + steps: + - script: | + set -e + mkdir -p '$(GOPATH)/bin' + mkdir -p '$(sdkPath)' + shopt -s dotglob extglob + mv !(work) '$(sdkPath)' + echo '##vso[task.prependpath]$(GOROOT)/bin' + echo '##vso[task.prependpath]$(GOPATH)/bin' + displayName: 'Create Go Workspace' + - script: | + set -e + go version + curl -sSL https://raw.githubusercontent.com/golang/dep/master/install.sh | sh + dep ensure -v + go get -u golang.org/x/lint/golint + workingDirectory: '$(sdkPath)' + displayName: 'Install Dependencies' + - script: go vet $(go list ./... | grep -v vendor) + workingDirectory: '$(sdkPath)' + displayName: 'Vet' + - 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/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 $(find . -path ./vendor -prune -o -name '*.go' -print) >&2 + workingDirectory: '$(sdkPath)' + displayName: 'Format Check' + failOnStderr: true + condition: succeededOrFailed() + - script: | + golint ./storage/... >&2 + golint ./tools/... >&2 + workingDirectory: '$(sdkPath)' + displayName: 'Linter Check' + failOnStderr: true + condition: succeededOrFailed() \ No newline at end of file diff --git a/moduler-pipelines.yml b/moduler-pipelines.yml new file mode 100644 index 000000000000..d08f1803cbc8 --- /dev/null +++ b/moduler-pipelines.yml @@ -0,0 +1,95 @@ +pool: + vmImage: 'Ubuntu 18.04' + +variables: + GOROOT: '/usr/local/go1.12' + GOPATH: '$(system.defaultWorkingDirectory)/work' + sdkPath: '$(GOPATH)/src/github.com/Azure/azure-sdk-for-go' + +trigger: + batch: true + branches: + include: + - master + +pr: none + +steps: + - script: | + # Enable bash verbose logging + set -x + mkdir -p '$(GOPATH)/bin' + mkdir -p '$(sdkPath)' + shopt -s dotglob extglob + mv !(work) '$(sdkPath)' + echo '##vso[task.prependpath]$(GOROOT)/bin' + echo '##vso[task.prependpath]$(GOPATH)/bin' + displayName: 'Create Go Workspace' + - script: | + set -x + go version + curl -sSL https://raw.githubusercontent.com/golang/dep/master/install.sh | sh + dep ensure -v + go get -u golang.org/x/lint/golint + workingDirectory: '$(sdkPath)' + displayName: 'Install Dependencies' + - script: | + # Echo error if github-pat is empty + [ -z $(github-pat) ] && echo "github-pat is empty!" && exit -1 + echo $(Build.SourceBranchName) + # Enable bash verbose logging + set -x + git checkout $(Build.SourceBranchName) + git config user.email "azuresdkci@microsoft.com" + git config user.name "azuresdkci" + git config credential.helper store + echo https://$(github-pat):x-oauth-basic@github.com > ~/.git-credentials + displayName: 'Setup github' + workingDirectory: '$(sdkPath)' + - script: | + go generate ./profiles + gofmt -s -w ./profiles + workingDirectory: '$(sdkPath)' + displayName: 'Generate profiles' + - script: go vet $(go list ./... | grep -v vendor) + workingDirectory: '$(sdkPath)' + displayName: 'Vet' + - 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/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 $(find . -path ./vendor -prune -o -name '*.go' -print) >&2 + workingDirectory: '$(sdkPath)' + displayName: 'Format Check' + failOnStderr: true + condition: succeededOrFailed() + - script: | + golint ./storage/... >&2 + golint ./tools/... >&2 + workingDirectory: '$(sdkPath)' + displayName: 'Linter Check' + failOnStderr: true + condition: succeededOrFailed() + - script: | + # test if there are new profiles + if [ -z "$(git status --porcelain)" ]; then + echo no new profiles generated. + else + git commit -a -m "regenerated profiles" + git push origin $(Build.SourceBranchName) + fi + workingDirectory: '$(sdkPath)' + displayName: 'Push profiles' + - script: go run ./tools/moduler/main.go ./services -v + displayName: 'Detecting new tag and push' + workingDirectory: '$(sdkPath)'