Add a new archiver to download videos using yt-dlp. The new extractor should call the yt-dlp binary to download the video and we should track progress in the output and return code. The default rules should be updated so youtube videos are extracted using this extractor. The extractor default config should get the thumbnail as well (so we don't depend on the thumbnail extractor) and subtitles. Update the dockerfile accordingly so we not only have yt-dlp but it's required dependencies as well. Prefer installing from packages, if possible.
156 lines
4.8 KiB
Makefile
156 lines
4.8 KiB
Makefile
PROJECT_NAME := hako
|
|
|
|
SOURCE_FILES ?=./...
|
|
|
|
TEST_OPTIONS ?= -v -failfast -race -bench=. -benchtime=100000x -cover -coverprofile=coverage.out
|
|
TEST_TIMEOUT ?=1m
|
|
|
|
GOLANGCI_LINT_VERSION ?= v1.64.5
|
|
|
|
CLEAN_OPTIONS ?=-modcache -testcache
|
|
|
|
CGO_ENABLED := 0
|
|
|
|
BUILDS_PATH := ./dist
|
|
FROM_MAKEFILE := y
|
|
|
|
CONTAINERFILE_NAME := Containerfile
|
|
CONTAINER_ALPINE_VERSION := 3.20
|
|
CONTAINER_SOURCE_URL := "https://git.nakama.town/fmartingr/${PROJECT_NAME}"
|
|
CONTAINER_MAINTAINER := "Felipe Martin <me@fmartingr.com>"
|
|
CONTAINER_BIN_NAME := ${PROJECT_NAME}
|
|
|
|
BUILDX_PLATFORMS := linux/amd64,linux/arm64,linux/arm/v7
|
|
|
|
export PROJECT_NAME
|
|
export FROM_MAKEFILE
|
|
|
|
export CGO_ENABLED
|
|
|
|
export SOURCE_FILES
|
|
export TEST_OPTIONS
|
|
export TEST_TIMEOUT
|
|
export BUILDS_PATH
|
|
|
|
export CONTAINERFILE_NAME
|
|
export CONTAINER_ALPINE_VERSION
|
|
export CONTAINER_SOURCE_URL
|
|
export CONTAINER_MAINTAINER
|
|
export CONTAINER_BIN_NAME
|
|
|
|
export BUILDX_PLATFORMS
|
|
|
|
.PHONY: all
|
|
all: help
|
|
|
|
# this is godly
|
|
# https://news.ycombinator.com/item?id=11939200
|
|
.PHONY: help
|
|
help: ### this screen. Keep it first target to be default
|
|
ifeq ($(UNAME), Linux)
|
|
@grep -P '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | \
|
|
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
|
|
else
|
|
@# this is not tested, but prepared in advance for you, Mac drivers
|
|
@awk -F ':.*###' '$$0 ~ FS {printf "%15s%s\n", $$1 ":", $$2}' \
|
|
$(MAKEFILE_LIST) | grep -v '@awk' | sort
|
|
endif
|
|
|
|
.PHONY: clean
|
|
clean: ### clean test cache, build files
|
|
$(info: Make: Clean)
|
|
@rm -rf ${BUILDS_PATH}
|
|
@rm -rf webapp/dist
|
|
@rm -rf webapp/node_modules
|
|
@rm -f webapp/bun.lockb
|
|
@go clean ${CLEAN_OPTIONS}
|
|
@find devdata -mindepth 1 ! -name config.yaml -delete 2>/dev/null || true
|
|
@-docker buildx rm ${PROJECT_NAME}_builder
|
|
|
|
.PHONY: clean-devdata
|
|
clean-devdata: ### Clear devdata database and files (keeps config.yaml)
|
|
$(info: Make: Cleaning devdata)
|
|
@rm -rf devdata/data
|
|
@rm -f devdata/hako.db devdata/hako.db-shm devdata/hako.db-wal
|
|
|
|
.PHONY: build
|
|
build: build-webapp ### builds the project for the setup os/arch combinations
|
|
$(info: Make: Build)
|
|
@goreleaser --clean --snapshot
|
|
|
|
.PHONY: build-webapp
|
|
build-webapp: ### Build the webapp
|
|
$(info: Make: Building webapp)
|
|
@which bun > /dev/null || (echo "Error: Bun is not installed. Install it from https://bun.sh" && exit 1)
|
|
@cd webapp && bun install && bun --bun node_modules/.bin/vite build
|
|
|
|
.PHONY: run-server
|
|
run-server: ### Runs the API server only (without building webapp)
|
|
$(info: Make: Running server)
|
|
CGO_ENABLED=${CGO_ENABLED} go run ./cmd/${PROJECT_NAME}/*.go server --config devdata/config.yaml
|
|
|
|
.PHONY: run-quick
|
|
run-quick: build-webapp run-server ### Builds the webapp and runs the server
|
|
|
|
.PHONY: run-webapp
|
|
run-webapp: ### Runs the webapp in dev mode with hot-reload
|
|
$(info: Make: Running webapp dev server)
|
|
@which bun > /dev/null || (echo "Error: Bun is not installed. Install it from https://bun.sh" && exit 1)
|
|
@cd webapp && bun --bun node_modules/.bin/vite --mode development
|
|
|
|
.PHONY: run
|
|
run: ### Executes the project build locally
|
|
@make build
|
|
${BUILDS_PATH}/${PROJECT_NAME}
|
|
|
|
.PHONY: build-docker
|
|
build-docker: build-webapp ### Build Docker image locally using goreleaser snapshot
|
|
$(info: Make: Building Docker image)
|
|
@which goreleaser > /dev/null || (echo "Error: goreleaser is not installed. Install it from https://goreleaser.com" && exit 1)
|
|
@which docker > /dev/null || (echo "Error: docker is not installed" && exit 1)
|
|
@goreleaser --clean --snapshot --skip=publish
|
|
|
|
.PHONY: format
|
|
format: ### Executes the formatting pipeline on the project
|
|
$(info: Make: Format)
|
|
@go fmt ./...
|
|
@go mod tidy
|
|
|
|
.PHONY: ci-lint
|
|
ci-lint: ### Check the project for errors
|
|
$(info: Make: Lint)
|
|
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCI_LINT_VERSION}
|
|
@golangci-lint run ./...
|
|
|
|
.PHONY: lint
|
|
lint: lint-server lint-webapp ### Check the project for errors
|
|
$(info: Make: Lint)
|
|
|
|
.PHONY: lint-server
|
|
lint-server: ### Check the server for linting errors
|
|
$(info: Make: Lint server)
|
|
@golangci-lint run ./...
|
|
|
|
.PHONY: lint-webapp
|
|
lint-webapp: ### Check the webapp for linting errors
|
|
$(info: Make: Lint webapp)
|
|
@which bun > /dev/null || (echo "Error: Bun is not installed. Install it from https://bun.sh" && exit 1)
|
|
@cd webapp && bun --bun node_modules/.bin/eslint .
|
|
|
|
.PHONY: test
|
|
test: ### Runs the test suite
|
|
$(info: Make: Test)
|
|
CGO_ENABLED=1 go test ${TEST_OPTIONS} -timeout=${TEST_TIMEOUT} ${SOURCE_FILES}
|
|
@echo "Generating HTML coverage report..."
|
|
@go tool cover -html=coverage.out -o coverage.html
|
|
@echo "✅ Coverage report generated: coverage.html"
|
|
|
|
.PHONY: e2e
|
|
e2e: ### Run end-to-end integration tests
|
|
$(info: Make: E2E Tests)
|
|
@./scripts/e2e.sh
|
|
|
|
.PHONY: e2e-install
|
|
e2e-install: ### Install Playwright browsers
|
|
$(info: Make: Installing E2E dependencies)
|
|
@go run github.com/playwright-community/playwright-go/cmd/playwright@latest install --with-deps chromium
|