From 39cf99f556817dc31535a3fbc8a60c7fbd70ba56 Mon Sep 17 00:00:00 2001 From: Joshua Harshman Date: Thu, 20 Feb 2020 12:25:38 -0700 Subject: [PATCH] leverage makefile to run build tasks (#976) remove circle ci --- .circleci/config.yml | 53 -------------------------------------------- .gitignore | 2 +- .travis.yml | 25 +++++++++++---------- Makefile | 36 ++++++++++++++++++++++++++++++ cobra/Makefile | 23 +++++++++++++++++++ 5 files changed, 73 insertions(+), 66 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 Makefile create mode 100644 cobra/Makefile diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 81944643..00000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,53 +0,0 @@ -version: 2 - -references: - workspace: &workspace - /go/src/github.com/spf13/cobra - - run_tests: &run_tests - run: - name: "All Commands" - command: | - mkdir -p bin - curl -Lso bin/shellcheck https://github.com/caarlos0/shellcheck-docker/releases/download/v0.4.6/shellcheck - chmod +x bin/shellcheck - go get -t -v ./... - PATH=$PATH:$PWD/bin go test -v ./... - go build - if [ -z $NOVET ]; then - diff -u <(echo -n) <(go vet . 2>&1 | grep -vE 'ExampleCommand|bash_completions.*Fprint'); - fi - -jobs: - go-current: - docker: - - image: circleci/golang:1.12 - working_directory: *workspace - steps: - - checkout - - *run_tests - - run: - name: "Check formatting" - command: diff -u <(echo -n) <(gofmt -d -s .) - go-previous: - docker: - - image: circleci/golang:1.11 - working_directory: *workspace - steps: - - checkout - - *run_tests - go-latest: - docker: - - image: circleci/golang:latest - working_directory: *workspace - steps: - - checkout - - *run_tests - -workflows: - version: 2 - main: - jobs: - - go-current - - go-previous - - go-latest diff --git a/.gitignore b/.gitignore index b2b848e7..c7b459e4 100644 --- a/.gitignore +++ b/.gitignore @@ -32,8 +32,8 @@ Session.vim tags *.exe -cobra cobra.test +bin .idea/ *.iml diff --git a/.travis.yml b/.travis.yml index fca1e694..a9bd4e54 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,26 +3,27 @@ language: go stages: - diff - test + - build go: - - 1.10.x - - 1.11.x - 1.12.x + - 1.13.x - tip +before_install: + - go get -u github.com/kyoh86/richgo + - go get -u github.com/mitchellh/gox + matrix: allow_failures: - go: tip include: - stage: diff - go: 1.12.x - script: diff -u <(echo -n) <(gofmt -d -s .) + go: 1.13.x + script: make fmt + - stage: build + go: 1.13.x + script: make cobra_generator -before_install: go get -u github.com/kyoh86/richgo - -script: - - richgo test -v ./... - - go build - - if [ -z $NOVET ]; then - diff -u <(echo -n) <(go vet . 2>&1 | grep -vE 'ExampleCommand|bash_completions.*Fprint'); - fi +script: + - make test diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..e9740d1e --- /dev/null +++ b/Makefile @@ -0,0 +1,36 @@ +BIN="./bin" +SRC=$(shell find . -name "*.go") + +ifeq (, $(shell which richgo)) +$(warning "could not find richgo in $(PATH), run: go get github.com/kyoh86/richgo") +endif + +.PHONY: fmt vet test cobra_generator install_deps clean + +default: all + +all: fmt vet test cobra_generator + +fmt: + $(info ******************** checking formatting ********************) + @test -z $(shell gofmt -l $(SRC)) || (gofmt -d $(SRC); exit 1) + +test: install_deps vet + $(info ******************** running tests ********************) + richgo test -v ./... + +cobra_generator: install_deps + $(info ******************** building generator ********************) + mkdir -p $(BIN) + make -C cobra all + +install_deps: + $(info ******************** downloading dependencies ********************) + go get -v ./... + +vet: + $(info ******************** vetting ********************) + go vet ./... + +clean: + rm -rf $(BIN) diff --git a/cobra/Makefile b/cobra/Makefile new file mode 100644 index 00000000..4995000d --- /dev/null +++ b/cobra/Makefile @@ -0,0 +1,23 @@ +XC_OS="linux darwin" +XC_ARCH="amd64" +XC_PARALLEL="2" +BIN="../bin" +SRC=$(shell find . -name "*.go") + +ifeq (, $(shell which gox)) +$(warning "could not find gox in $(PATH), run: go get github.com/mitchellh/gox") +endif + +.PHONY: all build + +default: all + +all: build + +build: + gox \ + -os=$(XC_OS) \ + -arch=$(XC_ARCH) \ + -parallel=$(XC_PARALLEL) \ + -output=$(BIN)/{{.Dir}}_{{.OS}}_{{.Arch}} \ + ;