Skip to content

Commit 2949343

Browse files
authored
Add windows tests to CircleCI
Add windows tests to CircleCI
2 parents fc35e45 + 340bd77 commit 2949343

File tree

3 files changed

+134
-43
lines changed

3 files changed

+134
-43
lines changed

.circleci/config.yml

Lines changed: 134 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,60 @@
11
version: 2.1
22

3+
orbs:
4+
win: circleci/[email protected]
5+
36
references:
4-
images:
5-
go: &GOLANG_IMAGE circleci/golang:latest
6-
environments:
7-
tmp: &TEST_RESULTS_PATH /tmp/test-results # path to where test results are saved
8-
9-
# reusable 'executor' object for jobs
10-
executors:
11-
go:
12-
docker:
13-
- image: *GOLANG_IMAGE
14-
environment:
15-
- TEST_RESULTS: *TEST_RESULTS_PATH
7+
environment: &ENVIRONMENT
8+
TEST_RESULTS_PATH: &TEST_RESULTS_PATH /tmp/test-results
9+
WIN_TEST_RESULTS: &WIN_TEST_RESULTS c:\Users\circleci\AppData\Local\Temp\test-results
1610

11+
commands:
12+
run-gotests:
13+
parameters:
14+
cmd:
15+
type: string
16+
platform:
17+
type: string
18+
steps:
19+
- run:
20+
name: "Run go tests"
21+
command: |
22+
PACKAGE_NAMES=$(go list ./... | circleci tests split --split-by=timings --timings-type=classname)
23+
echo "Running $(echo $PACKAGE_NAMES | wc -w) packages"
24+
echo $PACKAGE_NAMES
25+
<< parameters.cmd >> --format=short-verbose --junitfile $TEST_RESULTS_PATH/go-getter/gotestsum-report.xml -- -p 2 -cover -coverprofile=<< parameters.platform >>_cov_$CIRCLE_NODE_INDEX.part $PACKAGE_NAMES
26+
1727
jobs:
18-
go-fmt-and-test:
19-
executor: go
28+
linux-tests:
29+
docker:
30+
- image: circleci/golang:<< parameters.go-version >>
31+
parameters:
32+
go-version:
33+
type: string
34+
environment:
35+
<<: *ENVIRONMENT
36+
parallelism: 4
2037
steps:
38+
- run: go version
2139
- checkout
22-
- run: mkdir -p $TEST_RESULTS
40+
- attach_workspace:
41+
at: .
42+
- run: mkdir -p $TEST_RESULTS_PATH/go-getter
2343

2444
# Restore go module cache if there is one
2545
- restore_cache:
2646
keys:
27-
- go-getter-modcache-v1-{{ checksum "go.mod" }}
47+
- linux-gomod-cache-v1-{{ checksum "go.mod" }}
2848

2949
- run: go mod download
3050

3151
# Save go module cache if the go.mod file has changed
3252
- save_cache:
33-
key: go-getter-modcache-v1-{{ checksum "go.mod" }}
53+
key: linux-gomod-cache-v1-{{ checksum "go.mod" }}
3454
paths:
3555
- "/go/pkg/mod"
3656

37-
# check go fmt output because it does not report non-zero when there are fmt changes
57+
# Check go fmt output because it does not report non-zero when there are fmt changes
3858
- run:
3959
name: check go fmt
4060
command: |
@@ -45,17 +65,106 @@ jobs:
4565
exit 1
4666
fi
4767
48-
# run go tests with gotestsum
49-
- run: |
50-
PACKAGE_NAMES=$(go list ./...)
51-
gotestsum --format=short-verbose --junitfile $TEST_RESULTS/gotestsum-report.xml -- $PACKAGE_NAMES
68+
# Run go tests with gotestsum
69+
- run-gotests:
70+
cmd: "gotestsum"
71+
platform: "linux"
72+
73+
# Save coverage report parts
74+
- persist_to_workspace:
75+
root: .
76+
paths:
77+
- linux_cov_*.part
78+
5279
- store_test_results:
5380
path: *TEST_RESULTS_PATH
5481
- store_artifacts:
5582
path: *TEST_RESULTS_PATH
5683

84+
windows-tests:
85+
executor:
86+
name: win/default
87+
shell: bash --login -eo pipefail
88+
environment:
89+
<<: *ENVIRONMENT
90+
working_directory: c:\gopath\src\github.com\hashicorp\go-getter
91+
parameters:
92+
go-version:
93+
type: string
94+
gotestsum-version:
95+
type: string
96+
steps:
97+
- run: git config --global core.autocrlf false
98+
- checkout
99+
- attach_workspace:
100+
at: .
101+
- run:
102+
name: Setup (remove pre-installed go)
103+
command: |
104+
rm -rf "c:\Go"
105+
mkdir -p $TEST_RESULTS_PATH/go-getter
106+
107+
- restore_cache:
108+
keys:
109+
- win-golang-<< parameters.go-version >>-cache-v1
110+
- win-gomod-cache-{{ checksum "go.mod" }}-v1
111+
112+
- run:
113+
name: Install go version << parameters.go-version >>
114+
command: |
115+
if [ ! -d "c:\go" ]; then
116+
echo "Cache not found, installing new version of go"
117+
curl --fail --location https://dl.google.com/go/go<< parameters.go-version >>.windows-amd64.zip --output go.zip
118+
unzip go.zip -d "/c"
119+
fi
120+
121+
- run:
122+
command: go mod download
123+
124+
- save_cache:
125+
key: win-golang-<< parameters.go-version >>-cache-v1
126+
paths:
127+
- /go
128+
129+
- save_cache:
130+
key: win-gomod-cache-{{ checksum "go.mod" }}-v1
131+
paths:
132+
- c:\Windows\system32\config\systemprofile\go\pkg\mod
133+
134+
- run:
135+
name: Install gotestsum
136+
command: |
137+
curl --fail --location https://github.com/gotestyourself/gotestsum/releases/download/v<< parameters.gotestsum-version >>/gotestsum_<< parameters.gotestsum-version >>_windows_amd64.tar.gz --output gotestsum.tar.gz
138+
tar -xvzf gotestsum.tar.gz
139+
140+
- run-gotests:
141+
cmd: "./gotestsum.exe"
142+
platform: "win"
143+
144+
# Save coverage report parts
145+
- persist_to_workspace:
146+
root: .
147+
paths:
148+
- win_cov_*.part
149+
150+
- store_test_results:
151+
path: *WIN_TEST_RESULTS
152+
- store_artifacts:
153+
path: *WIN_TEST_RESULTS
154+
57155
workflows:
58-
version: 2
59-
test-and-build:
156+
go-getter:
60157
jobs:
61-
- go-fmt-and-test
158+
- linux-tests:
159+
context: go-getter
160+
matrix:
161+
parameters:
162+
go-version: ["1.14.1"]
163+
name: linux-test-go-<< matrix.go-version >>
164+
- windows-tests:
165+
context: go-getter
166+
matrix:
167+
parameters:
168+
go-version: ["1.14.1"]
169+
gotestsum-version: ["0.4.1"]
170+
name: win-test-go-<< matrix.go-version >>

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
# go-getter
22

33
[![CircleCI](https://circleci.com/gh/hashicorp/go-getter/tree/master.svg?style=svg)][circleci]
4-
[![Build status](https://ci.appveyor.com/api/projects/status/ulq3qr43n62croyq/branch/master?svg=true)][appveyor]
54
[![Go Documentation](http://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)][godocs]
65

76
[circleci]: https://circleci.com/gh/hashicorp/go-getter/tree/master
87
[godocs]: http://godoc.org/github.com/hashicorp/go-getter
9-
[appveyor]: https://ci.appveyor.com/project/hashicorp/go-getter/branch/master
108

119
go-getter is a library for Go (golang) for downloading files or directories
1210
from various sources using a URL as the primary form of input.

appveyor.yml

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)