Skip to content

Instantly share code, notes, and snippets.

@TsuyoshiUshio
Created September 24, 2018 12:15
Show Gist options
  • Select an option

  • Save TsuyoshiUshio/7eca53ff455b67eb08e3f1db8a01640d to your computer and use it in GitHub Desktop.

Select an option

Save TsuyoshiUshio/7eca53ff455b67eb08e3f1db8a01640d to your computer and use it in GitHub Desktop.

Revisions

  1. TsuyoshiUshio created this gist Sep 24, 2018.
    59 changes: 59 additions & 0 deletions azure-pipelines.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,59 @@
    # Go
    # Build your Go application.
    # Add steps that test, save build artifacts, deploy, and more:
    # https://docs.microsoft.com/vsts/pipelines/languages/go

    pool:
    vmImage: 'Ubuntu 16.04'

    variables:
    GOBIN: '$(GOPATH)/bin' # Go binaries path
    GOROOT: '/usr/local/go1.11' # Go installation path
    GOPATH: '$(system.defaultWorkingDirectory)/gopath' # Go workspace path
    modulePath: '$(GOPATH)/src/github.com/$(build.repository.name)' # Path to the module's code

    steps:
    - script: |
    mkdir -p '$(GOBIN)'
    mkdir -p '$(GOPATH)/pkg'
    mkdir -p '$(modulePath)'
    shopt -s extglob
    mv !(gopath) '$(modulePath)'
    echo '##vso[task.prependpath]$(GOBIN)'
    echo '##vso[task.prependpath]$(GOROOT)/bin'
    displayName: 'Set up the Go workspace'

    - script: |
    go version
    go get -v -t -d ./...
    if [ -f Gopkg.toml ]; then
    curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
    dep ensure
    fi
    go build -v ./cmd/strikes
    workingDirectory: '$(modulePath)'
    displayName: 'Get dependencies, then build'

    - script: |
    go get github.com/jstemmer/go-junit-report
    go get github.com/axw/gocov/gocov
    go get github.com/AlekSi/gocov-xml
    go get -u gopkg.in/matm/v1/gocov-html
    go test -v -coverprofile=coverage.txt -covermode count ./config ./helpers ./providers ./services/repository ./services/resources ./services/storage 2>&1 | go-junit-report > report.xml
    gocov convert coverage.txt > coverage.json
    gocov-xml < coverage.json > coverage.xml
    mkdir coverage
    gocov-html < coverage.json > coverage/index.html
    workingDirectory: '$(modulePath)'
    displayName: 'Run unit test'

    - task: PublishTestResults@2
    inputs:
    testRunner: JUnit
    testResultsFiles: $(System.DefaultWorkingDirectory)/**/report.xml

    - task: PublishCodeCoverageResults@1
    inputs:
    codeCoverageTool: Cobertura
    summaryFileLocation: $(System.DefaultWorkingDirectory)/**/coverage.xml
    reportDirectory: $(System.DefaultWorkingDirectory)/**/coverage