You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			55 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			Makefile
		
	
			
		
		
	
	
			55 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			Makefile
		
	
| SQL_DATABASE?=./ratchet.db
 | |
| 
 | |
| # TODO maybe only use -race in an ARG for CI
 | |
| FLAGS := -race -v 
 | |
| 
 | |
| # `make <target> ARGS=no-cache` will avoid using cached results in go test.
 | |
| ifeq ($(ARGS), no-cache)
 | |
| 	FLAGS += -count=1
 | |
| endif
 | |
| 
 | |
| # make test ARGS=no-cache
 | |
| test:
 | |
| 	go test $(FLAGS) ./...
 | |
| PHONEY: test
 | |
| 
 | |
| test-short:
 | |
| 	go test -short $(FLAGS) ./...
 | |
| PHONEY: test-short
 | |
| 
 | |
| # make test-int ARGS=no-cache
 | |
| test-int:
 | |
| 	go test $(FLAGS) ./cmd/...
 | |
| .PHONY: test-int
 | |
| 
 | |
| serve:
 | |
| 	go run ./cmd/ratchetd/main.go
 | |
| PHONEY: serve
 | |
| 
 | |
| 
 | |
| # SQLite Commands
 | |
| sql-cli:
 | |
| 	sqlite3 $(SQL_DATABASE) -cmd ".headers on" -cmd ".mode box" -cmd ".tables"
 | |
| 
 | |
| init-db: run-migrate
 | |
| 	sqlite3 $(SQL_DATABASE) "PRAGMA journal_mode = WAL; PRAGMA synchronous = NORMAL;"
 | |
| 
 | |
| seed-db:
 | |
| 	sqlite3 $(SQL_DATABASE) "INSERT INTO snippets (title, content, expires_at) VALUES ('placeholder', 'placeholder content', datetime('now', '+6 months'));"
 | |
| 
 | |
| run-migrate:
 | |
| 	migrate -database sqlite3://$(SQL_DATABASE) -path ./migrations up
 | |
| 
 | |
| # Checks system dependencies needed to run the local dev environment
 | |
| check-system-deps:
 | |
| 	@echo "Checking system dependencies..."
 | |
| 	@command -v air > /dev/null || (echo "Missing air command. go install github.com/air-verse/air@latest"; exit 1)
 | |
| 	@command -v sqlite3 > /dev/null || (echo "Missing sqlite3 command. brew install sqlite"; exit 1)
 | |
| 	@command -v migrate > /dev/null || (echo "Missing migrate command. go install -tags 'sqlite3' github.com/golang-migrate/migrate/v4/cmd/migrate@latest"; exit 1)
 | |
| 	@echo "System dependencies fulfilled 👍"
 | |
| 
 | |
| # Certs
 | |
| 
 | |
| local-certs:
 | |
| 	cd ./tls && go run /usr/local/go/src/crypto/tls/generate_cert.go --rsa-bits=2048 --host=localhost
 |