Skip to content

Commit

Permalink
Switch to Slashes in Make Targets (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
osterman authored Feb 25, 2018
1 parent 95080d4 commit bde0a77
Show file tree
Hide file tree
Showing 31 changed files with 135 additions and 187 deletions.
10 changes: 5 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ addons:
- curl

install:
- make go:deps-build
- make go:deps-dev
- make go/deps-build
- make go/deps-dev

script:
- "make bash:lint"
- "make make:lint"
- "make terraform:install"
- "make bash/lint"
- "make make/lint"
- "make terraform/install"
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,11 @@ export BUILD_HARNESS_PATH ?= $(shell 'pwd')
export OS ?= $(shell uname -s | tr '[:upper:]' '[:lower:]')
export SELF ?= make

# Import Makefiles into current context
include $(BUILD_HARNESS_PATH)/Makefile.*
include $(BUILD_HARNESS_PATH)/modules/*/Makefile*

ifndef TRANSLATE_COLON_NOTATION
%:
@$(SELF) $(subst :,/,$@) TRANSLATE_COLON_NOTATION=false
endif
2 changes: 1 addition & 1 deletion Makefile.helpers
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ default:: help
## This help screen
help:
@printf "Available targets:\n\n"
@awk '/^[a-zA-Z\-\_0-9%:\\]+:/ { \
@awk '/^[a-zA-Z\-\_0-9%:\\\/]+:/ { \
helpMessage = match(lastLine, /^## (.*)/); \
if (helpMessage) { \
helpCommand = $$1; \
Expand Down
93 changes: 47 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,51 +32,52 @@ $ make help

Available targets:

bash:lint Lint all bash scripts
docker:build Build docker image
docker:login Login into docker hub
docs:build Create $OUT file by building it from $IN template file
docs:copyright-add Add copyright headers to source code
docs:deps Install dependencies
geodesic:deploy Run a Jenkins Job to Deploy $(APP) with $(CANONICAL_TAG)
git:aliases-update Update git aliases
github:download-private-release Download release from github
github:download-public-release Download release from github
git:submodules-update Update submodules
go:build Build binary
go:build-all Build binary for all platforms
go:clean Clean compiled binary
go:clean-all Clean compiled binary and dependency
go:deps Install dependencies
go:deps-build Install dependencies for build
go:deps-dev Install development dependencies
go:fmt Format code according to Golang convention
go:install Install cli
go:lint Lint code
go:test Run tests
go:vet Vet code
helm:install Install helm
helm:repo:add-current Add helm remote dev repos
helm:repo:add-remote Add helm remote repos
helm:repo:build Build repo
helm:repo:clean Clean helm repo
helm:repo:fix-perms Fix repo filesystem permissions
helm:repo:info Show repo info
helm:repo:lint Lint charts
helm:serve:index Build index for serve helm charts
bash/lint Lint all bash scripts
docker/build Build docker image
docker/login Login into docker hub
docs/build Create $OUT file by building it from $IN template file
docs/copyright-add Add copyright headers to source code
docs/deps Install dependencies
geodesic/deploy Run a Jenkins Job to Deploy $(APP) with $(CANONICAL_TAG)
git/aliases-update Update git aliases
git/submodules-update Update submodules
github/download-private-release Download release from github
github/download-public-release Download release from github
go/build Build binary
go/build-all Build binary for all platforms
go/clean Clean compiled binary
go/clean-all Clean compiled binary and dependency
go/deps Install dependencies
go/deps-build Install dependencies for build
go/deps-dev Install development dependencies
go/fmt Format code according to Golang convention
go/install Install cli
go/lint Lint code
go/test Run tests
go/vet Vet code
helm/install Install helm
helm/repo/add-current Add helm remote dev repos
helm/repo/add-remote Add helm remote repos
helm/repo/build Build repo
helm/repo/clean Clean helm repo
helm/repo/fix-perms Fix repo filesystem permissions
helm/repo/info Show repo info
helm/repo/lint Lint charts
helm/serve/index Build index for serve helm charts
help This help screen
jenkins:run-job-with-tag Run a Jenkins Job with $(TAG)
make:lint Lint all makefiles
readme:build Create README.md by building it from .README.md file
readme:init Create basic minimalistic .README.md template file
readme:toc-update Update table of contents in README.md
terraform:get-modules Ensure all modules can be fetched
terraform:get-plugins Ensure all plugins can be fetched
terraform:install Install terraform
terraform:lint Lint check Terraform
terraform:validate Basic terraform sanity check
travis:docker-login Login into docker hub
travis:docker-tag-and-push Tag & Push according Travis environment variables
jenkins/run-job-with-tag Run a Jenkins Job with $(TAG)
make/lint Lint all makefiles
readme/build Create README.md by building it from .README.md file
readme/init Create basic minimalistic .README.md template file
readme/toc-update Update table of contents in README.md
terraform/get-modules Ensure all modules can be fetched
terraform/get-plugins Ensure all plugins can be fetched
terraform/install Install terraform
terraform/lint Lint check Terraform
terraform/validate Basic terraform sanity check
test/me Test target
travis/docker-login Login into docker hub
travis/docker-tag-and-push Tag & Push according Travis environment variables
```

## Real World Examples
Expand Down Expand Up @@ -155,8 +156,8 @@ or [hire us][hire] to help build your next cloud-platform.

### Contributors

|[![Erik Osterman][erik_img]][erik_web]<br/>[Erik Osterman][erik_web] |[![Igor Rodionov][igor_img]][igor_web]<br/>[Igor Rodionov][igor_img] |
|---|---|
|[![Erik Osterman][erik_img]][erik_web]<br/>[Erik Osterman][erik_web] |[![Igor Rodionov][igor_img]][igor_web]<br/>[Igor Rodionov][igor_img] |[![Andriy Knysh][andriy_img]][andriy_web]<br/>[Andriy Knysh][andriy_web] |
|---|---|---|

[andriy_img]: https://avatars0.githubusercontent.com/u/7356997?v=4&u=ed9ce1c9151d552d985bdf5546772e14ef7ab617&s=144
[andriy_web]: https://github.com/aknysh/
Expand Down
4 changes: 2 additions & 2 deletions bin/doc_generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function array-merge {
## Example of usage
## module ./.README.md
function modules {
grep -oP "(?<=datasource)\s+\".*?\"" $1 | sed 's/[ |\"]//g' | sort | uniq | paste -sd " " -
grep -Eo '\(datasource ".*?"\)' "$1" |cut -d'"' -f2 | sort -u | paste -sd " " -
}

## Fire event $1 for all modules passed as args
Expand Down Expand Up @@ -55,7 +55,7 @@ function datasources {
done
}

## Register modules
## Register all documentation modules
for file in $BUILD_HARNESS_PATH/modules/*/docs/*.sh ; do
if [ -f "$file" ] ; then
. "$file"
Expand Down
2 changes: 1 addition & 1 deletion modules/bash/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## Lint all bash scripts
bash\:lint:
bash/lint:
@set -o pipefail; \
(find . -type f -name '*.sh'; \
grep -l -r '#!/bin/bash' .; \
Expand Down
3 changes: 0 additions & 3 deletions modules/docker/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
DOCKER:= $(shell which docker)

default::
@exit 0
3 changes: 1 addition & 2 deletions modules/docker/Makefile.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ DOCKER_BUILD_PATH ?= .
DOCKER_BUILD_FLAGS ?= --no-cache
DOCKER_FILE ?= ./Dockerfile

.PHONY: docker\:build
## Build docker image
docker\:build: $(DOCKER)
docker/build: $(DOCKER)
$(call assert-set,DOCKER)
$(call assert-set,DOCKER_IMAGE_NAME)
ifeq ($(TRAVIS),true)
Expand Down
3 changes: 1 addition & 2 deletions modules/docker/Makefile.hub
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
.PHONY: docker\:login
## Use DOCKER_HUB_USERNAME and DOCKER_HUB_PASSWORD env variables to pass credentials
## Login into docker hub
docker\:login: $(DOCKER)
docker/login: $(DOCKER)
@if [ -n "$(DOCKER_HUB_USERNAME)" ] && [ -n "$(DOCKER_HUB_PASSWORD)" ]; then \
$(DOCKER) login --username="$(DOCKER_HUB_USERNAME)" --password="$(DOCKER_HUB_PASSWORD)"; \
else \
Expand Down
10 changes: 3 additions & 7 deletions modules/docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,15 @@ export GOMPLATE ?= $(BUILD_HARNESS_PATH)/vendor/gomplate
GOMPLATE_VERSION ?= v2.2.0
GOMPLATE_REPO ?= hairyhenderson/gomplate


## Install dependencies
docs\:deps:
@make github:download-public-release \
docs/deps:
@[ -f $(GOMPLATE) ] || $(SELF) github/download-public-release \
REPO=$(GOMPLATE_REPO) \
FILE=gomplate_$(OS)-amd64 \
VERSION=$(GOMPLATE_VERSION) \
OUTPUT=$(GOMPLATE) > /dev/null
@chmod +x $(GOMPLATE)



.PHONY : docs\:build
## Create $OUT file by building it from $IN template file
docs\:build:
docs/build: docs/deps
@$(BUILD_HARNESS_PATH)/bin/doc_generate.sh
3 changes: 1 addition & 2 deletions modules/docs/Makefile.copyright
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ COPYRIGHT_YEAR ?= $(shell date +%Y)
COPYRIGHT_OUTPUT_DIR ?= /usr/src
COPYRIGHT_WORD_WRAP ?= 100

.PHONY : docs\:copyright-add
## Add copyright headers to source code
docs\:copyright-add:
docs/copyright-add:
$(call assert-set,COPYRIGHT_SOFTWARE)
$(call assert-set,COPYRIGHT_SOFTWARE_DESCRIPTION)
$(COPYRIGHT_CMD) \
Expand Down
2 changes: 1 addition & 1 deletion modules/docs/docs/templates/contributor.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
andrew: |-
andriy: |-
[![Andriy Knysh][andriy_img]][andriy_web]<br/>[Andriy Knysh][andriy_web]
erik: |-
Expand Down
4 changes: 2 additions & 2 deletions modules/geodesic/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Run a Jenkins Job to Deploy $(APP) with $(CANONICAL_TAG)
geodesic\:deploy:
geodesic/deploy:
$(call assert-set,APP)
@$(SELF) jenkins:run-job-with-tag \
@$(SELF) jenkins/run-job-with-tag \
JOB=deploy-$(APP) \
TAG=$(CANONICAL_TAG)
6 changes: 2 additions & 4 deletions modules/git/Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
GIT:= $(shell which git)

.PHONY: git\:submodules-update
## Update submodules
git\:submodules-update:
git/submodules-update:
$(call assert-set,GIT)
$(GIT) submodule update --init --remote

.PHONY: git\:aliases-update
## Update git aliases
git\:aliases-update:
git/aliases-update:
@$(GIT) config --global --add alias.permission-reset '!git diff -p -R --no-color | grep -E "^(diff|(old|new) mode)" --color=never | git apply'
2 changes: 1 addition & 1 deletion modules/git/docs/module.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function git_data-docs-prepare-data {
cat << EOF > $GIT_DATA_FILE
---
url: $(git ls-remote --get-url)
name: $(git ls-remote --get-url | grep -oP "(?<=\/).*(?=.git)")
name: $(basename -s .git `git ls-remote --get-url`)
EOF
}

Expand Down
6 changes: 2 additions & 4 deletions modules/github/Makefile.release
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
.PHONY: github\:download-private-release
## GITHUB_TOKEN="<github_access_token>"
## REPO="<user_or_org>/<repo_name>"
## FILE="<name_of_asset_file>" # the name of your release asset file, e.g. build.tar.gz
## Download release from github
github\:download-private-release:
github/download-private-release:
$(call assert-set,GITHUB_TOKEN)
$(call assert-set,REPO)
$(call assert-set,FILE)
$(call assert-set,VERSION)
$(call assert-set,OUTPUT)
$(BUILD_HARNESS_PATH)/bin/github_download_private_release.sh $(VERSION) $(OUTPUT)

.PHONY: github\:download-public-release
## REPO="<user_or_org>/<repo_name>"
## FILE="<name_of_asset_file>" # the name of your release asset file, e.g. build.tar.gz
## Download release from github
github\:download-public-release:
github/download-public-release:
$(call assert-set,REPO)
$(call assert-set,FILE)
$(call assert-set,VERSION)
Expand Down
3 changes: 0 additions & 3 deletions modules/go/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
GO:= $(shell which go)

default::
@exit 0
21 changes: 8 additions & 13 deletions modules/go/Makefile.build
Original file line number Diff line number Diff line change
Expand Up @@ -3,55 +3,50 @@ INSTALL_DIR ?= /usr/local/sbin
RELEASE_DIR ?= release
APP ?= $(shell basename `pwd`)

.PHONY: go\:build
## Build binary
go\:build: $(GO)
go/build: $(GO)
$(call assert-set,GO)
$(GO) build -o $(RELEASE_DIR)/$(APP)

.PHONY: go\:build-all
## Build binary for all platforms
go\:build-all: $(GO)
go/build-all: $(GO)
$(call assert-set,GO)
ifeq ($(RELEASE_ARCH),)
gox -output "${RELEASE_DIR}/${APP}_{{.OS}}_{{.Arch}}"
else
gox -osarch="$(RELEASE_ARCH)" -output "${RELEASE_DIR}/${APP}_{{.OS}}_{{.Arch}}"
endif

.PHONY: go\:deps
## Install dependencies
go\:deps: $(GLIDE)
go/deps: $(GLIDE)
$(call assert-set,GLIDE)
$(GLIDE) install --strip-vendor
$(GLIDE) update --strip-vendor

.PHONY: go\:deps-build
## Install dependencies for build
go\:deps-build:
go/deps-build:
$(call assert-set,GOPATH)
mkdir -p $(GOPATH)/bin
which $(GLIDE) || (curl https://glide.sh/get | sh)

.PHONY: deps-dev
## Install development dependencies
go\:deps-dev: $(GO)
go/deps-dev: $(GO)
$(call assert-set,GO)
$(GO) get -d -v "github.com/golang/lint"
$(GO) install -v "github.com/golang/lint/golint"
$(GO) get -d -v github.com/mitchellh/gox
$(GO) install -v github.com/mitchellh/gox

## Clean compiled binary
go\:clean:
go/clean:
rm -rf $(RELEASE_DIR)

## Clean compiled binary and dependency
go\:clean-all: go\:clean
go/clean-all: clean
rm -rf vendor
rm -rf glide.lock

## Install cli
go\:install: $(APP) go\:build
go/install: $(APP) build
cp $(RELEASE_DIR)/$(APP) $(INSTALL_DIR)
chmod 555 $(INSTALL_DIR)/$(APP)
9 changes: 3 additions & 6 deletions modules/go/Makefile.style
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
.PHONY: go\:lint
## Lint code
go\:lint: $(GO) go\:vet
go/lint: $(GO) vet
$(call assert-set,GO)
find . ! -path "*/vendor/*" ! -path "*/.glide/*" -type f -name '*.go' | xargs -n 1 golint

.PHONY: go\:vet
## Vet code
go\:vet: $(GO)
go/vet: $(GO)
$(call assert-set,GO)
find . ! -path "*/vendor/*" ! -path "*/.glide/*" -type f -name '*.go' | xargs -n 1 $(GO) vet -v

.PHONY: go\:fmt
## Format code according to Golang convention
go\:fmt: $(GO)
go/fmt: $(GO)
$(call assert-set,GO)
find . ! -path "*/vendor/*" ! -path "*/.glide/*" -type f -name '*.go' | xargs -n 1 gofmt -w -l -s
3 changes: 1 addition & 2 deletions modules/go/Makefile.test
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
.PHONY: go\:test
## Run tests
go\:test: $(GO)
go/test: $(GO)
$(call assert-set,GO)
ifneq ($(LINT),true)
$(GO) test $(shell $(GO) list ./... | grep -v /vendor/)
Expand Down
Loading

0 comments on commit bde0a77

Please sign in to comment.