statping/Makefile

193 lines
8.6 KiB
Makefile
Raw Normal View History

2018-08-23 07:28:48 +00:00
VERSION=0.51
2018-08-16 06:22:20 +00:00
BINARY_NAME=statup
2018-08-14 05:59:51 +00:00
GOPATH:=$(GOPATH)
2018-08-15 03:02:52 +00:00
GOCMD=go
2018-08-14 04:13:06 +00:00
GOBUILD=$(GOCMD) build
GOTEST=$(GOCMD) test
GOGET=$(GOCMD) get
GOINSTALL=$(GOCMD) install
2018-08-19 08:48:02 +00:00
XGO=GOPATH=$(GOPATH) xgo -go 1.10.x --dest=build
2018-08-16 06:22:20 +00:00
BUILDVERSION=-ldflags "-X main.VERSION=$(VERSION) -X main.COMMIT=$(TRAVIS_COMMIT)"
2018-08-14 05:59:51 +00:00
RICE=$(GOPATH)/bin/rice
2018-08-14 04:13:06 +00:00
PATH:=/usr/local/bin:$(GOPATH)/bin:$(PATH)
2018-08-17 01:43:12 +00:00
PUBLISH_BODY='{ "request": { "branch": "master", "config": { "env": { "VERSION": "$(VERSION)", "COMMIT": "$(TRAVIS_COMMIT)" } } } }'
2018-08-17 20:05:11 +00:00
TRAVIS_BUILD_CMD='{ "request": { "branch": "master", "message": "Compile master for Statup v$(VERSION)", "config": { "os": [ "linux" ], "language": "go", "go": [ "1.10.x" ], "go_import_path": "github.com/hunterlong/statup", "install": true, "sudo": "required", "services": [ "docker" ], "env": { "VERSION": "$(VERSION)" }, "matrix": { "allow_failures": [ { "go": "master" } ], "fast_finish": true }, "before_deploy": [ "git config --local user.name \"hunterlong\"", "git config --local user.email \"info@socialeck.com\"", "make tag" ], "deploy": [ { "provider": "releases", "api_key": "$(GH_TOKEN)", "file": [ "build/statup-osx-x64.tar.gz", "build/statup-osx-x32.tar.gz", "build/statup-linux-x64.tar.gz", "build/statup-linux-x32.tar.gz", "build/statup-linux-arm64.tar.gz", "build/statup-linux-arm7.tar.gz", "build/statup-linux-alpine.tar.gz", "build/statup-windows-x64.zip" ], "skip_cleanup": true } ], "notifications": { "email": false }, "before_script": ["gem install sass"], "script": [ "travis_wait 30 docker pull karalabe/xgo-latest", "make release" ], "after_success": [], "after_deploy": [ "make publish-dev" ] } } }'
2018-08-16 20:55:30 +00:00
TEST_DIR=$(GOPATH)/src/github.com/hunterlong/statup
2018-08-15 08:08:50 +00:00
all: dev-deps compile install test-all
2018-08-14 04:13:06 +00:00
release: dev-deps build-all compress
2018-08-17 16:13:20 +00:00
test-all: dev-deps test cypress-test
travis-test: dev-deps cypress-install test docker-test cypress-test coverage
2018-08-14 04:13:06 +00:00
docker-build-all: docker-build-base docker-dev docker
docker-publish-all: docker-push-base docker-push-dev docker-push-latest
2018-08-21 17:08:58 +00:00
2018-08-17 16:13:20 +00:00
build: compile
$(GOBUILD) $(BUILDVERSION) -o $(BINARY_NAME) -v ./cmd
install: build
2018-08-14 04:13:06 +00:00
mv $(BINARY_NAME) $(GOPATH)/bin/$(BINARY_NAME)
$(GOPATH)/bin/$(BINARY_NAME) version
run: build
2018-08-17 04:39:25 +00:00
./$(BINARY_NAME) --ip 0.0.0.0 --port 8080
2018-08-14 04:13:06 +00:00
compile:
cd source && $(GOPATH)/bin/rice embed-go
2018-08-16 06:22:20 +00:00
sass source/scss/base.scss source/css/base.css
2018-08-21 06:54:39 +00:00
rm -rf .sass-cache
2018-08-14 04:13:06 +00:00
2018-08-16 06:22:20 +00:00
test: clean compile install
2018-08-17 15:03:46 +00:00
STATUP_DIR=$(TEST_DIR) go test -v -p=1 $(BUILDVERSION) -coverprofile=coverage.out ./...
2018-08-16 01:15:14 +00:00
gocov convert coverage.out > coverage.json
2018-08-14 04:13:06 +00:00
2018-08-14 05:10:51 +00:00
coverage:
$(GOPATH)/bin/goveralls -coverprofile=coverage.out -service=travis -repotoken $(COVERALLS)
docs:
godoc2md github.com/hunterlong/statup > servers/docs/README.md
gocov-html coverage.json > servers/docs/COVERAGE.html
revive -formatter stylish > servers/docs/LINT.md
2018-08-14 04:13:06 +00:00
build-all: clean compile
mkdir build
$(XGO) $(BUILDVERSION) --targets=darwin/amd64 ./cmd
$(XGO) $(BUILDVERSION) --targets=darwin/386 ./cmd
$(XGO) $(BUILDVERSION) --targets=linux/amd64 ./cmd
$(XGO) $(BUILDVERSION) --targets=linux/386 ./cmd
$(XGO) $(BUILDVERSION) --targets=windows-6.0/amd64 ./cmd
$(XGO) $(BUILDVERSION) --targets=linux/arm-7 ./cmd
$(XGO) $(BUILDVERSION) --targets=linux/arm64 ./cmd
2018-08-16 06:52:13 +00:00
$(XGO) --targets=linux/amd64 -ldflags="-X main.VERSION=$(VERSION) -X main.COMMIT=$(TRAVIS_COMMIT) -linkmode external -extldflags -static" -out alpine ./cmd
2018-08-16 06:22:20 +00:00
build-alpine: clean compile
mkdir build
2018-08-16 06:52:13 +00:00
$(XGO) --targets=linux/amd64 -ldflags="-X main.VERSION=$(VERSION) -X main.COMMIT=$(TRAVIS_COMMIT) -linkmode external -extldflags -static" -out alpine ./cmd
2018-08-14 04:13:06 +00:00
docker:
2018-08-22 07:16:24 +00:00
docker build --no-cache -t hunterlong/statup:latest .
2018-08-14 04:13:06 +00:00
docker-run: docker
2018-08-19 08:48:02 +00:00
docker run -it -p 8080:8080 hunterlong/statup:latest
2018-08-14 04:13:06 +00:00
2018-08-22 07:16:24 +00:00
docker-dev: clean docker-build-base
docker build -t hunterlong/statup:dev --no-cache -f dev/Dockerfile-dev .
docker-push-dev:
2018-08-19 00:37:00 +00:00
docker push hunterlong/statup:dev
docker push hunterlong/statup:cypress
2018-08-19 00:37:00 +00:00
2018-08-19 09:16:15 +00:00
docker-push-latest: docker
docker push hunterlong/statup:latest
2018-08-19 00:37:00 +00:00
docker-run-dev: docker-dev
2018-08-16 06:52:13 +00:00
docker run -t -p 8080:8080 hunterlong/statup:dev
2018-08-14 05:10:51 +00:00
2018-08-19 23:51:56 +00:00
docker-cypress: clean
GOPATH=$(GOPATH) xgo -out statup -go 1.10.x -ldflags "-X main.VERSION=$(VERSION) -X main.COMMIT=$(TRAVIS_COMMIT)" --targets=linux/amd64 ./cmd
docker build -t hunterlong/statup:cypress -f dev/Dockerfile-cypress .
rm -f statup
2018-08-19 08:48:02 +00:00
2018-08-19 23:51:56 +00:00
docker-run-cypress: docker-cypress
docker run -t hunterlong/statup:cypress
2018-08-19 08:48:02 +00:00
2018-08-21 17:08:58 +00:00
docker-push-base:
docker tag hunterlong/statup:base hunterlong/statup:base-v$(VERSION)
docker push hunterlong/statup:base
docker push hunterlong/statup:base-v$(VERSION)
2018-08-25 16:10:28 +00:00
docker-build-base:
2018-08-19 08:48:02 +00:00
wget -q https://assets.statup.io/sass && chmod +x sass
$(XGO) --targets=linux/amd64 -ldflags="-X main.VERSION=$(VERSION) -linkmode external -extldflags -static" -out alpine ./cmd
2018-08-22 07:16:24 +00:00
docker build -t hunterlong/statup:base --no-cache -f dev/Dockerfile-base .
2018-08-20 23:29:09 +00:00
docker tag hunterlong/statup:base hunterlong/statup:base-v$(VERSION)
docker-build-latest:
docker build -t hunterlong/statup:latest --no-cache -f Dockerfile .
2018-08-19 08:48:02 +00:00
2018-08-14 05:10:51 +00:00
databases:
2018-08-16 06:52:13 +00:00
docker run --name statup_postgres -p 5432:5432 -e POSTGRES_PASSWORD=password123 -e POSTGRES_USER=root -e POSTGRES_DB=root -d postgres
docker run --name statup_mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=password123 -e MYSQL_DATABASE=root -d mysql
2018-08-14 05:10:51 +00:00
sleep 30
2018-08-14 04:13:06 +00:00
dep:
2018-08-19 08:48:02 +00:00
dep ensure -vendor-only
2018-08-17 17:43:51 +00:00
dev-deps: dep
2018-08-14 04:13:06 +00:00
$(GOGET) github.com/stretchr/testify/assert
$(GOGET) golang.org/x/tools/cmd/cover
$(GOGET) github.com/mattn/goveralls
$(GOINSTALL) github.com/mattn/goveralls
$(GOGET) github.com/rendon/testcli
$(GOGET) github.com/karalabe/xgo
$(GOGET) github.com/GeertJohan/go.rice
$(GOGET) github.com/GeertJohan/go.rice/rice
2018-08-14 05:59:51 +00:00
$(GOINSTALL) github.com/GeertJohan/go.rice/rice
$(GOCMD) get github.com/davecheney/godoc2md
$(GOCMD) install github.com/davecheney/godoc2md
$(GOCMD) get github.com/axw/gocov/gocov
2018-08-17 15:03:46 +00:00
$(GOCMD) get gopkg.in/matm/v1/gocov-html
$(GOCMD) install gopkg.in/matm/v1/gocov-html
$(GOCMD) get github.com/mgechev/revive
2018-08-14 04:13:06 +00:00
clean:
2018-08-25 16:10:28 +00:00
rm -rf ./{logs,assets,plugins,statup.db,config.yml,.sass-cache,config.yml,statup,build,.sass-cache,statup.db,index.html,vendor}
2018-08-19 23:51:56 +00:00
rm -rf cmd/{logs,assets,plugins,statup.db,config.yml,.sass-cache,*.log}
rm -rf core/{logs,assets,plugins,statup.db,config.yml,.sass-cache,*.log}
rm -rf handlers/{logs,assets,plugins,statup.db,config.yml,.sass-cache,*.log}
rm -rf notifiers/{logs,assets,plugins,statup.db,config.yml,.sass-cache,*.log}
rm -rf source/{logs,assets,plugins,statup.db,config.yml,.sass-cache,*.log}
rm -rf types/{logs,assets,plugins,statup.db,config.yml,.sass-cache,*.log}
rm -rf utils/{logs,assets,plugins,statup.db,config.yml,.sass-cache,*.log}
2018-08-19 08:48:02 +00:00
rm -rf dev/test/cypress/videos
2018-08-25 16:10:28 +00:00
rm -f coverage.* sass
2018-08-14 04:13:06 +00:00
tag:
git tag "v$(VERSION)" --force
compress:
2018-08-15 05:30:15 +00:00
cd build && mv alpine-linux-amd64 $(BINARY_NAME)
cd build && tar -czvf $(BINARY_NAME)-linux-alpine.tar.gz $(BINARY_NAME) && rm -f $(BINARY_NAME)
cd build && mv cmd-darwin-10.6-amd64 $(BINARY_NAME)
cd build && tar -czvf $(BINARY_NAME)-osx-x64.tar.gz $(BINARY_NAME) && rm -f $(BINARY_NAME)
cd build && mv cmd-darwin-10.6-386 $(BINARY_NAME)
cd build && tar -czvf $(BINARY_NAME)-osx-x32.tar.gz $(BINARY_NAME) && rm -f $(BINARY_NAME)
cd build && mv cmd-linux-amd64 $(BINARY_NAME)
cd build && tar -czvf $(BINARY_NAME)-linux-x64.tar.gz $(BINARY_NAME) && rm -f $(BINARY_NAME)
cd build && mv cmd-linux-386 $(BINARY_NAME)
cd build && tar -czvf $(BINARY_NAME)-linux-x32.tar.gz $(BINARY_NAME) && rm -f $(BINARY_NAME)
cd build && mv cmd-windows-6.0-amd64.exe $(BINARY_NAME).exe
cd build && zip $(BINARY_NAME)-windows-x64.zip $(BINARY_NAME).exe && rm -f $(BINARY_NAME).exe
cd build && mv cmd-linux-arm-7 $(BINARY_NAME)
cd build && tar -czvf $(BINARY_NAME)-linux-arm7.tar.gz $(BINARY_NAME) && rm -f $(BINARY_NAME)
cd build && mv cmd-linux-arm64 $(BINARY_NAME)
2018-08-15 08:08:50 +00:00
cd build && tar -czvf $(BINARY_NAME)-linux-arm64.tar.gz $(BINARY_NAME) && rm -f $(BINARY_NAME)
2018-08-16 06:22:20 +00:00
publish-dev:
curl -H "Content-Type: application/json" --data '{"docker_tag": "dev"}' -X POST $(DOCKER)
publish-latest:
curl -H "Content-Type: application/json" --data '{"docker_tag": "latest"}' -X POST $(DOCKER)
publish-homebrew:
2018-08-16 06:52:13 +00:00
curl -s -X POST -H "Content-Type: application/json" -H "Accept: application/json" -H "Travis-API-Version: 3" -H "Authorization: token $(TRAVIS_API)" -d $(PUBLISH_BODY) https://api.travis-ci.com/repo/hunterlong%2Fhomebrew-statup/requests
2018-08-16 06:22:20 +00:00
cypress-install:
2018-08-19 22:16:59 +00:00
cd dev/test && npm install
2018-08-16 06:22:20 +00:00
2018-08-17 08:59:01 +00:00
cypress-test: clean cypress-install
2018-08-19 08:48:02 +00:00
cd dev/test && npm test
2018-08-17 01:43:12 +00:00
2018-08-17 16:13:20 +00:00
travis-build:
curl -s -X POST -H "Content-Type: application/json" -H "Accept: application/json" -H "Travis-API-Version: 3" -H "Authorization: token $(TRAVIS_API)" -d $(TRAVIS_BUILD_CMD) https://api.travis-ci.com/repo/hunterlong%2Fstatup/requests
2018-08-19 08:48:02 +00:00
xgo-install: clean
go get github.com/karalabe/xgo
docker pull karalabe/xgo-latest
2018-08-21 17:08:58 +00:00
.PHONY: build build-all build-alpine test-all test