Skip to content

Commit

Permalink
use go tool directive (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
vvakame authored Feb 26, 2025
1 parent c8fd634 commit 891d1a2
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 37 deletions.
1 change: 0 additions & 1 deletion .github/workflows/build_and_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ jobs:
with:
go-version-file: ./go.mod
- run: go version
- run: make install
- run: make lint
- run: make setup-emulator
- run: |
Expand Down
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ run:
tests: true
skip-dirs:
- model
- tools
skip-files:
- assets.go
linters:
Expand Down
34 changes: 9 additions & 25 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,11 @@ SPOOL_SPANNER_DATABASE_ID ?= spool-test-database
SPANNER_EMULATOR_HOST ?= localhost:9010
SPANNER_EMULATOR_HOST_REST ?= localhost:9020

BIN_DIR := .bin
YO_BIN := ${BIN_DIR}/yo
LINT_BIN := ${BIN_DIR}/golangci-lint
WRENCH_BIN := ${BIN_DIR}/wrench

${YO_BIN}:
@mkdir -p ${BIN_DIR}
@go build -o ${YO_BIN} go.mercari.io/yo

${LINT_BIN}:
@mkdir -p ${BIN_DIR}
@go build -o ${LINT_BIN} github.com/golangci/golangci-lint/cmd/golangci-lint

${WRENCH_BIN}:
@mkdir -p ${BIN_DIR}
@go build -o ${WRENCH_BIN} github.com/cloudspannerecosystem/wrench
YO_BIN := go tool yo
LINT_BIN := go tool golangci-lint
WRENCH_BIN := go tool wrench


.PHONY: install
install: ${WRENCH_BIN} ${YO_BIN} ${LINT_BIN}
BIN_DIR := .bin

.PHONY: clean
clean:
Expand All @@ -34,32 +19,31 @@ clean:
gen: gen_model

.PHONY: gen_model
gen_model: ${YO_BIN}
gen_model:
rm -f ./model/*.yo.go
${YO_BIN} $(SPANNER_PROJECT_ID) $(SPANNER_INSTANCE_ID) $(SPOOL_SPANNER_DATABASE_ID) --out ./model/

.PHONY: lint
lint: ${LINT_BIN}
lint:
${LINT_BIN} run

.PHONY: test
test:
go test -v -race -p=1 `go list ./... | grep -v tools`
go test -v -race -p=1 `go list ./...`

.PHONY: setup-emulator
setup-emulator:
curl -s "${SPANNER_EMULATOR_HOST_REST}/v1/projects/${SPANNER_PROJECT_ID}/instances" --data '{"instanceId": "'${SPANNER_INSTANCE_ID}'"}'

.PHONY: create_db
create_db: ${WRENCH_BIN}
create_db:
${WRENCH_BIN} create --project $(SPANNER_PROJECT_ID) --instance $(SPANNER_INSTANCE_ID) --database $(SPOOL_SPANNER_DATABASE_ID) --directory db/

.PHONY: drop_db
drop_db: ${WRENCH_BIN}
drop_db:
${WRENCH_BIN} drop --project $(SPANNER_PROJECT_ID) --instance $(SPANNER_INSTANCE_ID) --database $(SPOOL_SPANNER_DATABASE_ID)

.PHONY: reset_db
reset_db:
make drop_db
make create_db

14 changes: 11 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,20 @@ module github.com/cloudspannerecosystem/spool

go 1.23.0

toolchain go1.24.0

tool (
github.com/cloudspannerecosystem/wrench
github.com/golangci/golangci-lint/cmd/golangci-lint
go.mercari.io/yo
)

require (
cloud.google.com/go/spanner v1.28.0
github.com/alecthomas/kingpin v2.2.6+incompatible
github.com/cloudspannerecosystem/wrench v1.0.4
github.com/gcpug/handy-spanner v0.6.5
github.com/golangci/golangci-lint v1.43.0
github.com/kelseyhightower/envconfig v1.4.0
github.com/pkg/errors v0.9.1
go.mercari.io/yo v0.5.0
google.golang.org/api v0.63.0
google.golang.org/genproto v0.0.0-20211223182754-3ac035c7e7cb
google.golang.org/grpc v1.43.0
Expand Down Expand Up @@ -42,6 +47,7 @@ require (
github.com/cespare/xxhash/v2 v2.1.1 // indirect
github.com/charithe/durationcheck v0.0.9 // indirect
github.com/chavacava/garif v0.0.0-20210405164556-e8a0a408d6af // indirect
github.com/cloudspannerecosystem/wrench v1.0.4 // indirect
github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4 // indirect
github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1 // indirect
github.com/daixiang0/gci v0.2.9 // indirect
Expand Down Expand Up @@ -73,6 +79,7 @@ require (
github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a // indirect
github.com/golangci/go-misc v0.0.0-20180628070357-927a3d87b613 // indirect
github.com/golangci/gofmt v0.0.0-20190930125516-244bba706f1a // indirect
github.com/golangci/golangci-lint v1.43.0 // indirect
github.com/golangci/lint-1 v0.0.0-20191013205115-297bf364a8e0 // indirect
github.com/golangci/maligned v0.0.0-20180506175553-b1d89398deca // indirect
github.com/golangci/misspell v0.3.5 // indirect
Expand Down Expand Up @@ -163,6 +170,7 @@ require (
github.com/ultraware/whitespace v0.0.4 // indirect
github.com/uudashr/gocognit v1.0.5 // indirect
github.com/yeya24/promlinter v0.1.0 // indirect
go.mercari.io/yo v0.5.0 // indirect
go.opencensus.io v0.23.0 // indirect
golang.org/x/mod v0.5.0 // indirect
golang.org/x/net v0.0.0-20211020060615-d418f374d309 // indirect
Expand Down
7 changes: 0 additions & 7 deletions tools/tools.go

This file was deleted.

0 comments on commit 891d1a2

Please sign in to comment.