File: azure-pipelines.yml

package info (click to toggle)
golang-github-azure-go-autorest 14.2.0%2Bgit20220726.711dde1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 1,320 kB
  • sloc: makefile: 15
file content (117 lines) | stat: -rw-r--r-- 3,743 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
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_Go115:
          vm.image: 'ubuntu-18.04'
          go.version: '1.15'
        Linux_Go116:
          vm.image: 'ubuntu-18.04'
          go.version: '1.16'
        Linux_Go117:
          vm.image: 'ubuntu-18.04'
          go.version: '1.17'
          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 get golang.org/x/lint/golint@latest
          go get github.com/jstemmer/go-junit-report@latest
          go get github.com/axw/gocov/gocov@latest
          go get github.com/AlekSi/gocov-xml@latest
          go get github.com/matm/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