From 5d227ea4a2ee10f111eec9b796eecc650c4278d9 Mon Sep 17 00:00:00 2001 From: Keith Zantow Date: Tue, 22 Oct 2024 16:48:33 -0400 Subject: [PATCH] chore: fill out clean targets Signed-off-by: Keith Zantow --- .golangci.yaml | 2 +- Makefile | 4 ++++ make/go.mod | 4 ++-- make/go.sum | 2 ++ make/main.go | 64 +++++++++++++++++++++++++++++++------------------- 5 files changed, 49 insertions(+), 27 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index 711db99..1758f9b 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -21,7 +21,6 @@ linters: - dogsled - dupl - errcheck - - exportloopref - funlen - gocognit - goconst @@ -49,6 +48,7 @@ linters: # do not enable... # - bodyclose # 1.18 compat # - depguard # we don't have a specific configuration for this +# - exportloopref # no longer relevant post go 1.22 # - gochecknoglobals # - gochecknoinits # this is too aggressive # - godot diff --git a/Makefile b/Makefile index ed7b91a..245a2e9 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,7 @@ +.PHONY: test +test: + @go run -C make . test + .PHONY: * .DEFAULT_GOAL: make-default diff --git a/make/go.mod b/make/go.mod index 6435ae6..962388f 100644 --- a/make/go.mod +++ b/make/go.mod @@ -1,8 +1,8 @@ module github.com/anchore/chronicle/make -go 1.22.0 +go 1.22.1 -require github.com/anchore/go-make v0.0.0-20241021192429-7e18af0fc7f9 +require github.com/anchore/go-make v0.0.0-20241022203551-494d90ce1a4a require ( github.com/kr/text v0.2.0 // indirect diff --git a/make/go.sum b/make/go.sum index cc9d53e..3fc5745 100644 --- a/make/go.sum +++ b/make/go.sum @@ -1,5 +1,7 @@ github.com/anchore/go-make v0.0.0-20241021192429-7e18af0fc7f9 h1:LvLPfZd31lsrqw5XF45RIsIA1p11DC0Z2hDEe74kUEw= github.com/anchore/go-make v0.0.0-20241021192429-7e18af0fc7f9/go.mod h1:y2KCL40/pLMqMu5PGqxGUs/1taaQjZVkuCGXFi9Lcic= +github.com/anchore/go-make v0.0.0-20241022203551-494d90ce1a4a h1:ttcnRZCKhNWkBem7L4HVk60lVx2HwWPjOPX9NH9/LuQ= +github.com/anchore/go-make v0.0.0-20241022203551-494d90ce1a4a/go.mod h1:y2KCL40/pLMqMu5PGqxGUs/1taaQjZVkuCGXFi9Lcic= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= diff --git a/make/main.go b/make/main.go index 9255c2a..940e090 100644 --- a/make/main.go +++ b/make/main.go @@ -8,35 +8,51 @@ import ( ) func main() { - fixturesTask := Task{ - Name: "fixtures", - Desc: "build test fixtures", - Run: func() { - InDir("internal/git/test-fixtures", func() { - Run("make") - }) - - InDir("chronicle/release/releasers/github/test-fixtures", func() { - Run("make") - }) - }, - } - - fixturesFingerprintTask := Task{ - Name: "fixtures-fingerprint", - Desc: "get test fixtures cache fingerprint", - Quiet: true, - Run: func() { - Log(FingerprintGlobs("internal/git/test-fixtures/*.sh")) - }, - } - Makefile( RollupTask("default", "run all validations", "static-analysis", "test"), golint.Tasks(), release.Tasks(), fixturesFingerprintTask, fixturesTask, - gotest.Test("unit"), + gotest.Test("unit", gotest.WithDependencies(fixturesTask.Name)), ) } + +var fixturesTask = Task{ + Name: "fixtures", + Desc: "build test fixtures", + Run: func() { + InDir("internal/git/test-fixtures", func() { + Run("make") + }) + + InDir("chronicle/release/releasers/github/test-fixtures", func() { + Run("make") + }) + }, + Tasks: []Task{ + { + Name: "fixtures:clean", + Desc: "clean internal git test fixture caches", + Labels: All("clean"), + Run: func() { + InDir("internal/git/test-fixtures", func() { + Run("make clean") + }) + + InDir("chronicle/release/releasers/github/test-fixtures", func() { + Run("make clean") + }) + }, + }, + }, +} + +var fixturesFingerprintTask = Task{ + Name: "fixtures-fingerprint", + Desc: "get test fixtures cache fingerprint", + Quiet: true, + Run: func() { + Log(FingerprintGlobs("internal/git/test-fixtures/*.sh")) + }, +}