From 1338c67bfc9c959bdaf661403a3633e025beae12 Mon Sep 17 00:00:00 2001 From: JM Faircloth Date: Thu, 18 Dec 2025 13:04:28 -0600 Subject: [PATCH 01/13] POC: improve CI test logging; add linting --- .github/workflows/golangci-lint.yml | 25 +++++++++++++++++++++++++ Makefile | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/golangci-lint.yml diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml new file mode 100644 index 00000000..dd3ea42b --- /dev/null +++ b/.github/workflows/golangci-lint.yml @@ -0,0 +1,25 @@ +name: golangci-lint +on: + push: + branches: + - main + - master + pull_request: +permissions: + contents: read # Optional: allow read access to pull requests +jobs: + golangci: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: stable + - name: golangci-lint + uses: golangci/golangci-lint-action@v4 + with: + # Required: Specify the version of golangci-lint to use + version: v1.59.1 # Use the desired version + # Optional: additional arguments + args: --verbose diff --git a/Makefile b/Makefile index 0a2d43da..e2f15d44 100644 --- a/Makefile +++ b/Makefile @@ -38,7 +38,7 @@ bootstrap: .PHONY: test test: fmtcheck - CGO_ENABLED=0 go test ./... $(TESTARGS) -timeout=20m + CGO_ENABLED=0 gotestsum --format github-actions -- ./... $(TESTARGS) -timeout=20m .PHONY: fmtcheck fmtcheck: From 7070dafc0c254bcadd58aa3e00f7db19733a5a86 Mon Sep 17 00:00:00 2001 From: JM Faircloth Date: Thu, 18 Dec 2025 13:07:24 -0600 Subject: [PATCH 02/13] fix makefile tooling --- Makefile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index e2f15d44..0b0e31f5 100644 --- a/Makefile +++ b/Makefile @@ -35,12 +35,16 @@ bootstrap: go mod edit -module github.com/hashicorp/$(REPO_DIR); \ fi +.PHONY: tools +tools: + @which gofumpt > /dev/null || (echo "Installing gofumpt..." && go install mvdan.cc/gofumpt@latest) + @which gotestsum > /dev/null || (echo "Installing gotestsum..." && go install gotest.tools/gotestsum@latest) .PHONY: test -test: fmtcheck +test: tools fmtcheck CGO_ENABLED=0 gotestsum --format github-actions -- ./... $(TESTARGS) -timeout=20m -.PHONY: fmtcheck +.PHONY: tools fmtcheck fmtcheck: @sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'" From 9b7984a347b3c7f222c61117f480961a14a300ad Mon Sep 17 00:00:00 2001 From: JM Faircloth Date: Thu, 18 Dec 2025 13:23:10 -0600 Subject: [PATCH 03/13] add coverage --- .github/workflows/golangci-lint.yml | 10 ++++------ .github/workflows/tests.yaml | 29 +++++++++++++++++++++++++---- Makefile | 3 ++- 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index dd3ea42b..edc833d1 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -3,7 +3,6 @@ on: push: branches: - main - - master pull_request: permissions: contents: read # Optional: allow read access to pull requests @@ -17,9 +16,8 @@ jobs: with: go-version: stable - name: golangci-lint - uses: golangci/golangci-lint-action@v4 + uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0 with: - # Required: Specify the version of golangci-lint to use - version: v1.59.1 # Use the desired version - # Optional: additional arguments - args: --verbose + version: latest + args: --timeout 10m + only-new-issues: true diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index d23a9f47..dfa2d252 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -1,7 +1,28 @@ -name: Run Tests +# copy of https://github.com/hashicorp/vault-workflows-common/blob/main/.github/workflows/tests.yaml +name: Tests + on: - push: + workflow_call: {} + +permissions: + contents: read + jobs: run-tests: - # using `main` as the ref will keep your workflow up-to-date - uses: hashicorp/vault-workflows-common/.github/workflows/tests.yaml@main + name: "Run Tests" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5.4.0 + with: + go-version-file: .go-version + + - name: Run Tests + run: make test + + - name: Run Test Build + run: make dev + + - name: Print Coverage Summary + # Parses the profile and prints per-function coverage to stdout + run: go tool cover -func=coverage.out diff --git a/Makefile b/Makefile index 0b0e31f5..e37b074e 100644 --- a/Makefile +++ b/Makefile @@ -42,7 +42,8 @@ tools: .PHONY: test test: tools fmtcheck - CGO_ENABLED=0 gotestsum --format github-actions -- ./... $(TESTARGS) -timeout=20m + CGO_ENABLED=0 gotestsum --format github-actions \ + -- ./... $(TESTARGS) -timeout=20m -race -coverprofile=coverage.out .PHONY: tools fmtcheck fmtcheck: From effc674c18c6f89268d1bb2039323df482c2b1ea Mon Sep 17 00:00:00 2001 From: JM Faircloth Date: Thu, 18 Dec 2025 13:28:45 -0600 Subject: [PATCH 04/13] fix lint err --- .github/workflows/tests.yaml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index dfa2d252..fc16a3d4 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -24,5 +24,17 @@ jobs: run: make dev - name: Print Coverage Summary - # Parses the profile and prints per-function coverage to stdout - run: go tool cover -func=coverage.out + # Parses the profile and prints per-function coverage to stdout + run: go tool cover -func=coverage.out + + code_coverage: + name: "Code coverage report" + if: github.event_name == 'pull_request' + runs-on: ubuntu-latest + needs: coverage + permissions: + contents: read + actions: read + pull-requests: write + steps: + - uses: fgrosse/go-coverage-report@8c1d1a09864211d258937b1b1a5b849f7e4f2682 # v1.2.0 From 45353a0246696707fa0a6e9537f4dd3ed12bc6bb Mon Sep 17 00:00:00 2001 From: JM Faircloth Date: Thu, 18 Dec 2025 13:31:19 -0600 Subject: [PATCH 05/13] fix depends on --- .github/workflows/tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index fc16a3d4..1263deb8 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -31,7 +31,7 @@ jobs: name: "Code coverage report" if: github.event_name == 'pull_request' runs-on: ubuntu-latest - needs: coverage + needs: run-tests permissions: contents: read actions: read From caeb71773725bd76de6b89d5f16813feb76daa6b Mon Sep 17 00:00:00 2001 From: JM Faircloth Date: Thu, 18 Dec 2025 13:32:39 -0600 Subject: [PATCH 06/13] fix test yaml --- .github/workflows/tests.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 1263deb8..e6faa7ff 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -1,8 +1,8 @@ # copy of https://github.com/hashicorp/vault-workflows-common/blob/main/.github/workflows/tests.yaml -name: Tests +name: Run Tests on: - workflow_call: {} + push: permissions: contents: read From b7b2d31c7a1b86863e6b4432a8a4c3fcfc011a0d Mon Sep 17 00:00:00 2001 From: JM Faircloth Date: Thu, 18 Dec 2025 13:33:58 -0600 Subject: [PATCH 07/13] -race require cgo --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e37b074e..c53c138d 100644 --- a/Makefile +++ b/Makefile @@ -42,7 +42,7 @@ tools: .PHONY: test test: tools fmtcheck - CGO_ENABLED=0 gotestsum --format github-actions \ + gotestsum --format github-actions \ -- ./... $(TESTARGS) -timeout=20m -race -coverprofile=coverage.out .PHONY: tools fmtcheck From 0650c09670162b077c87e494e723c317023f8198 Mon Sep 17 00:00:00 2001 From: JM Faircloth Date: Thu, 18 Dec 2025 13:40:48 -0600 Subject: [PATCH 08/13] add pull_request trigger --- .github/workflows/tests.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index e6faa7ff..1023be0f 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -3,6 +3,7 @@ name: Run Tests on: push: + pull_request: permissions: contents: read From 875ec26a1f1510d5e51228b791f59fbf965ebeb1 Mon Sep 17 00:00:00 2001 From: JM Faircloth Date: Thu, 18 Dec 2025 13:44:42 -0600 Subject: [PATCH 09/13] fix coverage --- .github/workflows/tests.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 1023be0f..24e3e09c 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -3,6 +3,7 @@ name: Run Tests on: push: + branches: [ "main" ] pull_request: permissions: @@ -26,7 +27,7 @@ jobs: - name: Print Coverage Summary # Parses the profile and prints per-function coverage to stdout - run: go tool cover -func=coverage.out + run: go tool cover -func=coverage.txt code_coverage: name: "Code coverage report" From 4f931dd4f0871b9d01c696de1e55262b5cbe4149 Mon Sep 17 00:00:00 2001 From: JM Faircloth Date: Thu, 18 Dec 2025 13:47:39 -0600 Subject: [PATCH 10/13] upload artifact --- .github/workflows/tests.yaml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 24e3e09c..429b30f5 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -27,7 +27,13 @@ jobs: - name: Print Coverage Summary # Parses the profile and prints per-function coverage to stdout - run: go tool cover -func=coverage.txt + run: go tool cover -func=coverage.out + + - name: Archive code coverage results + uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0 + with: + name: code-coverage + path: coverage.txt code_coverage: name: "Code coverage report" From a053880b1aeec0de312ea30d31e642daad579b3c Mon Sep 17 00:00:00 2001 From: JM Faircloth Date: Thu, 18 Dec 2025 13:51:20 -0600 Subject: [PATCH 11/13] fix path --- .github/workflows/tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 429b30f5..f39d98ec 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -33,7 +33,7 @@ jobs: uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0 with: name: code-coverage - path: coverage.txt + path: coverage.out code_coverage: name: "Code coverage report" From c51b192902cff54319b7ce9ded1e51aec1b05383 Mon Sep 17 00:00:00 2001 From: JM Faircloth Date: Thu, 18 Dec 2025 13:56:57 -0600 Subject: [PATCH 12/13] filename --- .github/workflows/tests.yaml | 4 ++-- .gitignore | 2 ++ Makefile | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index f39d98ec..1bda52f3 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -27,13 +27,13 @@ jobs: - name: Print Coverage Summary # Parses the profile and prints per-function coverage to stdout - run: go tool cover -func=coverage.out + run: go tool cover -func=coverage.txt - name: Archive code coverage results uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0 with: name: code-coverage - path: coverage.out + path: coverage.txt code_coverage: name: "Code coverage report" diff --git a/.gitignore b/.gitignore index 3f9ee1ff..159efbaa 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,8 @@ *.a *.so +coverage.* + # Folders _obj _test diff --git a/Makefile b/Makefile index c53c138d..18d4ec0d 100644 --- a/Makefile +++ b/Makefile @@ -43,7 +43,7 @@ tools: .PHONY: test test: tools fmtcheck gotestsum --format github-actions \ - -- ./... $(TESTARGS) -timeout=20m -race -coverprofile=coverage.out + -- ./... $(TESTARGS) -timeout=20m -race -coverprofile=coverage.txt .PHONY: tools fmtcheck fmtcheck: From 44a56b537f3044acca97a8138b456efee797cbbb Mon Sep 17 00:00:00 2001 From: JM Faircloth Date: Thu, 18 Dec 2025 14:11:43 -0600 Subject: [PATCH 13/13] remove cov gh action --- .github/workflows/tests.yaml | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 1bda52f3..2a13927e 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -19,12 +19,12 @@ jobs: with: go-version-file: .go-version + - name: Run Build + run: make dev + - name: Run Tests run: make test - - name: Run Test Build - run: make dev - - name: Print Coverage Summary # Parses the profile and prints per-function coverage to stdout run: go tool cover -func=coverage.txt @@ -34,15 +34,3 @@ jobs: with: name: code-coverage path: coverage.txt - - code_coverage: - name: "Code coverage report" - if: github.event_name == 'pull_request' - runs-on: ubuntu-latest - needs: run-tests - permissions: - contents: read - actions: read - pull-requests: write - steps: - - uses: fgrosse/go-coverage-report@8c1d1a09864211d258937b1b1a5b849f7e4f2682 # v1.2.0