From cf926f05f994d87e5c9ea4742ef143f10ac927d8 Mon Sep 17 00:00:00 2001 From: Stefan Majewsky Date: Tue, 1 Jul 2025 11:44:56 +0200 Subject: add `make check` target --- .github/workflows/checks.yaml | 4 ++-- .gitignore | 1 + Makefile | 34 ++++++++++++++++++++++++++++++++++ REUSE.toml | 1 + 4 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 .gitignore create mode 100644 Makefile diff --git a/.github/workflows/checks.yaml b/.github/workflows/checks.yaml index 8541806..5e96628 100644 --- a/.github/workflows/checks.yaml +++ b/.github/workflows/checks.yaml @@ -42,11 +42,11 @@ jobs: # Test Suite - name: Run tests - run: go test -shuffle=on -coverprofile=cover.out -covermode=count ./... + run: go test -shuffle=on -coverprofile=build/cover.out -covermode=count ./... - name: Upload coverage report to Coveralls env: COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }} GIT_BRANCH: ${{ github.head_ref }} run: | go install github.com/mattn/goveralls@latest - goveralls -service=github -coverprofile=cover.out + goveralls -service=github -coverprofile=build/cover.out diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..84c048a --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/build/ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..4444b40 --- /dev/null +++ b/Makefile @@ -0,0 +1,34 @@ +# SPDX-FileCopyrightText: 2025 Stefan Majewsky +# SPDX-License-Identifier: Apache-2.0 + +default: help + +check: static-check build/cover.html + +static-check: FORCE + @printf "\e[1;36m>> golangci-lint\e[0m\n" + @golangci-lint config verify + @golangci-lint run + @printf "\e[1;36m>> reuse lint\e[0m\n" + @if ! reuse lint -q; then reuse lint; fi + +build/cover.out: FORCE + @printf "\e[1;36m>> go test\e[0m\n" + go test -shuffle=on -coverprofile=build/cover.out -covermode=count ./... +build/cover.html: build/cover.out + @printf "\e[1;36m>> go tool cover\e[0m\n" + go tool cover -html $< -o $@ + +help: FORCE + @printf "\n" + @printf "\e[1mUsage:\e[0m\n" + @printf " make \e[36m\e[0m\n" + @printf "\n" + @printf "\e[1mTest\e[0m\n" + @printf " \e[36mcheck\e[0m Run all tests and checks.\n" + @printf " \e[36mstatic-check\e[0m Run static code checks.\n" + @printf " \e[36mbuild/cover.out\e[0m Run tests and generate coverage report.\n" + @printf " \e[36mbuild/cover.html\e[0m Generate an HTML file with source code annotations from the coverage report.\n" + @printf "\n" + +.PHONY: FORCE diff --git a/REUSE.toml b/REUSE.toml index 8555114..5c2693c 100644 --- a/REUSE.toml +++ b/REUSE.toml @@ -6,6 +6,7 @@ SPDX-PackageDownloadLocation = "https://github.com/majewsky/gg" [[annotations]] path = [ + ".gitignore", "go.mod", ] SPDX-FileCopyrightText = "Stefan Majewsky " -- cgit v1.2.3