chore: add mise

This commit is contained in:
Kevin Franklin Kim 2025-09-18 23:21:15 +02:00
parent 401407617a
commit 3677ba8f02
No known key found for this signature in database
4 changed files with 109 additions and 56 deletions

View File

@ -1,4 +1,4 @@
name: Lint and Test name: Test Branch
on: on:
push: push:
@ -7,48 +7,51 @@ on:
merge_group: merge_group:
workflow_dispatch: workflow_dispatch:
permissions:
contents: read
pull-requests: write
concurrency: concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true cancel-in-progress: true
env:
GOFLAGS: -mod=readonly
GOPROXY: https://proxy.golang.org
permissions:
contents: read
pull-requests: read
checks: write
jobs: jobs:
test: test:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v5
- uses: actions/setup-go@v5 - uses: jdx/mise-action@v3
- uses: actions/setup-go@v6
with: with:
check-latest: true check-latest: true
go-version-file: go.mod go-version-file: go.mod
- uses: actions/setup-node@v4 - uses: golangci/golangci-lint-action@v8
with:
install-mode: none
- uses: actions/setup-node@v5
with:
cache: yarn
- name: Run yarn install - name: Run yarn install
working-directory: example working-directory: example
run: yarn install run: yarn install
- name: Run go mod tidy - name: Run go mod tidy
run: | run: make tidy && git diff --exit-code
make tidy
git diff --exit-code
- uses: golangci/golangci-lint-action@v8 - name: Run lint
run: make lint
- name: Run tests
run: make test
- name: Make examples - name: Make examples
run: | run: |
make examples make examples
git diff --exit-code git diff --exit-code
- name: Run tests
run: make test

5
.mise.toml Normal file
View File

@ -0,0 +1,5 @@
[tools]
# https://github.com/golangci/golangci-lint/releases
golangci-lint = "2.4.0"
# https://github.com/go-courier/husky/releases
"github:go-courier/husky" = "1.8.1"

View File

@ -1,19 +1,32 @@
.DEFAULT_GOAL:=help .DEFAULT_GOAL:=help
-include .makerc -include .makerc
# --- Config -----------------------------------------------------------------
# Newline hack for error output
define br
endef
# --- Targets ----------------------------------------------------------------- # --- Targets -----------------------------------------------------------------
# This allows us to accept extra arguments # This allows us to accept extra arguments
%: .husky %: .mise .husky
@: @:
.PHONY: .mise
# Install dependencies
.mise: msg := $(br)$(br)Please ensure you have 'mise' installed and activated!$(br)$(br)$$ brew update$(br)$$ brew install mise$(br)$(br)See the documentation: https://mise.jdx.dev/getting-started.html$(br)$(br)
.mise:
ifeq (, $(shell command -v mise))
$(error ${msg})
endif
@mise install
.PHONY: .husky .PHONY: .husky
# Configure git hooks for husky # Configure git hooks for husky
.husky: .husky:
@if ! command -v husky &> /dev/null; then \
echo "ERROR: missing executeable 'husky', please run:"; \
echo "\n$ go install github.com/go-courier/husky/cmd/husky@latest\n"; \
fi
@git config core.hooksPath .husky @git config core.hooksPath .husky
## === Tasks === ## === Tasks ===
@ -22,11 +35,38 @@
## Run lint & test ## Run lint & test
check: tidy examples lint test check: tidy examples lint test
.PHONY: tidy
## Run go mod tidy
tidy:
@go mod tidy
.PHONY: lint
## Run linter
lint:
@golangci-lint run
.PHONY: lint.fix
## Run linter and fix
lint.fix:
@golangci-lint run --fix
.PHONY: test .PHONY: test
## Run go test ## Run go test
test: test:
@GO_TEST_TAGS=-skip go test -coverprofile=coverage.out --tags=safe -race ./... @GO_TEST_TAGS=-skip go test -coverprofile=coverage.out --tags=safe -race ./...
.PHONY: build
## Build binary
build:
@rm -f bin/gotsrpc
@go build -o bin/gotsrpc cmd/gotsrpc/gotsrpc.go
.PHONY: build.debug
## Build binary in debug mode
build.debug:
@rm -f bin/gotsrpc
@go build -gcflags "all=-N -l" -o bin/gotsrpc cmd/gotsrpc/gotsrpc.go
.PHONY: install .PHONY: install
## Run go install ## Run go install
install: install:
@ -42,15 +82,9 @@ install.debug:
outdated: outdated:
@go list -u -m -json all | go-mod-outdated -update -direct @go list -u -m -json all | go-mod-outdated -update -direct
.PHONY: build.debug
## Build binary in debug mode
build.debug:
@rm -f bin/gotsrpc
@go build -gcflags "all=-N -l" -o bin/gotsrpc cmd/gotsrpc/gotsrpc.go
## === Tools === ## === Tools ===
EXAMPLES=basic errors monitor nullable union time EXAMPLES=basic errors monitor nullable union time types
define examples define examples
.PHONY: example.$(1) .PHONY: example.$(1)
example.$(1): example.$(1):
@ -71,21 +105,6 @@ example.$(1).lint:
endef endef
$(foreach p,$(EXAMPLES),$(eval $(call examples,$(p)))) $(foreach p,$(EXAMPLES),$(eval $(call examples,$(p))))
.PHONY: lint
## Run linter
lint:
@golangci-lint run
.PHONY: lint.fix
## Run linter and fix
lint.fix:
@golangci-lint run --fix
.PHONY: tidy
## Run go mod tidy
tidy:
@go mod tidy
## === Examples === ## === Examples ===
.PHONY: examples .PHONY: examples

View File

@ -1,6 +1,5 @@
[![Build Status](https://github.com/foomo/gotsrpc/actions/workflows/test.yml/badge.svg?branch=main&event=push)](https://github.com/foomo/gotsrpc/actions/workflows/test.yml) [![Build Status](https://github.com/foomo/gotsrpc/actions/workflows/test.yml/badge.svg?branch=main&event=push)](https://github.com/foomo/gotsrpc/actions/workflows/test.yml)
[![Go Report Card](https://goreportcard.com/badge/github.com/foomo/gotsrpc)](https://goreportcard.com/report/github.com/foomo/gotsrpc) [![Go Report Card](https://goreportcard.com/badge/github.com/foomo/gotsrpc)](https://goreportcard.com/report/github.com/foomo/gotsrpc)
[![Coverage Status](https://coveralls.io/repos/github/foomo/gotsrpc/badge.svg?branch=main&)](https://coveralls.io/github/foomo/gotsrpc?branch=main)
[![GoDoc](https://godoc.org/github.com/foomo/gotsrpc?status.svg)](https://godoc.org/github.com/foomo/gotsrpc) [![GoDoc](https://godoc.org/github.com/foomo/gotsrpc?status.svg)](https://godoc.org/github.com/foomo/gotsrpc)
<p align="center"> <p align="center">
@ -11,22 +10,49 @@
## Documentation ## Documentation
Please refer to the documentation: Please refer to the [documentation](https://www.foomo.org/docs/projects/gotsrpc).
https://www.foomo.org/docs/projects/gotsrpc ```shell
$ gotsrpc
gotsrpc
Usage:
gotsrpc [options] <config-file>
Options:
-version Display version information
-debug Print debug information
Examples:
$ gotsrpc path/to/gotsrpc.yaml
```
## Installation ## Installation
Follow the docs: Please follow the [documentation](https://www.foomo.org/docs/projects/gotsrpc/cli#installation).
https://www.foomo.org/docs/projects/gotsrpc/cli#installation ### Download binary
From source to /usr/local/bin/gotsrpc: Download a [binary release](https://github.com/foomo/gotsrpc/releases)
```bash ### Build from source
go get github.com/foomo/gotsrpc/v2
cd $GOPATH/src/github.com/foomo/gotsrpc ```
make install go install github.com/foomo/gotsrpc@latest
```
### Homebrew (Linux/macOS)
If you use [Homebrew](https://brew.sh), you can install like this:
```
brew install foomo/tap/gotsrpc
```
### Mise
If you use [mise](https://https://mise.jdx.dev), you can install like this:
```
mise use github.com:foomo/gotsrpc
``` ```
Release downloads: Release downloads: