-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmakefile
122 lines (102 loc) · 4.62 KB
/
makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
version=0.1.0
export GOPROXY=direct
.PHONY: all dependencies clean test lint cover testall testvall
all:
@echo "make <cmd>"
@echo ""
@echo "commands:"
@echo " dependencies - install dependencies"
@echo " build - build the source code"
@echo " serve-docs - serve the documentation"
@echo " clean - clean the source directory"
@echo " lint - lint the source code"
@echo " fmt - format the source code"
@echo " test - test the source code"
dependencies:
@go install golang.org/x/tools/cmd/cover@latest
@go install golang.org/x/lint/golint@latest
@go install golang.org/x/tools/cmd/godoc@latest
@go install github.com/unchartedsoftware/witch@latest
@go install github.com/ory/go-acc@latest
@go install github.com/google/pprof@latest
@go install google.golang.org/protobuf/cmd/[email protected]
@go install google.golang.org/grpc/cmd/[email protected]
@go get -d -v ./...
fmt:
@go fmt ./...
clean:
@echo "Cleaning..."
@rm -rf ./bin
@rm -rf internal/test/integration/sif-worker-808*
lint:
@echo "Running go vet"
@go vet ./...
@echo "Running golint"
@go list ./... | grep -v /vendor/ | xargs -L1 golint --set_exit_status
@echo "Ensuring that internal code isn't used in the implementation of datasources"
@! grep -ir internal datasource | grep -v util.go
@echo "Ensuring that internal code isn't used in the implementation of integration tests"
@! grep -ir internal internal/test/integration | grep -v util.go
testenv:
@echo "Downloading NYC Taxi test files..."
@mkdir -p testenv
@cd testenv && curl -s http://assets.oculusinfo.com/salt/sample-data/taxi_one_day.csv | tail -n +2 | split --additional-suffix .csv -l 60000
@echo "Finished downloading NYC Taxi test files."
@echo "Downloading NYC Taxi test files..."
@mkdir -p testenv/odbc
@cd testenv/odbc && curl -s http://assets.oculusinfo.com/salt/sample-data/taxi_one_day.csv | tail -n +2 > taxi_one_day.csv
@echo "Creating SQLite3 database and table..."
@cd testenv/odbc && sqlite3 taxi_one_day.sqlite3 'DROP TABLE IF EXISTS "taxi_one_day";'
@cd testenv/odbc && sqlite3 taxi_one_day.sqlite3 'CREATE TABLE IF NOT EXISTS "taxi_one_day"("hack" TEXT, "license" TEXT, "code" TEXT, "flag" TEXT, "type" TEXT, "pickup_time" TEXT, "dropoff_time" TEXT, "passengers" TEXT, "duration" FLOAT, "distance" FLOAT, "pickup_lon" FLOAT, "pickup_lat" FLOAT, "dropoff_lon" FLOAT, "dropoff_lat" FLOAT);'
@echo "Loading CSV into table..."
@cd testenv/odbc && sqlite3 taxi_one_day.sqlite3 -cmd ".mode csv" -cmd ".import taxi_one_day.csv taxi_one_day" "SELECT COUNT(*) FROM taxi_one_day"
@cd testenv/odbc && rm taxi_one_day.csv
@echo "Finished creating NYC Taxi SQLite3 Database."
@echo "Downloading EDSM test files..."
@mkdir -p testenv
@cd testenv && curl -s https://www.edsm.net/dump/systemsWithCoordinates7days.json.gz | gunzip | tail -n +2 | head -n -1 | sed 's/,$$//' | sed 's/^....//' | split --additional-suffix .jsonl -l 50000
@echo "Finished downloading EDSM test files."
# Can use this for a much larger dataset
edsm_big_data:
@echo "Downloading EDSM test files..."
@mkdir -p testenv
@cd testenv && curl -s https://www.edsm.net/dump/systemsWithCoordinates.json | tail -n +2 | head -n -1 | sed 's/,$$//' | sed 's/^....//' | split --additional-suffix .jsonl -l 50000
@echo "Finished downloading EDSM test files."
test: build testenv
@echo "Running tests..."
@go test -short -p 1 -count=1 ./...
testall: build testenv
@echo "Running tests..."
@go test -timeout 30m -p 1 -count=1 ./...
testv: build testenv
@echo "Running tests..."
@go test -short -p 1 -v ./...
testvall: build testenv
@echo "Running tests..."
@go test -timeout 30m -v -p 1 -count=1 ./...
# make profile test=TestMyFunction package=./path/to/package
profile: build testenv
@echo "Profiling test $(test)..."
@go test -cpuprofile=cpu.out -run="$(test)" $(package)
@pprof -http=localhost:8080 -no_browser cpu.out
cover: build testenv
@echo "Running tests with coverage..."
@go-acc --ignore internal/rpc -o cover.out ./... -- -p 1 -count=1
@go tool cover -html=cover.out -o cover.html
edsm: build testenv
@echo "Running tests..."
@go test -timeout 30m -p 1 -count=1 -run TestEDSMHeatmap ./...
generate:
@echo "Generating protobuf code..."
@go generate ./...
@echo "Finished generating protobuf code."
build: clean generate lint
@echo "Building sif..."
@go mod tidy
@go build ./...
@echo "Finished building sif."
serve-docs:
@echo "Serving docs on http://localhost:6060"
@witch --cmd="godoc -http=localhost:6060" --watch="**/*.go" --ignore="vendor,.git,**/*.pb.go" --no-spinner
watch:
@witch --cmd="make build" --watch="**/*.go" --ignore="vendor,.git,**/*.pb.go" --no-spinner