From 3c396cda3869206a638d65a79cad22bee31d3268 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Miri=C4=87?= <1009277+imiric@users.noreply.github.com> Date: Sat, 20 Apr 2024 20:31:16 +0200 Subject: [PATCH] build: add lint and test just recipes --- .gitignore | 2 ++ justfile | 32 +++++++++++++++++++++++++++++--- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 1667fe2..76c5ee9 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ .env /disco /dist +/*.txt +*.log diff --git a/justfile b/justfile index 915b625..8aedf06 100644 --- a/justfile +++ b/justfile @@ -1,10 +1,36 @@ +version := "1" + +# Shell script recipes fail if /tmp is mounted with noexec, so change the +# tempdir. See https://github.com/casey/just/issues/1611 +set tempdir := "." + + default: just --list -version := "1" build *ARGS: - ./release/build.sh "{{ARGS}}" + ./release/build.sh '{{ARGS}}' + clean: - rm -rf ./dist \ No newline at end of file + rm -rf ./dist ./golangci-lint*.txt + + +lint report="": + #!/usr/bin/env sh + if [ -z '{{report}}' ]; then + golangci-lint run --out-format=tab --new-from-rev=e72df147cd ./... + exit $? + fi + + _report_id="$(date '+%Y%m%d')-$(git describe --tags --abbrev=10 --always)" + golangci-lint run --out-format=tab --issues-exit-code=0 ./... | \ + tee "golangci-lint-${_report_id}.txt" | \ + awk 'NF {if ($2 == "revive") print $2 ":" $3; else print $2}' \ + | sort | uniq -c | sort -nr \ + | tee "golangci-lint-summary-${_report_id}.txt" + + +test target="..." *ARGS="": + go test -v -race -count=1 -failfast {{ARGS}} ./{{target}} \ No newline at end of file