From 1e073f138f07a632ab1f08309579a70a055bff4e Mon Sep 17 00:00:00 2001 From: "Sean E. Russell" Date: Tue, 15 Oct 2024 11:53:41 -0500 Subject: [PATCH] add: Makefile compiles binary with derived version add: Makefile test task runs tests & linting add: Makefile generates changelog chore: #62, adds a changelog docs: Adds instructions & dependency list for Makefile --- CHANGELOG.md | 19 ++++++++++++ Makefile | 16 ++++++++++ README.md | 21 +++++++++++++ cliff.toml | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++ stmps.go | 6 ++++ 5 files changed, 145 insertions(+) create mode 100644 CHANGELOG.md create mode 100644 Makefile create mode 100644 cliff.toml diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..e65cf63 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,19 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +## [unreleased] + +### ๐Ÿ› Bug Fixes + +- Mpris not implementing the right interface + +### โš™๏ธ Miscellaneous Tasks + +- Rename mpris player (Player -> stmps) + +### Queue + +- Fix scroll behaviour, unexport some methods + + diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..3a722c2 --- /dev/null +++ b/Makefile @@ -0,0 +1,16 @@ +.PHONY: all test + +all: test stmps CHANGELOG.md + +VERSION != git describe --tags HEAD + +stmps: + go build -ldflags="-X main.Version=$(VERSION)" -o stmps . + +CHANGELOG.md: + git cliff -o CHANGELOG.md + +test: + go test ./... + markdownlint README.md + golangci-lint run diff --git a/README.md b/README.md index 6edf6b2..ac47d07 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,27 @@ These screenshots use [Navidrome's demo server](https://demo.navidrome.org/) ([c Compile STMPS with `go build`. Cgo is needed for interfacing with libmpv. +STMPS can be installed without checking out the repository by running: + +``` + go install github.com/spezifisch/stmps@latest +``` + +### Developers & Distribution Packagers + +There's a Makefile with tasks for: + +- Updating the CHANGELOG.md +- Running tests & linting commands +- Compiling an executable with a derived tag for the version + +These tasks depend on the following tools: + +- [git-cliff](https://git-cliff.org/) for updating the CHANGELOG.md +- [markdownlint](https://github.com/igorshubovych/markdownlint-cli) for running the markdown linting test +- [golangci-lint](https://github.com/golangci/golangci-lint) for linting the Go code + + ## Configuration STMPS looks for a configuration file named `stmp.toml` in either `$HOME/.config/stmp` or the directory containing the executable. diff --git a/cliff.toml b/cliff.toml new file mode 100644 index 0000000..3d56204 --- /dev/null +++ b/cliff.toml @@ -0,0 +1,83 @@ +# git-cliff ~ default configuration file +# https://git-cliff.org/docs/configuration +# +# Lines starting with "#" are comments. +# Configuration options are organized into tables and keys. +# See documentation for more information on available options. + +[changelog] +# template for the changelog header +header = """ +# Changelog\n +All notable changes to this project will be documented in this file.\n +""" +# template for the changelog body +# https://keats.github.io/tera/docs/#introduction +body = """ +{% if version %}\ + ## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }} +{% else %}\ + ## [unreleased] +{% endif %}\ +{% for group, commits in commits | group_by(attribute="group") %} + ### {{ group | striptags | trim | upper_first }} + {% for commit in commits %} + - {% if commit.scope %}*({{ commit.scope }})* {% endif %}\ + {% if commit.breaking %}[**breaking**] {% endif %}\ + {{ commit.message | upper_first }}\ + {% endfor %} +{% endfor %}\n +""" +# template for the changelog footer +footer = """ + +""" +# remove the leading and trailing s +trim = true +# postprocessors +postprocessors = [ + # { pattern = '', replace = "https://github.com/orhun/git-cliff" }, # replace repository URL +] +# render body even when there are no releases to process +# render_always = true +# output file path +# output = "test.md" + +[git] +# parse the commits based on https://www.conventionalcommits.org +conventional_commits = true +# filter out the commits that are not conventional +filter_unconventional = true +# process each line of a commit as an individual commit +split_commits = false +# regex for preprocessing the commit messages +commit_preprocessors = [ + # Replace issue numbers + #{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](/issues/${2}))"}, + # Check spelling of the commit with https://github.com/crate-ci/typos + # If the spelling is incorrect, it will be automatically fixed. + #{ pattern = '.*', replace_command = 'typos --write-changes -' }, +] +# regex for parsing and grouping commits +commit_parsers = [ + { message = "^feat", group = "๐Ÿš€ Features" }, + { message = "^fix", group = "๐Ÿ› Bug Fixes" }, + { message = "^doc", group = "๐Ÿ“š Documentation" }, + { message = "^perf", group = "โšก Performance" }, + { message = "^refactor", group = "๐Ÿšœ Refactor" }, + { message = "^style", group = "๐ŸŽจ Styling" }, + { message = "^test", group = "๐Ÿงช Testing" }, + { message = "^chore\\(release\\): prepare for", skip = true }, + { message = "^chore\\(deps.*\\)", skip = true }, + { message = "^chore\\(pr\\)", skip = true }, + { message = "^chore\\(pull\\)", skip = true }, + { message = "^chore|^ci", group = "โš™๏ธ Miscellaneous Tasks" }, + { body = ".*security", group = "๐Ÿ›ก๏ธ Security" }, + { message = "^revert", group = "โ—€๏ธ Revert" }, +] +# filter out the commits that are not matched by commit parsers +filter_commits = false +# sort the tags topologically +topo_order = false +# sort the commits inside sections by oldest/newest order +sort_commits = "oldest" diff --git a/stmps.go b/stmps.go index ebf7bda..39e07d2 100644 --- a/stmps.go +++ b/stmps.go @@ -23,6 +23,7 @@ import ( var osExit = os.Exit // A variable to allow mocking os.Exit in tests var headlessMode bool // This can be set to true during tests var testMode bool // This can be set to true during tests, too +var Version string = "development" func readConfig(configFile *string) error { required_properties := []string{"auth.username", "auth.password", "server.host"} @@ -108,6 +109,7 @@ func main() { cpuprofile := flag.String("cpuprofile", "", "write cpu profile to `file`") memprofile := flag.String("memprofile", "", "write memory profile to `file`") configFile := flag.String("config", "", "use config `file`") + version := flag.Bool("version", false, "print the stmps version and exit") flag.Parse() if *help { @@ -115,6 +117,10 @@ func main() { flag.Usage() osExit(0) } + if *version { + fmt.Printf("stmps %s", Version) + osExit(0) + } // cpu/memprofile code straight from https://pkg.go.dev/runtime/pprof if *cpuprofile != "" {