go-autorest/azure-pipelines.yml

115 строки
3.6 KiB
YAML

variables:
GO111MODULE: 'auto'
GOPATH: '$(system.defaultWorkingDirectory)/work'
sdkPath: '$(GOPATH)/src/github.com/$(build.repository.name)'
jobs:
- job: 'goautorest'
displayName: 'Run go-autorest CI Checks'
strategy:
matrix:
Linux_Go118:
vm.image: 'ubuntu-22.04'
go.version: '1.18.10'
Linux_Go119:
vm.image: 'ubuntu-22.04'
go.version: '1.19.5'
current_go: 'true'
pool:
vmImage: '$(vm.image)'
steps:
- task: GoTool@0
inputs:
version: '$(go.version)'
displayName: "Select Go Version"
- script: |
set -e
mkdir -p '$(GOPATH)/bin'
mkdir -p '$(sdkPath)'
shopt -s extglob
mv !(work) '$(sdkPath)'
echo '##vso[task.prependpath]$(GOPATH)/bin'
displayName: 'Create Go Workspace'
- script: |
set -e
export GO111MODULE=on
go install golang.org/x/lint/golint@latest
go install github.com/jstemmer/go-junit-report@latest
go install github.com/axw/gocov/gocov@latest
go install github.com/AlekSi/gocov-xml@latest
go install github.com/matm/gocov-html/cmd/gocov-html@latest
workingDirectory: '$(sdkPath)'
displayName: 'Install Dependencies'
- script: |
modules=$(find . -name go.mod)
for module in $modules; do
pushd "$(dirname $module)" && go vet ./... && popd;
done
workingDirectory: '$(sdkPath)'
displayName: 'Vet'
- script: |
modules=$(find . -name go.mod)
for module in $modules; do
pushd "$(dirname $module)" && go build -v ./... && popd;
done
workingDirectory: '$(sdkPath)'
displayName: 'Build'
- script: |
set -e
modules=$(find . -name go.mod)
for module in $modules; do
pushd "$(dirname $module)";
go test -race -v -coverprofile=coverage.txt -covermode atomic ./... 2>&1 | go-junit-report > report.xml;
gocov convert coverage.txt > coverage.json;
gocov-xml < coverage.json > coverage.xml;
gocov-html < coverage.json > coverage.html;
popd;
done
workingDirectory: '$(sdkPath)'
displayName: 'Run Tests'
- 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 ./autorest/. >&2
gofmt -s -l -w ./logger/. >&2
gofmt -s -l -w ./tracing/. >&2
workingDirectory: '$(sdkPath)'
displayName: 'Format Check'
failOnStderr: true
condition: and(succeededOrFailed(), eq(variables['current_go'], 'true'))
- script: |
modules=$(find . -name go.mod)
for module in $modules; do
pushd "$(dirname $module)" && golint ./... >&2 && popd;
done
workingDirectory: '$(sdkPath)'
displayName: 'Linter Check'
failOnStderr: true
condition: succeededOrFailed()
- task: PublishTestResults@2
inputs:
testRunner: JUnit
testResultsFiles: $(sdkPath)/**/report.xml
failTaskOnFailedTests: true
- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: $(sdkPath)/autorest/**/coverage.xml
additionalCodeCoverageFiles: $(sdkPath)/autorest/**/coverage.html