2020-08-19 11:40:31 -08:00
|
|
|
GO_VERSION=$(shell grep "^go " go.mod | cut -f 2 -d ' ')
|
2020-03-06 07:50:39 -09:00
|
|
|
NODE_VERSION=$(shell cat .nvmrc)
|
2020-01-13 18:53:23 -09:00
|
|
|
|
2021-10-23 17:27:19 -08:00
|
|
|
ifneq ("$(wildcard .git/HEAD)","")
|
2020-01-26 08:36:24 -09:00
|
|
|
GIT_SHA=$(shell git rev-parse --short HEAD)
|
2020-04-20 05:47:44 -08:00
|
|
|
GIT_TAG=$(shell git describe --tags `git rev-list --tags --max-count=1`)
|
2021-09-06 17:26:04 -08:00
|
|
|
else
|
|
|
|
|
GIT_SHA=source_archive
|
|
|
|
|
GIT_TAG=$(patsubst navidrome-%,v%,$(notdir $(PWD)))
|
2021-07-15 05:49:34 -08:00
|
|
|
endif
|
2020-01-25 07:06:04 -09:00
|
|
|
|
2024-05-09 17:58:10 -08:00
|
|
|
CI_RELEASER_VERSION=1.22.3-1 ## https://github.com/navidrome/ci-goreleaser
|
2020-03-20 08:21:41 -08:00
|
|
|
|
2024-08-07 11:36:29 -08:00
|
|
|
UI_SRC_FILES := $(shell find ui -type f -not -path "ui/build/*" -not -path "ui/node_modules/*")
|
|
|
|
|
|
2021-08-21 09:45:34 -08:00
|
|
|
setup: check_env download-deps setup-git ##@1_Run_First Install dependencies and prepare development environment
|
2021-05-01 07:14:24 -08:00
|
|
|
@echo Downloading Node dependencies...
|
|
|
|
|
@(cd ./ui && npm ci)
|
|
|
|
|
.PHONY: setup
|
|
|
|
|
|
|
|
|
|
dev: check_env ##@Development Start Navidrome in development mode, with hot-reload for both frontend and backend
|
2020-04-28 19:24:57 -08:00
|
|
|
npx foreman -j Procfile.dev -p 4533 start
|
2020-03-20 08:21:41 -08:00
|
|
|
.PHONY: dev
|
2020-01-19 18:48:36 -09:00
|
|
|
|
2024-08-07 11:36:29 -08:00
|
|
|
server: check_go_env buildjs ##@Development Start the backend in development mode
|
2023-03-30 11:33:47 -08:00
|
|
|
@go run github.com/cespare/reflex@latest -d none -c reflex.conf
|
2020-03-20 08:21:41 -08:00
|
|
|
.PHONY: server
|
2020-01-20 09:43:51 -09:00
|
|
|
|
2021-05-01 07:14:24 -08:00
|
|
|
watch: ##@Development Start Go tests in watch mode (re-run when code changes)
|
2023-04-04 05:57:00 -08:00
|
|
|
go run github.com/onsi/ginkgo/v2/ginkgo@latest watch -notify ./...
|
2020-03-20 08:21:41 -08:00
|
|
|
.PHONY: watch
|
2020-01-15 19:40:22 -09:00
|
|
|
|
2021-05-01 07:14:24 -08:00
|
|
|
test: ##@Development Run Go tests
|
2023-03-22 16:12:12 -08:00
|
|
|
go test -race -shuffle=on ./...
|
2020-03-20 08:21:41 -08:00
|
|
|
.PHONY: test
|
2020-01-13 18:53:23 -09:00
|
|
|
|
2021-05-01 07:14:24 -08:00
|
|
|
testall: test ##@Development Run Go and JS tests
|
2020-01-19 15:34:54 -09:00
|
|
|
@(cd ./ui && npm test -- --watchAll=false)
|
2020-03-20 08:21:41 -08:00
|
|
|
.PHONY: testall
|
2020-01-19 15:34:54 -09:00
|
|
|
|
2021-05-01 07:14:24 -08:00
|
|
|
lint: ##@Development Lint Go code
|
2023-03-30 11:33:47 -08:00
|
|
|
go run github.com/golangci/golangci-lint/cmd/golangci-lint@latest run -v --timeout 5m
|
2020-10-24 18:43:59 -08:00
|
|
|
.PHONY: lint
|
|
|
|
|
|
2021-05-01 07:14:24 -08:00
|
|
|
lintall: lint ##@Development Lint Go and JS code
|
2023-04-06 07:45:32 -08:00
|
|
|
@(cd ./ui && npm run check-formatting) || (echo "\n\nPlease run 'npm run prettier' to fix formatting issues." && exit 1)
|
|
|
|
|
@(cd ./ui && npm run lint)
|
2021-03-24 08:21:20 -08:00
|
|
|
.PHONY: lintall
|
|
|
|
|
|
2023-06-19 07:15:51 -08:00
|
|
|
format: ##@Development Format code
|
|
|
|
|
@(cd ./ui && npm run prettier)
|
2023-11-27 09:53:08 -09:00
|
|
|
@go run golang.org/x/tools/cmd/goimports@latest -w `find . -name '*.go' | grep -v _gen.go$$`
|
2023-06-19 07:15:51 -08:00
|
|
|
@go mod tidy
|
|
|
|
|
.PHONY: format
|
|
|
|
|
|
2021-05-20 09:42:29 -08:00
|
|
|
wire: check_go_env ##@Development Update Dependency Injection
|
2023-03-30 11:33:47 -08:00
|
|
|
go run github.com/google/wire/cmd/wire@latest ./...
|
2021-05-20 09:42:29 -08:00
|
|
|
.PHONY: wire
|
|
|
|
|
|
|
|
|
|
snapshots: ##@Development Update (GoLang) Snapshot tests
|
2023-04-04 05:57:00 -08:00
|
|
|
UPDATE_SNAPSHOTS=true go run github.com/onsi/ginkgo/v2/ginkgo@latest ./server/subsonic/...
|
2021-05-20 09:42:29 -08:00
|
|
|
.PHONY: snapshots
|
2020-05-09 17:00:38 -08:00
|
|
|
|
2023-04-04 06:30:28 -08:00
|
|
|
migration-sql: ##@Development Create an empty SQL migration file
|
|
|
|
|
@if [ -z "${name}" ]; then echo "Usage: make migration-sql name=name_of_migration_file"; exit 1; fi
|
2024-05-08 15:54:48 -08:00
|
|
|
go run github.com/pressly/goose/v3/cmd/goose@latest -dir db/migrations create ${name} sql
|
2023-04-04 06:30:28 -08:00
|
|
|
.PHONY: migration
|
|
|
|
|
|
|
|
|
|
migration-go: ##@Development Create an empty Go migration file
|
|
|
|
|
@if [ -z "${name}" ]; then echo "Usage: make migration-go name=name_of_migration_file"; exit 1; fi
|
2024-05-08 15:54:48 -08:00
|
|
|
go run github.com/pressly/goose/v3/cmd/goose@latest -dir db/migrations create ${name}
|
2020-07-31 05:55:44 -08:00
|
|
|
.PHONY: migration
|
2020-06-08 13:29:09 -08:00
|
|
|
|
2021-05-01 07:14:24 -08:00
|
|
|
setup-dev: setup
|
2021-05-01 04:49:34 -08:00
|
|
|
.PHONY: setup-dev
|
2020-04-26 12:10:40 -08:00
|
|
|
|
2021-05-01 07:14:24 -08:00
|
|
|
setup-git: ##@Development Setup Git hooks (pre-commit and pre-push)
|
2020-10-03 07:01:16 -08:00
|
|
|
@echo Setting up git hooks
|
2020-07-16 13:52:59 -08:00
|
|
|
@mkdir -p .git/hooks
|
2020-10-03 07:01:16 -08:00
|
|
|
@(cd .git/hooks && ln -sf ../../git/* .)
|
2020-07-16 13:52:59 -08:00
|
|
|
.PHONY: setup-git
|
|
|
|
|
|
2021-05-01 07:14:24 -08:00
|
|
|
buildall: buildjs build ##@Build Build the project, both frontend and backend
|
|
|
|
|
.PHONY: buildall
|
|
|
|
|
|
2024-08-07 11:36:29 -08:00
|
|
|
build: check_go_env buildjs ##@Build Build only backend
|
2021-05-01 07:14:24 -08:00
|
|
|
go build -ldflags="-X github.com/navidrome/navidrome/consts.gitSha=$(GIT_SHA) -X github.com/navidrome/navidrome/consts.gitTag=$(GIT_TAG)-SNAPSHOT" -tags=netgo
|
|
|
|
|
.PHONY: build
|
|
|
|
|
|
2024-08-07 11:36:29 -08:00
|
|
|
debug-build: check_go_env buildjs ##@Build Build only backend (with remote debug on)
|
Jukebox mode (#2289)
* Adding cache directory to ignore-list
* Adding jukebox-related config options
* Adding DevEnableJukebox config option pls. dummy server
* Adding types and routers
* Now without panic
* First draft on parsing the action
* Some cleanups
* Adding playback server
* Verify audio device configuration
* Adding debug-build target to have full symbol support
* Adding beep sound library pls some example code. Not working yet
* Play a fixed mp3 on any interface access for testing purposes
* Put action code into separate file, adding stringer, more debug output, prepare structs, validation
* Put action parameter parser code where it belongs
* Have a single Action transporting all information
* User fmt.Errorf for error-generation
* Adding wide playback interface
* Use action map for parsing, stringer instead switch stmt.
* Use but only one switch case and direct dispatch, refactoring
* Add error handling and pushing to client
* send decent errormessage, no internal server error
* Adding playback devices slice and load it from config
* Combine config-verification and structure init
* Return user-specific device
* Separate playback server from device
* Use dataStore to retrieve mediafile by id
* WIP: Playlist and start/stop handling. Doing start/stop the hard way as of now
* WIP: set, start and stop work on one single song. More to come
* Dont need to wait for the end
* Merge jukebox_action.go into jukebox.go
* Remove getParameterAsInt64(). Use existing requiredParamInt() instead
* Dont need to call newFailure() explicitly
* Remove int64, use int instead.
* Add and set action now accept multiple ids
* Kickout copy of childFromMediaFile(). It is not needed here.
* Refactoring devices and playbackServer
* Turn (internal) playback.DeviceStatus into subsonic JukeboxStatus when rendering output. Indexes int64 -> int
* Now we have a position and playing status
* Switching gain to float32, xs:float is defined as 32 bit. Fixing nasty copy/pointer bug
* Now with volume control
* Start working the queue
* Remove user from device interface
* Rename function GetDevice -> GetDeviceForUser to make intention clearer
* Have a nice stringer for the queue
* User Prepared boolean for now to allow pause/unpause
* Skipping works, but without offsets
* Make ChildFromMediaFile public to be used in jukebox get() implementation
* Return position in seconds and implement offset-skip in seconds
* Default offset to 0
* Adding a simple setGain implementation
* Prepare for transcoding AAC
* WIP: transcode to WAV to use beeps wav decoder. Not done yet.
* WIP: out of sheer desparation: convert to MP3 (which works) rather than WAV to troubleshoot issue.
* Use FLAC as intermediate format to play Apple AAC
* A bit of cleanup
* Catching the end-of-stream event for further reactions
* Have a trackSwitching goroutine waiting on channel when track ends
* Move decoder code into own file. Restructure code a bit
* Now with going on to play the next song in the playlist
* Adding shuffle feature
* Implementing remove action
* Cleanup code
* Remove templates for ffmpeg mp3 generation. Not needed anymore.
* Adding some documentation
* Check whether offset into track is in range. Fixing potential remove track bug. Documentation
* Make golangci-lint happy: handling return values
* Adding test suite and example dummy for playback package
* Adding some basic queue tests
* Only use Jukebox.Enabled config option
* Adding stream closing handling
* Pass context.Context to all PlaybackDevice methods
* Remove unneeded function
* Correct spelling
* Reduce visibility of ChildFromMediaFile
* Decomplicate action-parsing
* Adding simple tempfile-based AAC->FLAC transcoding. No parallel reading and writing yet.
* Try to optimize pipe-writing, tempfile-handling and reading. Not done yet.
* Do a synchronous copy of the tempfile. Racecondition detected
* More debugging statements and fixing the play/pause bug. More work needed
* Start the trackSwitcher() with each device once. Return JSON position even if its 0. More debug-output
* Moving all track-handling code into own module
* Fix typo. Do not pass ctx around when not applicable
* WIP: More refactoring, debugging output
* Fix nil pointer
* Repairing MP3 playback by pinning indirect dependencies: hajimehoshi/go-mp3 and hajimehoshi/oto
* Do not forget to cleanup after a skip action
* Make resync with master easy
* Adding missing mocks
* Adding missing error-handling found by linter
* Updating github.com/hajimehoshi/oto
* Removing duplicate function
* Move BEEP-related code into own package
* Juggle beep-related code around as preparation for interface access
* More refactoring for interface separation
* Gather CloseDevice() behind Track interface.
* Adding skeleton, draft audio-interface using mpv.io
* Adding majority of interface commands using messages to mpv socket.
* Adding end-of-stream handling
* MPV: start/stop are working
* postition is given in float in mpv
* Unify Close() and CloseDevice(). Using temp filename for controlling socket
* Wait until control-socket shows up. Cleanup socket in Close()
* Use canceable command. Rename to Executor
* Skipping tracks works now
* Now with actually setting the position
* Fix regain
* Add missing error-handling found by linter
* Adding retry mode on time-pos property getter
* Remove unneeded code on queue
* Putting build-tag beep onto beep files
* Remove deprecated call to rand.Seed()
"As of Go 1.20 there is no reason to call Seed with a random value. Programs that call Seed with a known value to get a specific sequence of results should use New(NewSource(seed)) to obtain a local random generator."
* Using int32 to conform to Subsonic API spec
* Fix merge error
* Minor style changes
* Get username from context
---------
Co-authored-by: Deluan <deluan@navidrome.org>
2023-09-10 07:25:22 -08:00
|
|
|
go build -gcflags="all=-N -l" -ldflags="-X github.com/navidrome/navidrome/consts.gitSha=$(GIT_SHA) -X github.com/navidrome/navidrome/consts.gitTag=$(GIT_TAG)-SNAPSHOT" -tags=netgo
|
|
|
|
|
.PHONY: debug-build
|
|
|
|
|
|
2024-08-07 11:36:29 -08:00
|
|
|
buildjs: check_node_env ui/build/index.html ##@Build Build only frontend
|
2021-05-01 07:14:24 -08:00
|
|
|
.PHONY: buildjs
|
|
|
|
|
|
2024-08-07 11:36:29 -08:00
|
|
|
ui/build/index.html: $(UI_SRC_FILES)
|
|
|
|
|
@(cd ./ui && npm run build)
|
|
|
|
|
|
|
|
|
|
all: buildjs ##@Cross_Compilation Build binaries for all supported platforms.
|
2024-02-17 07:16:54 -09:00
|
|
|
@echo "Building binaries for all platforms using builder ${CI_RELEASER_VERSION}"
|
2021-05-01 07:14:24 -08:00
|
|
|
docker run -t -v $(PWD):/workspace -w /workspace deluan/ci-goreleaser:$(CI_RELEASER_VERSION) \
|
2023-11-24 14:08:34 -09:00
|
|
|
goreleaser release --clean --skip=publish --snapshot
|
2021-05-01 07:14:24 -08:00
|
|
|
.PHONY: all
|
|
|
|
|
|
2024-08-07 11:36:29 -08:00
|
|
|
single: buildjs ##@Cross_Compilation Build binaries for a single supported platforms.
|
2021-05-04 13:02:17 -08:00
|
|
|
@if [ -z "${GOOS}" -o -z "${GOARCH}" ]; then \
|
|
|
|
|
echo "Usage: GOOS=<os> GOARCH=<arch> make single"; \
|
2021-05-01 07:14:24 -08:00
|
|
|
echo "Options:"; \
|
|
|
|
|
grep -- "- id: navidrome_" .goreleaser.yml | sed 's/- id: navidrome_//g'; \
|
|
|
|
|
exit 1; \
|
|
|
|
|
fi
|
2024-02-17 07:16:54 -09:00
|
|
|
@echo "Building binaries for ${GOOS}/${GOARCH} using builder ${CI_RELEASER_VERSION}"
|
2021-05-04 13:02:17 -08:00
|
|
|
docker run -t -v $(PWD):/workspace -e GOOS -e GOARCH -w /workspace deluan/ci-goreleaser:$(CI_RELEASER_VERSION) \
|
2024-02-17 07:16:54 -09:00
|
|
|
goreleaser build --clean --snapshot -p 2 --single-target --id navidrome_${GOOS}_${GOARCH}
|
2021-05-01 07:14:24 -08:00
|
|
|
.PHONY: single
|
|
|
|
|
|
2024-04-13 09:29:45 -08:00
|
|
|
docker: buildjs ##@Build Build Docker linux/amd64 image (tagged as `deluan/navidrome:develop`)
|
|
|
|
|
GOOS=linux GOARCH=amd64 make single
|
|
|
|
|
@echo "Building Docker image"
|
|
|
|
|
docker build . --platform linux/amd64 -t deluan/navidrome:develop -f .github/workflows/pipeline.dockerfile
|
|
|
|
|
.PHONY: docker
|
|
|
|
|
|
2022-09-30 19:10:33 -08:00
|
|
|
get-music: ##@Development Download some free music from Navidrome's demo instance
|
|
|
|
|
mkdir -p music
|
|
|
|
|
( cd music; \
|
|
|
|
|
curl "https://demo.navidrome.org/rest/download?u=demo&p=demo&f=json&v=1.8.0&c=dev_download&id=ec2093ec4801402f1e17cc462195cdbb" > brock.zip; \
|
2023-06-02 13:14:11 -08:00
|
|
|
curl "https://demo.navidrome.org/rest/download?u=demo&p=demo&f=json&v=1.8.0&c=dev_download&id=b376eeb4652d2498aa2b25ba0696725e" > back_on_earth.zip; \
|
|
|
|
|
curl "https://demo.navidrome.org/rest/download?u=demo&p=demo&f=json&v=1.8.0&c=dev_download&id=e49c609b542fc51899ee8b53aa858cb4" > ugress.zip; \
|
|
|
|
|
curl "https://demo.navidrome.org/rest/download?u=demo&p=demo&f=json&v=1.8.0&c=dev_download&id=350bcab3a4c1d93869e39ce496464f03" > voodoocuts.zip; \
|
2022-09-30 19:10:33 -08:00
|
|
|
for file in *.zip; do unzip -n $${file}; done )
|
|
|
|
|
@echo "Done. Remember to set your MusicFolder to ./music"
|
|
|
|
|
.PHONY: get-music
|
|
|
|
|
|
|
|
|
|
|
2021-05-01 07:14:24 -08:00
|
|
|
##########################################
|
|
|
|
|
#### Miscellaneous
|
|
|
|
|
|
|
|
|
|
release:
|
|
|
|
|
@if [[ ! "${V}" =~ ^[0-9]+\.[0-9]+\.[0-9]+.*$$ ]]; then echo "Usage: make release V=X.X.X"; exit 1; fi
|
|
|
|
|
go mod tidy
|
|
|
|
|
@if [ -n "`git status -s`" ]; then echo "\n\nThere are pending changes. Please commit or stash first"; exit 1; fi
|
|
|
|
|
make pre-push
|
|
|
|
|
git tag v${V}
|
|
|
|
|
git push origin v${V} --no-verify
|
|
|
|
|
.PHONY: release
|
|
|
|
|
|
2021-05-01 04:49:34 -08:00
|
|
|
download-deps:
|
|
|
|
|
@echo Downloading Go dependencies...
|
2022-09-28 16:27:53 -08:00
|
|
|
@go mod download
|
2021-05-01 04:49:34 -08:00
|
|
|
@go mod tidy # To revert any changes made by the `go mod download` command
|
|
|
|
|
.PHONY: download-deps
|
2021-03-10 11:36:57 -09:00
|
|
|
|
2021-05-01 04:49:34 -08:00
|
|
|
check_env: check_go_env check_node_env
|
|
|
|
|
.PHONY: check_env
|
|
|
|
|
|
|
|
|
|
check_go_env:
|
2021-03-10 11:36:57 -09:00
|
|
|
@(hash go) || (echo "\nERROR: GO environment not setup properly!\n"; exit 1)
|
|
|
|
|
@current_go_version=`go version | cut -d ' ' -f 3 | cut -c3-` && \
|
|
|
|
|
echo "$(GO_VERSION) $$current_go_version" | \
|
|
|
|
|
tr ' ' '\n' | sort -V | tail -1 | \
|
|
|
|
|
grep -q "^$${current_go_version}$$" || \
|
|
|
|
|
(echo "\nERROR: Please upgrade your GO version\nThis project requires at least the version $(GO_VERSION)"; exit 1)
|
2021-05-01 04:49:34 -08:00
|
|
|
.PHONY: check_go_env
|
2021-03-10 11:36:57 -09:00
|
|
|
|
2021-05-01 04:49:34 -08:00
|
|
|
check_node_env:
|
2021-03-10 11:36:57 -09:00
|
|
|
@(hash node) || (echo "\nERROR: Node environment not setup properly!\n"; exit 1)
|
|
|
|
|
@current_node_version=`node --version` && \
|
|
|
|
|
echo "$(NODE_VERSION) $$current_node_version" | \
|
|
|
|
|
tr ' ' '\n' | sort -V | tail -1 | \
|
|
|
|
|
grep -q "^$${current_node_version}$$" || \
|
|
|
|
|
(echo "\nERROR: Please check your Node version. Should be at least $(NODE_VERSION)\n"; exit 1)
|
2020-03-20 08:21:41 -08:00
|
|
|
.PHONY: check_node_env
|
2020-01-08 07:13:05 -09:00
|
|
|
|
2021-03-24 08:21:20 -08:00
|
|
|
pre-push: lintall testall
|
2020-09-24 13:23:46 -08:00
|
|
|
.PHONY: pre-push
|
|
|
|
|
|
2021-05-01 07:14:24 -08:00
|
|
|
.DEFAULT_GOAL := help
|
2020-01-30 12:33:27 -09:00
|
|
|
|
2021-05-01 07:14:24 -08:00
|
|
|
HELP_FUN = \
|
|
|
|
|
%help; while(<>){push@{$$help{$$2//'options'}},[$$1,$$3] \
|
|
|
|
|
if/^([\w-_]+)\s*:.*\#\#(?:@(\w+))?\s(.*)$$/}; \
|
|
|
|
|
print"$$_:\n", map" $$_->[0]".(" "x(20-length($$_->[0])))."$$_->[1]\n",\
|
|
|
|
|
@{$$help{$$_}},"\n" for sort keys %help; \
|
2021-04-26 13:21:59 -08:00
|
|
|
|
2021-05-01 07:14:24 -08:00
|
|
|
help: ##@Miscellaneous Show this help
|
|
|
|
|
@echo "Usage: make [target] ...\n"
|
|
|
|
|
@perl -e '$(HELP_FUN)' $(MAKEFILE_LIST)
|