Skip to content

Commit

Permalink
Merge pull request #246 from hashicorp/master
Browse files Browse the repository at this point in the history
Merge master into v2
  • Loading branch information
azr authored Apr 28, 2020
2 parents 0b1d527 + 2949343 commit 41fc410
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 45 deletions.
159 changes: 134 additions & 25 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,60 @@
version: 2.1

orbs:
win: circleci/windows@2.2.0

references:
images:
go: &GOLANG_IMAGE circleci/golang:latest
environments:
tmp: &TEST_RESULTS_PATH /tmp/test-results # path to where test results are saved

# reusable 'executor' object for jobs
executors:
go:
docker:
- image: *GOLANG_IMAGE
environment:
- TEST_RESULTS: *TEST_RESULTS_PATH
environment: &ENVIRONMENT
TEST_RESULTS_PATH: &TEST_RESULTS_PATH /tmp/test-results
WIN_TEST_RESULTS: &WIN_TEST_RESULTS c:\Users\circleci\AppData\Local\Temp\test-results

commands:
run-gotests:
parameters:
cmd:
type: string
platform:
type: string
steps:
- run:
name: "Run go tests"
command: |
PACKAGE_NAMES=$(go list ./... | circleci tests split --split-by=timings --timings-type=classname)
echo "Running $(echo $PACKAGE_NAMES | wc -w) packages"
echo $PACKAGE_NAMES
<< 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
jobs:
go-fmt-and-test:
executor: go
linux-tests:
docker:
- image: circleci/golang:<< parameters.go-version >>
parameters:
go-version:
type: string
environment:
<<: *ENVIRONMENT
parallelism: 4
steps:
- run: go version
- checkout
- run: mkdir -p $TEST_RESULTS
- attach_workspace:
at: .
- run: mkdir -p $TEST_RESULTS_PATH/go-getter

# Restore go module cache if there is one
- restore_cache:
keys:
- go-getter-modcache-v1-{{ checksum "go.mod" }}
- linux-gomod-cache-v1-{{ checksum "go.mod" }}

- run: go mod download

# Save go module cache if the go.mod file has changed
- save_cache:
key: go-getter-modcache-v1-{{ checksum "go.mod" }}
key: linux-gomod-cache-v1-{{ checksum "go.mod" }}
paths:
- "/go/pkg/mod"

# check go fmt output because it does not report non-zero when there are fmt changes
# Check go fmt output because it does not report non-zero when there are fmt changes
- run:
name: check go fmt
command: |
Expand All @@ -45,17 +65,106 @@ jobs:
exit 1
fi
# run go tests with gotestsum
- run: |
PACKAGE_NAMES=$(go list ./...)
gotestsum --format=short-verbose --junitfile $TEST_RESULTS/gotestsum-report.xml -- $PACKAGE_NAMES
# Run go tests with gotestsum
- run-gotests:
cmd: "gotestsum"
platform: "linux"

# Save coverage report parts
- persist_to_workspace:
root: .
paths:
- linux_cov_*.part

- store_test_results:
path: *TEST_RESULTS_PATH
- store_artifacts:
path: *TEST_RESULTS_PATH

windows-tests:
executor:
name: win/default
shell: bash --login -eo pipefail
environment:
<<: *ENVIRONMENT
working_directory: c:\gopath\src\github.com\hashicorp\go-getter
parameters:
go-version:
type: string
gotestsum-version:
type: string
steps:
- run: git config --global core.autocrlf false
- checkout
- attach_workspace:
at: .
- run:
name: Setup (remove pre-installed go)
command: |
rm -rf "c:\Go"
mkdir -p $TEST_RESULTS_PATH/go-getter
- restore_cache:
keys:
- win-golang-<< parameters.go-version >>-cache-v1
- win-gomod-cache-{{ checksum "go.mod" }}-v1

- run:
name: Install go version << parameters.go-version >>
command: |
if [ ! -d "c:\go" ]; then
echo "Cache not found, installing new version of go"
curl --fail --location https://dl.google.com/go/go<< parameters.go-version >>.windows-amd64.zip --output go.zip
unzip go.zip -d "/c"
fi
- run:
command: go mod download

- save_cache:
key: win-golang-<< parameters.go-version >>-cache-v1
paths:
- /go

- save_cache:
key: win-gomod-cache-{{ checksum "go.mod" }}-v1
paths:
- c:\Windows\system32\config\systemprofile\go\pkg\mod

- run:
name: Install gotestsum
command: |
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
tar -xvzf gotestsum.tar.gz
- run-gotests:
cmd: "./gotestsum.exe"
platform: "win"

# Save coverage report parts
- persist_to_workspace:
root: .
paths:
- win_cov_*.part

- store_test_results:
path: *WIN_TEST_RESULTS
- store_artifacts:
path: *WIN_TEST_RESULTS

workflows:
version: 2
test-and-build:
go-getter:
jobs:
- go-fmt-and-test
- linux-tests:
context: go-getter
matrix:
parameters:
go-version: ["1.14.1"]
name: linux-test-go-<< matrix.go-version >>
- windows-tests:
context: go-getter
matrix:
parameters:
go-version: ["1.14.1"]
gotestsum-version: ["0.4.1"]
name: win-test-go-<< matrix.go-version >>
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
# go-getter

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

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

go-getter is a library for Go (golang) for downloading files or directories
from various sources using a URL as the primary form of input.
Expand Down Expand Up @@ -139,8 +137,8 @@ If you downloaded this to the `/tmp` directory, then the file
directory in this repository, but because we specified a subdirectory,
go-getter automatically copied only that directory contents.

Subdirectory paths may contain may also use filesystem glob patterns.
The path must match _exactly one_ entry or go-getter will return an error.
Subdirectory paths may also use filesystem glob patterns. The path must
match _exactly one_ entry or go-getter will return an error.
This is useful if you're not sure the exact directory name but it follows
a predictable naming structure.

Expand Down
16 changes: 0 additions & 16 deletions appveyor.yml

This file was deleted.

0 comments on commit 41fc410

Please sign in to comment.