Skip to content

Commit c00b3a5

Browse files
authored
ci: Azure Pipelines CI system (#2540)
* Set up CI with Azure Pipelines [skip ci] * Add other platforms [skip ci] * Oops, add vmImage back in [skip ci] * Fix goVersion [skip ci] * Use sudo to install Go [skip ci] * Attempt platform-specific Go isntalls [skip ci] * Try sharing the variable a different way [skip ci] * Trying this again... [skip ci] * Fix the PATH [skip ci] * Fix GOROOT, hopefully [skip ci] * More fixing [skip ci] * Still fixing [skip ci] * Add golang-ci [skip ci] * asdfasdfasf [skip ci] * Sigh, work around broken golangci-lint installer [skip ci] * Try again [skip ci] * ahhhhhh [skip ci] * sooooo close! cleanup [skip ci] * oh c'mon [skip ci] * thought I had it for a sec [skip ci] * yaaaayyyy [skip ci] ship it
1 parent f6e6a6b commit c00b3a5

File tree

1 file changed

+86
-0
lines changed

1 file changed

+86
-0
lines changed

azure-pipelines.yml

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Mutilated beyond recognition from the example at:
2+
# https://docs.microsoft.com/azure/devops/pipelines/languages/go
3+
4+
trigger:
5+
- master
6+
7+
strategy:
8+
matrix:
9+
linux:
10+
imageName: ubuntu-16.04
11+
gorootDir: /usr/local
12+
mac:
13+
imageName: macos-10.13
14+
gorootDir: /usr/local
15+
windows:
16+
imageName: windows-2019
17+
gorootDir: C:\
18+
19+
pool:
20+
vmImage: $(imageName)
21+
22+
variables:
23+
GOROOT: $(gorootDir)/go
24+
GOPATH: $(system.defaultWorkingDirectory)/gopath
25+
GOBIN: $(GOPATH)/bin
26+
modulePath: '$(GOPATH)/src/github.com/$(build.repository.name)'
27+
28+
steps:
29+
- bash: |
30+
latestGo=$(curl "https://golang.org/VERSION?m=text")
31+
echo "##vso[task.setvariable variable=LATEST_GO]$latestGo"
32+
echo "Latest Go version: $latestGo"
33+
displayName: "Get latest Go version"
34+
35+
- bash: |
36+
sudo rm -f $(which go)
37+
echo '##vso[task.prependpath]$(GOBIN)'
38+
echo '##vso[task.prependpath]$(GOROOT)/bin'
39+
mkdir -p '$(modulePath)'
40+
shopt -s extglob
41+
shopt -s dotglob
42+
mv !(gopath) '$(modulePath)'
43+
displayName: Remove old Go, set GOBIN/GOROOT, and move project into GOPATH
44+
45+
# Install Go (this varies by platform)
46+
47+
- bash: |
48+
wget "https://dl.google.com/go/$(LATEST_GO).linux-amd64.tar.gz"
49+
sudo tar -C $(gorootDir) -xzf "$(LATEST_GO).linux-amd64.tar.gz"
50+
condition: eq( variables['Agent.OS'], 'Linux' )
51+
displayName: Install Go on Linux
52+
53+
- bash: |
54+
wget "https://dl.google.com/go/$(LATEST_GO).darwin-amd64.tar.gz"
55+
sudo tar -C $(gorootDir) -xzf "$(LATEST_GO).darwin-amd64.tar.gz"
56+
condition: eq( variables['Agent.OS'], 'Darwin' )
57+
displayName: Install Go on macOS
58+
59+
- powershell: |
60+
Write-Host "Downloading Go... (please be patient, I am very slow)"
61+
(New-Object System.Net.WebClient).DownloadFile("https://dl.google.com/go/$(LATEST_GO).windows-amd64.zip", "$(LATEST_GO).windows-amd64.zip")
62+
Write-Host "Extracting Go... (I'm slow too)"
63+
Expand-Archive "$(LATEST_GO).windows-amd64.zip" -DestinationPath "$(gorootDir)"
64+
condition: eq( variables['Agent.OS'], 'Windows_NT' )
65+
displayName: Install Go on Windows
66+
67+
# TODO: When this issue is fixed, replace with installer script:
68+
# https://github.com/golangci/golangci-lint/issues/472
69+
- script: go get -v github.com/golangci/golangci-lint/cmd/golangci-lint
70+
displayName: Install golangci-lint
71+
72+
- bash: |
73+
printf "Using go at: $(which go)\n"
74+
printf "Go version: $(go version)\n"
75+
printf "\n\nGo environment:\n\n"
76+
go env
77+
printf "\n\nSystem environment:\n\n"
78+
env
79+
displayName: Print Go version and environment
80+
81+
- script: |
82+
go get -v -t -d ./...
83+
golangci-lint run -E gofmt -E goimports -E misspell
84+
go test -race ./...
85+
workingDirectory: '$(modulePath)'
86+
displayName: Run tests

0 commit comments

Comments
 (0)