Skip to content

Commit

Permalink
Configured Go module, updated CI configs
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Xie authored and hulloitskai committed Sep 5, 2018
1 parent 55a0b32 commit 17c1cca
Show file tree
Hide file tree
Showing 60 changed files with 136 additions and 6,813 deletions.
53 changes: 43 additions & 10 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,62 @@ clone_folder: C:\gopath\src\github.com\steven-xie\dgen

environment:
GOPATH: C:\gopath
GOBIN: '%GOPATH%\bin'

stack: go 1.10
GO111MODULE: "on"
GCC: x86_64-w64-mingw32-gcc.exe
MINGW64_DIR: C:\mingw-w64\x86_64-7.3.0-posix-seh-rt_v5-rev0\mingw64\bin
matrix:
- GOROOT: C:\go

platform:
- x86
- x64
- x86

matrix:
## Calling PowerShell externally doesn't seem to be particularly stable
## on x86.
allow_failures:
- platform: x86

cache:
## Preserve Go module cache.
- "%GOPATH%\\pkg\\mod\\cache"

init:
- git config --global core.autocrlf input

install:
- set PATH=C:\cygwin\bin;%PATH%
- go get ./...
## Configure MinGW, put proper GOBIN at the front of the path.
- set PATH=%GOROOT%\bin;%MINGW64_DIR%;%PATH%

## Configure testing environment.
- ps: if ($env:PLATFORM -Eq "x86") { $env:GOARCH = "386" }

## Install dependencies.
- mingw32-make get

## Log diagonistic information.
- echo %GOPATH%
- go version
- go env
- ps: $PSVersionTable.PSVersion

build: off
deploy: off

build_script:
- make build

test_script:
- make test-race
- ps: |
if ($env:PLATFORM -Eq "x86") {
## Emulate tests on an x86 architecture.
mingw32-make test-v
} else {
## Test race conditions only on x64.
mingw32-make test-race-v
}
after_test:
- ps: |
if (Test-Path -PathType Leaf -Path "coverage.out") {
$env:PATH = "C:\msys64\usr\bin;${env:PATH}"
Invoke-WebRequest -Uri 'https://codecov.io/bash' -OutFile codecov.sh
bash codecov.sh
}
56 changes: 48 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,61 @@
language: go

go:
- '1.10'
- '1.11'
- tip

git:
depth: 3

os:
- osx
- linux

env:
global:
- GOLINT_BIN="$GOPATH/bin/golint"
- GO111MODULE="on"

## Cache Golint installation.
cache:
directories:
## Preserve golint executable.
- $GOLINT_BIN
## Preserve Go module cache.
- $GOPATH/pkg/mod/cache

## Mark Go version 'tip' as an optional.
matrix:
allow_failures:
- go: 'tip'
fast_finish: true

## Install dependencies and code review tools.
before_install:
- curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
- go get -u golang.org/x/lint/golint
## Install Golint, if no installation cache exists.
- if [ ! -e "$GOLINT_BIN" ]; then go get -u golang.org/x/lint/golint; fi

## Install clipboard program if necessary.
- |
if [ "$TRAVIS_OS_NAME" == "linux" ]; then
sudo apt-get update;
sudo apt-get install xclip;
fi
install:
## Install all dependencies.
- make get
- |
if [ "$TRAVIS_OS_NAME" == "linux" ]; then
export DISPLAY=:99.0
sh -e /etc/init.d/xvfb start # imitate an display on Linux
fi
install: dep ensure
## List diagonstic information before running tests.
before_script:
- go env

script:
- make review-race
- make build
script: make review-race-v

after_script:
after_success:
- bash <(curl -s https://codecov.io/bash)
31 changes: 0 additions & 31 deletions Gopkg.lock

This file was deleted.

30 changes: 0 additions & 30 deletions Gopkg.toml

This file was deleted.

47 changes: 29 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,17 @@ COVER_OUT = coverage.out

## ------ Commands (targets) -----
## Prevent targeting filenames...
.PHONY: default init run build install get update fix review review-race \
review-bench check fmt test test-v test-race bench
.PHONY: default init setup verify run build install get update fix \
_review_base review review-race review-bench check fmt test test-v \
test-race bench

## Default target when no arguments are given to make (build and run program).
default: build run

## Setup sets up a Go module by initializing the module and then verifying
## its dependencies.
setup: init verify

## Initializes a Go module in the current directory.
init:
@printf "Initializing Go module:\n"
Expand All @@ -39,7 +44,7 @@ run:
## Builds the program specified by the main package.
build:
@printf "Building... "
@GOBUILD_OUT="$$(go build 2>&1)"; \
@GOBUILD_OUT="$$(go build ./... 2>&1)"; \
if [ -n "$$GOBUILD_OUT" ]; then \
printf "\n[ERROR] Failed to build program:\n"; \
printf "$$GOBUILD_OUT\n"; \
Expand All @@ -48,7 +53,7 @@ build:
fi

install:
@printf 'Installing with "go install"... '
@printf 'Installing... '
@GOINSTALL_OUT="$$(go install 2>&1)"; \
if [ -n "$$GOBUILD_OUT" ]; then \
printf "\n[ERROR] failed to install:\n"; \
Expand All @@ -57,23 +62,19 @@ install:
else printf "done.\n"; \
fi


## Installs package dependencies.
## Installs dependencies.
get:
@printf 'Installing package dependencies with "go get"... '
@printf "Installing dependencies... "
@GOGET_OUT="$$(go get ./... 2>&1)"; \
if [ -n "$$GOGET_OUT" ]; then \
printf "\n[ERROR] Failed to install package dependencies:\n"; \
printf "$$GOGET_OUT\n"; \
exit 1; \
if [ -n "$$GOGET_OUT" ]; then printf "\n$$GOGET_OUT\n"; \
else printf "done.\n"; \
fi

## Installs and updates package dependencies.
update:
@printf 'Installing and updating package dependencies with "go get"... '
@GOGET_OUT="$$(go get -u 2>&1)"; \
if [ -n "$$GOGET_OUT" ]; then \
if [ -n "$$GOGET_OUT" ]; then \
printf "\n[ERROR] Failed to install package dependencies:\n"; \
printf "$$GOGET_OUT\n"; \
exit 1; \
Expand All @@ -82,16 +83,26 @@ update:

## Fixes Go code using "go fix"
fix:
@printf 'Fixing Go code with "go fix":\n'
@go fix
@printf 'Fixing Go code with "go fix"... '
@GOFIX_OUT="$$(go fix 2>&1)"; \
if [ -n "$$GOFIX_OUT" ]; then \
printf "\n$$GOFIX_OUT\n"; \
else printf "done.\n"; \
fi

## Verifies that Go module dependencies are satisfied.
verify:
@printf "Verifying Go module dependencies:\n"
@go mod verify


## Formats, checks, and tests the code.
review: fmt check test
review-v: fmt check test-v
_review_base: verify fmt check
review: _review_base test
review-v: _review_base test-v
## Like "review", but tests for race conditions.
review-race: fmt check test-race
review-race-v: fmt check test-race-v
review-race: _review_base test-race
review-race-v: _review_base test-race-v
## Like "review-race", but includes benchmarks.
review-bench: review-race bench
review-bench-v: review-race bench-v
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ _A command-line tool designed for repeating a string an excessive number of
times._

[![godoc: reference][godoc-img]][godoc]
[![codecov: coverage][codecov-img]][codecov]
[![go report card][goreportcard-img]][goreportcard]
[![travis: build][travis-img]][travis]
[![appveyor: build][appveyor-img]][appveyor]
[![codecov: coverage][codecov-img]][codecov]

## Installation

Expand Down Expand Up @@ -94,3 +95,5 @@ func main() {
[codecov]: https://codecov.io/gh/steven-xie/dgen
[appveyor]: https://ci.appveyor.com/project/StevenXie/dgen-p2xgh
[appveyor-img]: https://ci.appveyor.com/api/projects/status/wrry9krp1kkx4hsi/branch/master?svg=true
[goreportcard]: https://goreportcard.com/report/github.com/steven-xie/dgen
[goreportcard-img]: https://goreportcard.com/badge/github.com/steven-xie/dgen
6 changes: 6 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module github.com/steven-xie/dgen

require (
github.com/jessevdk/go-flags v1.4.0
github.com/steven-xie/glip v1.1.0
)
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
github.com/jessevdk/go-flags v1.4.0 h1:4IU2WS7AumrZ/40jfhf4QVDMsQwqA7VEHozFRrGARJA=
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/steven-xie/glip v1.0.0 h1:YeZcV2bgnvngDeLi62Ck7exi//zz0PmDEpHvS7uYhT8=
github.com/steven-xie/glip v1.0.0/go.mod h1:7//Wcz3pRKb1c7mJpki9VVWiVM0GlqC3oi369FqXZY8=
github.com/steven-xie/glip v1.1.0 h1:aB7PWAs+5tq4rYuTfUeWd/4Ke6wSDMfWQ2BwRx5FNTc=
github.com/steven-xie/glip v1.1.0/go.mod h1:7//Wcz3pRKb1c7mJpki9VVWiVM0GlqC3oi369FqXZY8=
44 changes: 0 additions & 44 deletions vendor/github.com/jessevdk/go-flags/.travis.yml

This file was deleted.

0 comments on commit 17c1cca

Please sign in to comment.