summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammed Al Sahaf <msaa1990@gmail.com>2019-10-02 01:47:29 +0300
committerMatt Holt <mholt@users.noreply.github.com>2019-10-01 16:47:29 -0600
commit1ecb216001f77127084fc9bf5c075acebfec58a9 (patch)
tree441d2034db2fb500a63e10891b8e3eef135adfbd
parent94f98c0733c63fe2044d41bf5bc85465ab23e283 (diff)
v2: introduce CI (#2768)
* v2: introduce CI for v2 branch * v2-ci: split test report generation from test pass to preserve exit code * v2-ci: spilt lint results from unit test results * v2-ci: fix testRunTitle name * v2-ci: break up the steps for more accurate status indicators * v2-ci: break steps into different jobs * v2-ci: revert back to single-job pattern * v2-ci: reflect the true result by coercing SucceededWithIssues into Failed in the last step * v2-ci: don't fail the build on lint errors
-rw-r--r--README.md2
-rw-r--r--azure-pipelines.yml142
2 files changed, 144 insertions, 0 deletions
diff --git a/README.md b/README.md
index 3791130..cb174df 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,8 @@
Caddy 2 Development Branch
===========================
+[![Build Status](https://dev.azure.com/mholt-dev/Caddy/_apis/build/status/Multiplatform%20Tests?branchName=v2)](https://dev.azure.com/mholt-dev/Caddy/_build/latest?definitionId=5&branchName=v2)
+
This is the development branch for Caddy 2. This code (version 2) is not yet feature-complete or production-ready, but is already being used in production, and we encourage you to deploy it today on sites that are not very visible or important so that it can obtain crucial experience in the field.
Please file issues to propose new features and report bugs, and after the bug or feature has been discussed, submit a pull request! We need your help to build this web server into what you want it to be. (Caddy 2 issues and pull requests will usually receive priority over Caddy 1 issues and pull requests.)
diff --git a/azure-pipelines.yml b/azure-pipelines.yml
new file mode 100644
index 0000000..fbee6fb
--- /dev/null
+++ b/azure-pipelines.yml
@@ -0,0 +1,142 @@
+# Mutilated beyond recognition from the example at:
+# https://docs.microsoft.com/azure/devops/pipelines/languages/go
+
+trigger:
+- v2
+
+strategy:
+ matrix:
+ linux:
+ imageName: ubuntu-16.04
+ gorootDir: /usr/local
+ mac:
+ imageName: macos-10.13
+ gorootDir: /usr/local
+ windows:
+ imageName: windows-2019
+ gorootDir: C:\
+pool:
+ vmImage: $(imageName)
+
+variables:
+ GOROOT: $(gorootDir)/go
+ GOPATH: $(system.defaultWorkingDirectory)/gopath
+ GOBIN: $(GOPATH)/bin
+ modulePath: '$(GOPATH)/src/github.com/$(build.repository.name)'
+ # TODO: Remove once it's enabled by default
+ GO111MODULE: on
+
+steps:
+- bash: |
+ latestGo=$(curl "https://golang.org/VERSION?m=text")
+ echo "##vso[task.setvariable variable=LATEST_GO]$latestGo"
+ echo "Latest Go version: $latestGo"
+ displayName: "Get latest Go version"
+
+- bash: |
+ sudo rm -f $(which go)
+ echo '##vso[task.prependpath]$(GOBIN)'
+ echo '##vso[task.prependpath]$(GOROOT)/bin'
+ mkdir -p '$(modulePath)'
+ shopt -s extglob
+ shopt -s dotglob
+ mv !(gopath) '$(modulePath)'
+ displayName: Remove old Go, set GOBIN/GOROOT, and move project into GOPATH
+
+# Install Go (this varies by platform)
+- bash: |
+ wget "https://dl.google.com/go/$(LATEST_GO).linux-amd64.tar.gz"
+ sudo tar -C $(gorootDir) -xzf "$(LATEST_GO).linux-amd64.tar.gz"
+ condition: eq( variables['Agent.OS'], 'Linux' )
+ displayName: Install Go on Linux
+
+- bash: |
+ wget "https://dl.google.com/go/$(LATEST_GO).darwin-amd64.tar.gz"
+ sudo tar -C $(gorootDir) -xzf "$(LATEST_GO).darwin-amd64.tar.gz"
+ condition: eq( variables['Agent.OS'], 'Darwin' )
+ displayName: Install Go on macOS
+
+- powershell: |
+ Write-Host "Downloading Go... (please be patient, I am very slow)"
+ (New-Object System.Net.WebClient).DownloadFile("https://dl.google.com/go/$(LATEST_GO).windows-amd64.zip", "$(LATEST_GO).windows-amd64.zip")
+ Write-Host "Extracting Go... (I'm slow too)"
+ Expand-Archive "$(LATEST_GO).windows-amd64.zip" -DestinationPath "$(gorootDir)"
+ condition: eq( variables['Agent.OS'], 'Windows_NT' )
+ displayName: Install Go on Windows
+
+- bash: curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.19.1
+ displayName: Install golangci-lint
+
+- script: |
+ go get github.com/axw/gocov/gocov
+ go get github.com/AlekSi/gocov-xml
+ go get -u github.com/jstemmer/go-junit-report
+ displayName: Install test and coverage analysis tools
+
+- bash: |
+ printf "Using go at: $(which go)\n"
+ printf "Go version: $(go version)\n"
+ printf "\n\nGo environment:\n\n"
+ go env
+ printf "\n\nSystem environment:\n\n"
+ env
+ displayName: Print Go version and environment
+
+- script: |
+ go get -v -t -d ./...
+ mkdir test-results
+ workingDirectory: '$(modulePath)'
+ displayName: Get dependencies
+
+- script: |
+ (golangci-lint run --out-format junit-xml -E gofmt -E goimports -E misspell) > test-results/lint-result.xml
+ exit 0
+ workingDirectory: '$(modulePath)'
+ continueOnError: true
+ displayName: Run lint check
+
+- script: |
+ (go test -v -coverprofile=cover-profile.out -race ./... 2>&1) > test-results/test-result.out
+ workingDirectory: '$(modulePath)'
+ continueOnError: true
+ displayName: Run tests
+
+- script: |
+ mkdir coverage
+ gocov convert cover-profile.out > coverage/coverage.json
+ # Because Windows doesn't work with input redirection like *nix, but output redirection works.
+ (cat ./coverage/coverage.json | gocov-xml) > coverage/coverage.xml
+ workingDirectory: '$(modulePath)'
+ displayName: Prepare coverage reports
+
+- script: |
+ (cat ./test-results/test-result.out | go-junit-report) > test-results/test-result.xml
+ workingDirectory: '$(modulePath)'
+ displayName: Prepare test report
+
+- task: PublishCodeCoverageResults@1
+ displayName: Publish test coverage report
+ inputs:
+ codeCoverageTool: Cobertura
+ summaryFileLocation: $(modulePath)/coverage/coverage.xml
+
+- task: PublishTestResults@2
+ displayName: Publish unit test
+ inputs:
+ testResultsFormat: 'JUnit'
+ testResultsFiles: $(modulePath)/test-results/test-result.xml
+ testRunTitle: $(agent.OS) Unit Test
+ mergeTestResults: false
+
+- task: PublishTestResults@2
+ displayName: Publish lint results
+ inputs:
+ testResultsFormat: 'JUnit'
+ testResultsFiles: $(modulePath)/test-results/lint-result.xml
+ testRunTitle: $(agent.OS) Lint
+ mergeTestResults: false
+
+- bash: |
+ exit 1
+ condition: eq(variables['Agent.JobStatus'], 'SucceededWithIssues')
+ displayName: Coerce correct build result \ No newline at end of file