|
| 1 | +# Package configuration |
| 2 | +PROJECT := gitbase-playground |
| 3 | +COMMANDS := cmd/gitbase-playground |
| 4 | +DOCKER_ORG := src-d |
| 5 | +DEPENDENCIES := \ |
| 6 | + github.com/golang/dep/cmd/dep \ |
| 7 | + github.com/jteeuwen/go-bindata \ |
| 8 | + github.com/golang/lint/golint |
| 9 | +GO_LINTABLE_PACKAGES := $(shell go list ./... | grep -v '/vendor/') |
| 10 | +GO_BUILD_ENV := CGO_ENABLED=0 |
| 11 | + |
| 12 | +# Tools |
| 13 | +GODEP := dep |
| 14 | +GOLINT := golint |
| 15 | +GOVET := go vet |
| 16 | +BINDATA := go-bindata |
| 17 | +DIFF := diff |
| 18 | + |
| 19 | +# Default rule |
| 20 | +all: |
| 21 | + |
| 22 | +# Including ci Makefile |
| 23 | +CI_REPOSITORY ?= https://github.com/dpordomingo/ci.git |
| 24 | +CI_BRANCH ?= v1 |
| 25 | +CI_PATH ?= $(shell pwd)/.ci |
| 26 | +MAKEFILE := $(CI_PATH)/Makefile.main |
| 27 | +$(MAKEFILE): |
| 28 | + @git clone --quiet --depth 1 -b $(CI_BRANCH) $(CI_REPOSITORY) $(CI_PATH); |
| 29 | +-include $(MAKEFILE) |
| 30 | + |
| 31 | +# Makefile.main::dependencies -> Makefile.main::$(DEPENDENCIES) -> this::dependencies |
| 32 | +# The `exit` is needed to prevent running `Makefile.main::dependencies` commands. |
| 33 | +dependencies: | front-dependencies back-dependencies exit |
| 34 | + |
| 35 | +# Makefile.main::test -> this::test |
| 36 | +test: front-test |
| 37 | + |
| 38 | +# this::build -> Makefile.main::build -> Makefile.main::$(COMMANDS) |
| 39 | +# The @echo forces this prerequisites to be run before `Makefile.main::build` ones. |
| 40 | +build: front-build back-build |
| 41 | + @echo |
| 42 | + |
| 43 | +coverage: | test-coverage codecov |
| 44 | + |
| 45 | +lint: back-lint front-lint |
| 46 | + |
| 47 | +validate-commit: | \ |
| 48 | + back-dependencies \ |
| 49 | + back-ensure-assets-proxy \ |
| 50 | + front-fix-lint-errors \ |
| 51 | + no-changes-in-commit |
| 52 | + |
| 53 | +exit: |
| 54 | + exit 0; |
| 55 | + |
| 56 | + |
| 57 | +## Compiles the assets, and serve the tool through its API |
| 58 | + |
| 59 | +serve: | front-build back-start |
| 60 | + |
| 61 | + |
| 62 | +# Backend |
| 63 | + |
| 64 | +assets := ./server/assets/asset.go |
| 65 | +assets_back := $(assets).bak |
| 66 | + |
| 67 | +back-dependencies: |
| 68 | + $(GODEP) ensure |
| 69 | + |
| 70 | +back-build: back-bindata |
| 71 | + |
| 72 | +back-bindata: |
| 73 | + $(BINDATA) \ |
| 74 | + -pkg assets \ |
| 75 | + -o $(assets) \ |
| 76 | + build/public/* |
| 77 | + |
| 78 | +back-lint: $(GO_LINTABLE_PACKAGES) |
| 79 | +$(GO_LINTABLE_PACKAGES): |
| 80 | + $(GOLINT) $@ |
| 81 | + $(GOVET) $@ |
| 82 | + |
| 83 | +back-start: |
| 84 | + GITBASEPG_ENV=dev go run cmd/gitbase-playground/main.go |
| 85 | + |
| 86 | +back-ensure-assets-proxy: |
| 87 | + $(DIFF) $(assets) $(assets_back) || exit 1 |
| 88 | + |
| 89 | +go-test-integration-packages := ./server/handler |
| 90 | +go-test-integration-flags := -v -args -test.integration.gitbase -test.integration.bblfshd |
| 91 | +back-test-integration: |
| 92 | + go test $(go-test-integration-packages) $(go-test-integration-flags) |
| 93 | + |
| 94 | + |
| 95 | +# Frontend |
| 96 | + |
| 97 | +front-dependencies: |
| 98 | + echo 'SKIP. no frontend dependencies to install' |
| 99 | + |
| 100 | +front-test: |
| 101 | + echo 'SKIP. no frontend tests to run' |
| 102 | + |
| 103 | +front-lint: |
| 104 | + echo 'SKIP. no frontend linters to run' |
| 105 | + |
| 106 | +front-build: |
| 107 | + mkdir -p build/public |
| 108 | + cp public/index.html build/public/index.html |
| 109 | + cp public/secondary.html build/public/secondary.html |
| 110 | + |
| 111 | +front-fix-lint-errors: |
| 112 | + echo 'SKIP. no fixable code' |
| 113 | + |
| 114 | + |
0 commit comments