2022-10-30 02:13:51 +02:00
|
|
|
.PHONY: all setup ytrssil-api build gen-mocks lint yamllint test migrate image-build image-push
|
2022-10-27 04:04:49 +02:00
|
|
|
|
|
|
|
DB_URI ?= postgres://ytrssil:ytrssil@localhost:5431/ytrssil?sslmode=disable
|
|
|
|
|
|
|
|
all: lint test build
|
|
|
|
|
|
|
|
setup: bin/golangci-lint
|
|
|
|
go mod download
|
|
|
|
|
|
|
|
ytrssil-api:
|
|
|
|
go build -o dist/ytrssil-api cmd/main.go
|
|
|
|
|
|
|
|
build: ytrssil-api
|
|
|
|
|
|
|
|
bin/moq:
|
|
|
|
GOBIN=$(PWD)/bin go install github.com/matryer/moq@v0.2.7
|
|
|
|
|
|
|
|
gen-mocks: bin/moq
|
|
|
|
./bin/moq -pkg db_mock -out ./mocks/db/db.go ./db DB
|
2022-10-31 02:39:52 +01:00
|
|
|
./bin/moq -pkg parser_mock -out ./mocks/feedparser/feedparser.go ./feedparser Parser
|
2022-10-27 04:04:49 +02:00
|
|
|
go fmt ./...
|
|
|
|
|
|
|
|
bin/golangci-lint:
|
|
|
|
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.48.0
|
|
|
|
|
|
|
|
lint: bin/golangci-lint
|
|
|
|
go fmt ./...
|
|
|
|
go vet ./...
|
|
|
|
bin/golangci-lint -c .golangci.yml run ./...
|
|
|
|
go mod tidy
|
|
|
|
|
|
|
|
test:
|
|
|
|
go mod tidy
|
|
|
|
go test -timeout=10s -race -benchmem ./...
|
|
|
|
|
|
|
|
migrate:
|
|
|
|
migrate -database "$(DB_URI)" -path migrations up
|
|
|
|
|
|
|
|
image-build:
|
|
|
|
@echo "# Building docker image..."
|
2022-10-30 02:13:51 +02:00
|
|
|
docker build -t theedgeofrage/ytrssil:api --target api .
|
|
|
|
docker build -t theedgeofrage/ytrssil:migrations --target migrations .
|
|
|
|
|
|
|
|
image-push: image-build
|
|
|
|
@echo "# Pushing docker image..."
|
|
|
|
docker push theedgeofrage/ytrssil:api
|
|
|
|
docker push theedgeofrage/ytrssil:migrations
|