diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.yml index e9afa08..6470184 100644 --- a/.github/workflows/quality.yml +++ b/.github/workflows/quality.yml @@ -9,17 +9,16 @@ jobs: name: 📋 GolangCI runs-on: ubuntu-latest steps: - - name: ⬇️ Git clone the repository - uses: actions/checkout@v4 + - name: ⬇️ Git clone the repository + uses: actions/checkout@v6 - - name: 📦 Install Go - uses: actions/setup-go@v5 - with: - go-version-file: 'go.mod' + - name: 📦 Install Mise + run: | + curl https://mise.run | sh + mise install + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # Action sometimes causes threading. Recommended to run in separate workflow action. - # See https://github.com/golangci/golangci-lint-action?tab=readme-ov-file#how-to-use - - name: 🧪 GolangCI - uses: golangci/golangci-lint-action@v8 - with: - version: v2.3 + - name: 🧪 Lint + run: | + mise run lint diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 420be9a..3311b98 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,27 +14,18 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: fetch-depth: 0 - - name: Install Go - uses: actions/setup-go@v5 - with: - go-version-file: 'go.mod' - - - name: Login to GHCR - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} + - name: 📦 Install Mise + run: | + curl https://mise.run | sh + mise install + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v6 - with: - distribution: goreleaser - version: "~> v2" - args: release --clean + run: mise release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 1d700ec..bd016f9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .idea vendor +bin dist diff --git a/.mise.toml b/.mise.toml new file mode 100644 index 0000000..1e888d3 --- /dev/null +++ b/.mise.toml @@ -0,0 +1,54 @@ +[tools] +go = "1.25" +"go:github.com/daixiang0/gci" = "latest" +"ubi:golangci/golangci-lint" = "2.5" +"ubi:goreleaser/goreleaser" = "2.12" + +[env] +CGO_ENABLED=0 +LGFLAGS="-extldflags '-static'" +IMAGE="skpr/grpc-go:latest" +PB_DIR="./pb" + +[tasks.vendor] +description = "Vendor resets the main module's vendor directory to include all packages needed to build the application" +run = "go mod vendor" +depends = ["generate"] + +[tasks.tidy] +description = "Tidy makes sure go.mod matches the source code in the module" +run = "go mod tidy" + +[tasks.generate] +description = "Build the grpc protocol" +run = ''' +rm -rf $PB_DIR +mkdir -p $PB_DIR +# Sadly can't get protoc on mac through mise. +docker build -t $IMAGE dockerfiles/grpc-go +docker run -it -w /data -v .:/data $IMAGE /bin/bash -c 'protoc --go_out=./pb --go_opt=paths=source_relative --go-grpc_out=./pb --go-grpc_opt=paths=source_relative *.proto' +''' + +[tasks."build"] +description = "Build the application" +run = "go build -o bin/apiserver-mock -ldflags=${CLI_LDFLAGS} github.com/skpr/api/cmd/apiserver-mock" +depends = ["vendor"] + +[tasks.mock] +description = "Run the application" +run = "bin/apiserver-mock" +depends = ["build"] + +[tasks."lint"] +description = "Linting automatically checks code for errors and style issues" +run = "golangci-lint run" + +[tasks.test] +description = "Checks to verify code correctness" +run = "go test -cover ./..." +depends = ["vendor"] + +[tasks.release] +description = "Release the command line interface" +run = "goreleaser" +depends = ["build"] diff --git a/Makefile b/Makefile deleted file mode 100644 index a0c7b24..0000000 --- a/Makefile +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/make -f - -# Directory to store GRPC package. -DIR=./pb - -# Image used to build the package. -IMAGE=skpr/grpc-go:latest - -# Builds the client/server code. -build: - # Cleaning up directories. - rm -fR $(DIR) - mkdir -p $(DIR) - # Building image. - docker build -t $(IMAGE) dockerfiles/grpc-go - # Building package. - docker run -it -w $(PWD) -v $(PWD):$(PWD) $(IMAGE) /bin/bash -c 'protoc --go_out=./pb --go_opt=paths=source_relative --go-grpc_out=./pb --go-grpc_opt=paths=source_relative *.proto' - -docs: - docker run --rm -v $(pwd)/doc:/out pseudomuto/protoc-gen-doc --doc_opt=markdown,docs.md - -.PHONY: *