Fix travis and expand makefile targets
This commit is contained in:
parent
6b4eb57571
commit
0c7cfe5609
@ -12,7 +12,7 @@ addons:
|
|||||||
go_import_path: github.com/vulcanize/vulcanizedb
|
go_import_path: github.com/vulcanize/vulcanizedb
|
||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
# ginkgo golint dep migrate
|
# ginkgo golint dep goose
|
||||||
- make installtools
|
- make installtools
|
||||||
- bash ./scripts/install-postgres-10.sh
|
- bash ./scripts/install-postgres-10.sh
|
||||||
- npm install -g ganache-cli
|
- npm install -g ganache-cli
|
||||||
@ -23,6 +23,7 @@ before_install:
|
|||||||
before_script:
|
before_script:
|
||||||
- go get -u github.com/pressly/sup/cmd/sup
|
- go get -u github.com/pressly/sup/cmd/sup
|
||||||
- sudo -u postgres createdb vulcanize_private
|
- sudo -u postgres createdb vulcanize_private
|
||||||
|
- make version_migrations
|
||||||
- make migrate NAME=vulcanize_private
|
- make migrate NAME=vulcanize_private
|
||||||
- bash ./pkg/transformers/start_test_chain.sh
|
- bash ./pkg/transformers/start_test_chain.sh
|
||||||
- cd postgraphile && yarn
|
- cd postgraphile && yarn
|
||||||
|
44
Makefile
44
Makefile
@ -3,28 +3,34 @@ BASE = $(GOPATH)/src/$(PACKAGE)
|
|||||||
PKGS = go list ./... | grep -v "^vendor/"
|
PKGS = go list ./... | grep -v "^vendor/"
|
||||||
|
|
||||||
# Tools
|
# Tools
|
||||||
|
## Dependency management
|
||||||
DEP = $(BIN)/dep
|
DEP = $(BIN)/dep
|
||||||
$(BIN)/dep:
|
$(BIN)/dep:
|
||||||
go get -u github.com/golang/dep/cmd/dep
|
go get -u github.com/golang/dep/cmd/dep
|
||||||
|
|
||||||
|
## Testing library
|
||||||
GINKGO = $(BIN)/ginkgo
|
GINKGO = $(BIN)/ginkgo
|
||||||
$(BIN)/ginkgo:
|
$(BIN)/ginkgo:
|
||||||
go get -u github.com/onsi/ginkgo/ginkgo
|
go get -u github.com/onsi/ginkgo/ginkgo
|
||||||
|
|
||||||
|
## Migration tool
|
||||||
GOOSE = $(BIN)/goose
|
GOOSE = $(BIN)/goose
|
||||||
$(BIN)/goose:
|
$(BIN)/goose:
|
||||||
go get -u -d github.com/pressly/goose/cmd/goose
|
go get -u -d github.com/pressly/goose/cmd/goose
|
||||||
go build -tags='no_mysql no_sqlite' -o $(BIN)/goose github.com/pressly/goose
|
go build -tags='no_mysql no_sqlite' -o $(BIN)/goose github.com/pressly/goose
|
||||||
|
|
||||||
|
## Source linter
|
||||||
LINT = $(BIN)/golint
|
LINT = $(BIN)/golint
|
||||||
$(BIN)/golint:
|
$(BIN)/golint:
|
||||||
go get -u golang.org/x/lint/golint
|
go get -u golang.org/x/lint/golint
|
||||||
|
|
||||||
|
## Combination linter
|
||||||
METALINT = $(BIN)/gometalinter.v2
|
METALINT = $(BIN)/gometalinter.v2
|
||||||
$(BIN)/gometalinter.v2:
|
$(BIN)/gometalinter.v2:
|
||||||
go get -u gopkg.in/alecthomas/gometalinter.v2
|
go get -u gopkg.in/alecthomas/gometalinter.v2
|
||||||
$(METALINT) --install
|
$(METALINT) --install
|
||||||
|
|
||||||
|
|
||||||
.PHONY: installtools
|
.PHONY: installtools
|
||||||
installtools: | $(LINT) $(GOOSE) $(GINKGO) $(DEP)
|
installtools: | $(LINT) $(GOOSE) $(GINKGO) $(DEP)
|
||||||
echo "Installing tools"
|
echo "Installing tools"
|
||||||
@ -66,6 +72,8 @@ PORT = 5432
|
|||||||
NAME =
|
NAME =
|
||||||
CONNECT_STRING=postgresql://$(HOST_NAME):$(PORT)/$(NAME)?sslmode=disable
|
CONNECT_STRING=postgresql://$(HOST_NAME):$(PORT)/$(NAME)?sslmode=disable
|
||||||
|
|
||||||
|
# Parameter checks
|
||||||
|
## Check that DB variables are provided
|
||||||
.PHONY: checkdbvars
|
.PHONY: checkdbvars
|
||||||
checkdbvars:
|
checkdbvars:
|
||||||
test -n "$(HOST_NAME)" # $$HOST_NAME
|
test -n "$(HOST_NAME)" # $$HOST_NAME
|
||||||
@ -73,50 +81,66 @@ checkdbvars:
|
|||||||
test -n "$(NAME)" # $$NAME
|
test -n "$(NAME)" # $$NAME
|
||||||
@echo $(CONNECT_STRING)
|
@echo $(CONNECT_STRING)
|
||||||
|
|
||||||
|
## Check that the migration variable (id/timestamp) is provided
|
||||||
|
.PHONY: checkmigration
|
||||||
|
checkmigration:
|
||||||
|
test -n "$(MIGRATION)" # $$MIGRATION
|
||||||
|
|
||||||
# Goose defaults down migrations to 1 step
|
# Check that the migration name is provided
|
||||||
|
.PHONY: checkmigname
|
||||||
|
checkmigname:
|
||||||
|
test -n "$(NAME)" # $$NAME
|
||||||
|
|
||||||
|
# Migration operations
|
||||||
|
## Rollback the last migration
|
||||||
.PHONY: rollback
|
.PHONY: rollback
|
||||||
rollback: $(GOOSE) checkdbvars
|
rollback: $(GOOSE) checkdbvars
|
||||||
cd db/migrations;\
|
cd db/migrations;\
|
||||||
$(GOOSE) postgres "$(CONNECT_STRING)" down
|
$(GOOSE) postgres "$(CONNECT_STRING)" down
|
||||||
pg_dump -O -s $(CONNECT_STRING) > db/schema.sql
|
pg_dump -O -s $(CONNECT_STRING) > db/schema.sql
|
||||||
|
|
||||||
.PHONY: checkmigration
|
|
||||||
checkmigration:
|
|
||||||
test -n "$(MIGRATION)" # $$MIGRATION
|
|
||||||
|
|
||||||
# MIGRATION is either a version integer or a timestamp
|
## Rollbackt to a select migration (id/timestamp)
|
||||||
.PHONY: rollback_to
|
.PHONY: rollback_to
|
||||||
rollback_to: $(GOOSE) checkmigration checkdbvars
|
rollback_to: $(GOOSE) checkmigration checkdbvars
|
||||||
cd db/migrations;\
|
cd db/migrations;\
|
||||||
$(GOOSE) postgres "$(CONNECT_STRING)" down-to "$(MIGRATION)"
|
$(GOOSE) postgres "$(CONNECT_STRING)" down-to "$(MIGRATION)"
|
||||||
|
|
||||||
|
## Apply all migrations not already run
|
||||||
.PHONY: migrate
|
.PHONY: migrate
|
||||||
migrate: $(GOOSE) checkdbvars
|
migrate: $(GOOSE) checkdbvars
|
||||||
cd db/migrations;\
|
cd db/migrations;\
|
||||||
$(GOOSE) postgres "$(CONNECT_STRING)" up
|
$(GOOSE) postgres "$(CONNECT_STRING)" up
|
||||||
pg_dump -O -s $(CONNECT_STRING) > db/schema.sql
|
pg_dump -O -s $(CONNECT_STRING) > db/schema.sql
|
||||||
|
|
||||||
.PHONY: checkmigname
|
## Create a new migration file
|
||||||
checkmigname:
|
|
||||||
test -n "$(NAME)" # $$NAME
|
|
||||||
|
|
||||||
.PHONY: new_migration
|
.PHONY: new_migration
|
||||||
new_migration: $(GOOSE) checkmigname
|
new_migration: $(GOOSE) checkmigname
|
||||||
cd db/migrations;\
|
cd db/migrations;\
|
||||||
$(GOOSE) create $(NAME) sql
|
$(GOOSE) create $(NAME) sql
|
||||||
|
|
||||||
|
## Check which migrations are applied at the moment
|
||||||
.PHONY: migration_status
|
.PHONY: migration_status
|
||||||
migration_status: $(GOOSE) checkdbvars
|
migration_status: $(GOOSE) checkdbvars
|
||||||
cd db/migrations;\
|
cd db/migrations;\
|
||||||
$(GOOSE) postgres "$(CONNECT_STRING)" status
|
$(GOOSE) postgres "$(CONNECT_STRING)" status
|
||||||
|
|
||||||
|
# Convert timestamped migrations to versioned (to be run in CI);
|
||||||
|
# merge timestamped files to prevent conflict
|
||||||
|
.PHONY: version_migrations
|
||||||
|
version_migrations:
|
||||||
|
cd db/migrations;\
|
||||||
|
$(GOOSE) fix
|
||||||
|
|
||||||
|
# Import a psql schema to the database
|
||||||
.PHONY: import
|
.PHONY: import
|
||||||
import:
|
import:
|
||||||
test -n "$(NAME)" # $$NAME
|
test -n "$(NAME)" # $$NAME
|
||||||
psql $(NAME) < db/schema.sql
|
psql $(NAME) < db/schema.sql
|
||||||
|
|
||||||
#Rinkeby docker environment
|
|
||||||
|
# Docker actions
|
||||||
|
## Rinkeby docker environment
|
||||||
RINKEBY_COMPOSE_FILE=dockerfiles/rinkeby/docker-compose.yml
|
RINKEBY_COMPOSE_FILE=dockerfiles/rinkeby/docker-compose.yml
|
||||||
|
|
||||||
.PHONY: rinkeby_env_up
|
.PHONY: rinkeby_env_up
|
||||||
|
Loading…
Reference in New Issue
Block a user