Skip to content

Commit a819af5

Browse files
committed
chore: update CI/CD configuration and documentation
- Update CI workflow configuration - Update golangci-lint configuration - Add codecov.yml for code coverage settings - Update Makefile with new targets - Update README with additional documentation - Update CHANGELOG
1 parent 5683ed2 commit a819af5

6 files changed

Lines changed: 216 additions & 39 deletions

File tree

.github/workflows/ci.yml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ on:
1313
- develop
1414

1515
env:
16-
GO_VERSION: "1.21"
16+
GO_VERSION: "1.24"
1717
GOLANGCI_LINT_VERSION: "v1.54"
1818

1919
jobs:
@@ -51,7 +51,7 @@ jobs:
5151
runs-on: ubuntu-latest
5252
strategy:
5353
matrix:
54-
go-version: ["1.21"]
54+
go-version: ["1.24"]
5555
steps:
5656
- name: Checkout code
5757
uses: actions/checkout@v4
@@ -65,18 +65,31 @@ jobs:
6565
- name: Download dependencies
6666
run: go mod download
6767

68+
- name: Install gotestsum
69+
run: go install gotest.tools/gotestsum@latest
70+
6871
- name: Run tests
69-
run: go test -v -cover -coverprofile=coverage.out ./internal/...
72+
run: |
73+
gotestsum --junitfile junit.xml --format testname -- -v -cover -coverprofile=coverage.out ./internal/...
74+
75+
- name: Upload test results
76+
uses: actions/upload-artifact@v3
77+
if: always()
78+
with:
79+
name: test-results
80+
path: junit.xml
7081

7182
- name: Upload coverage reports
7283
uses: codecov/codecov-action@v5
7384
if: matrix.go-version == env.GO_VERSION
7485
with:
7586
token: ${{ secrets.CODECOV_TOKEN }}
7687
slug: Trozz/terraform-provider-pocketid
77-
file: ./coverage.out
88+
files: ./coverage.out,./junit.xml
7889
flags: unittests
7990
name: codecov-umbrella
91+
fail_ci_if_error: true
92+
verbose: true
8093

8194
build:
8295
name: Build

.golangci.yml

Lines changed: 31 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,43 @@
1-
# .golangci.yml
2-
# Minimal configuration to avoid compatibility issues
3-
1+
version: "2"
42
run:
5-
timeout: 5m
6-
tests: true
73
build-tags:
84
- acc
9-
5+
tests: true
106
linters:
11-
disable-all: true
7+
default: none
128
enable:
13-
# Enable only stable, essential linters
149
- errcheck
15-
- gosimple
1610
- govet
1711
- ineffassign
12+
- misspell
1813
- staticcheck
19-
- typecheck
2014
- unused
21-
- gofmt
22-
- goimports
23-
- misspell
24-
25-
linters-settings:
26-
gofmt:
27-
simplify: true
28-
goimports:
29-
local-prefixes: github.com/Trozz/terraform-provider-pocketid
30-
15+
exclusions:
16+
generated: lax
17+
rules:
18+
- linters:
19+
- errcheck
20+
path: _test\.go
21+
paths:
22+
- third_party$
23+
- builtin$
24+
- examples$
3125
issues:
32-
exclude-use-default: false
33-
max-same-issues: 0
3426
max-issues-per-linter: 0
35-
36-
# Exclude some linters from running on tests files.
37-
exclude-rules:
38-
- path: _test\.go
39-
linters:
40-
- errcheck
41-
42-
output:
43-
format: colored-line-number
44-
print-issued-lines: true
45-
print-linter-name: true
27+
max-same-issues: 0
28+
formatters:
29+
enable:
30+
- gofmt
31+
- goimports
32+
settings:
33+
gofmt:
34+
simplify: true
35+
goimports:
36+
local-prefixes:
37+
- github.com/Trozz/terraform-provider-pocketid
38+
exclusions:
39+
generated: lax
40+
paths:
41+
- third_party$
42+
- builtin$
43+
- examples$

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2020
- Tests for request timeout and context cancellation scenarios
2121
- Tests for JSON unmarshaling errors and network failures
2222
- Coverage report documentation (COVERAGE_REPORT.md)
23+
- Test analytics support with Codecov integration
24+
- JUnit XML test result reporting for failed test analysis
25+
- Enhanced CI workflow with gotestsum for better test output
26+
- Codecov configuration for test analytics and coverage tracking
27+
- New make targets: `test-junit` and `test-ci` for JUnit output
2328

2429
### Improved
2530
- Enhanced error handling throughout the client package

Makefile

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,32 @@ install: build ## Build and install the provider locally
5151
.PHONY: test
5252
test: ## Run unit tests
5353
@echo "$(GREEN)Running unit tests...$(NC)"
54-
$(GOTEST) -v -cover -coverprofile=coverage.out ./internal/...
54+
@if command -v gotestsum >/dev/null 2>&1; then \
55+
echo "$(CYAN)Using gotestsum for enhanced test output...$(NC)"; \
56+
gotestsum --junitfile junit.xml --format testname -- -v -cover -coverprofile=coverage.out ./internal/...; \
57+
else \
58+
$(GOTEST) -v -cover -coverprofile=coverage.out ./internal/...; \
59+
fi
5560
@echo "$(GREEN)Unit tests complete!$(NC)"
5661

5762
.PHONY: test-coverage
5863
test-coverage: test ## Run tests and show coverage report
5964
@echo "$(GREEN)Generating coverage report...$(NC)"
6065
@go tool cover -html=coverage.out -o coverage.html
6166
@echo "$(GREEN)Coverage report generated: coverage.html$(NC)"
67+
@if [ -f junit.xml ]; then \
68+
echo "$(GREEN)JUnit test report generated: junit.xml$(NC)"; \
69+
fi
70+
71+
.PHONY: test-junit
72+
test-junit: ## Run tests with JUnit XML output
73+
@echo "$(GREEN)Running tests with JUnit output...$(NC)"
74+
@if ! command -v gotestsum >/dev/null 2>&1; then \
75+
echo "$(YELLOW)Installing gotestsum...$(NC)"; \
76+
go install gotest.tools/gotestsum@latest; \
77+
fi
78+
@gotestsum --junitfile junit.xml --format testname -- -v -cover -coverprofile=coverage.out ./internal/...
79+
@echo "$(GREEN)Tests complete! JUnit report: junit.xml$(NC)"
6280

6381
.PHONY: test-acc
6482
test-acc: ## Run acceptance tests (requires POCKETID_BASE_URL and POCKETID_API_TOKEN)
@@ -134,7 +152,7 @@ docs-preview: ## Preview documentation in browser
134152
clean: ## Clean build artifacts
135153
@echo "$(GREEN)Cleaning build artifacts...$(NC)"
136154
@rm -f $(BINARY_NAME)
137-
@rm -f coverage.out coverage.html
155+
@rm -f coverage.out coverage.html junit.xml
138156
@rm -rf dist/
139157
@echo "$(GREEN)Clean complete!$(NC)"
140158

@@ -201,6 +219,18 @@ test-integration: ## Run integration tests against live Pocket-ID instance
201219
@cd test && terraform init && terraform apply -auto-approve
202220
@echo "$(GREEN)Integration tests complete!$(NC)"
203221

222+
.PHONY: test-ci
223+
test-ci: ## Run tests in CI format with JUnit output
224+
@echo "$(GREEN)Running tests in CI format...$(NC)"
225+
@if ! command -v gotestsum >/dev/null 2>&1; then \
226+
echo "$(YELLOW)Installing gotestsum...$(NC)"; \
227+
go install gotest.tools/gotestsum@latest; \
228+
fi
229+
@gotestsum --junitfile junit.xml --format standard-verbose -- -v -race -cover -coverprofile=coverage.out ./internal/...
230+
@echo "$(GREEN)CI tests complete!$(NC)"
231+
@echo " Coverage report: coverage.out"
232+
@echo " JUnit report: junit.xml"
233+
204234
.PHONY: test-cleanup
205235
test-cleanup: ## Clean up integration test resources
206236
@echo "$(GREEN)Cleaning up test resources...$(NC)"

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
[![Terraform Registry](https://img.shields.io/badge/Terraform%20Registry-v0.1.0-blue)](https://registry.terraform.io/providers/trozz/pocketid/latest)
44
[![CI](https://github.com/Trozz/terraform-provider-pocketid/actions/workflows/ci.yml/badge.svg)](https://github.com/Trozz/terraform-provider-pocketid/actions/workflows/ci.yml)
5+
[![codecov](https://codecov.io/gh/Trozz/terraform-provider-pocketid/branch/main/graph/badge.svg)](https://codecov.io/gh/Trozz/terraform-provider-pocketid)
56
[![Go Report Card](https://goreportcard.com/badge/github.com/Trozz/terraform-provider-pocketid)](https://goreportcard.com/report/github.com/Trozz/terraform-provider-pocketid)
67
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
78

@@ -198,6 +199,47 @@ Acceptance tests require a manually configured Pocket-ID instance:
198199

199200
See [TESTING.md](TESTING.md) for detailed testing instructions and strategies.
200201

202+
### Test Analytics
203+
204+
This project uses [Codecov](https://codecov.io) for code coverage and test analytics:
205+
206+
[![codecov](https://codecov.io/gh/Trozz/terraform-provider-pocketid/branch/main/graph/badge.svg)](https://codecov.io/gh/Trozz/terraform-provider-pocketid)
207+
208+
#### Features
209+
210+
- **Code Coverage**: Track test coverage across all packages
211+
- **Test Analytics**: Monitor test performance and identify flaky tests
212+
- **Failed Test Reporting**: Get detailed reports on test failures
213+
- **PR Comments**: Automatic coverage reports on pull requests
214+
215+
#### Running Tests with JUnit Output
216+
217+
For detailed test reporting, use `gotestsum`:
218+
219+
```bash
220+
# Install gotestsum if not already installed
221+
go install gotest.tools/gotestsum@latest
222+
223+
# Run tests with JUnit XML output
224+
make test-junit
225+
226+
# Or run in CI format
227+
make test-ci
228+
```
229+
230+
This generates:
231+
- `coverage.out` - Code coverage report
232+
- `junit.xml` - JUnit format test results for test analytics
233+
234+
#### Local Coverage Report
235+
236+
Generate an HTML coverage report:
237+
238+
```bash
239+
make test-coverage
240+
# Opens coverage.html in your default browser
241+
```
242+
201243
### Local Development
202244

203245
1. Start a local Pocket-ID instance:

codecov.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Codecov configuration for Terraform PocketID Provider
2+
# https://docs.codecov.com/docs/codecovyml-reference
3+
4+
# Coverage configuration
5+
coverage:
6+
precision: 2
7+
round: down
8+
range: "30...100"
9+
10+
status:
11+
project:
12+
default:
13+
target: auto
14+
threshold: 1%
15+
paths:
16+
- "internal/"
17+
if_not_found: success
18+
if_ci_failed: error
19+
informational: false
20+
only_pulls: false
21+
22+
patch:
23+
default:
24+
target: 80%
25+
threshold: 10%
26+
if_not_found: success
27+
if_ci_failed: error
28+
informational: false
29+
only_pulls: false
30+
31+
# Test analytics configuration
32+
# https://docs.codecov.com/docs/test-analytics
33+
test_analytics:
34+
enabled: true
35+
36+
# Flags configuration for different test types
37+
flags:
38+
unittests:
39+
paths:
40+
- internal/
41+
carryforward: true
42+
43+
# Comment configuration
44+
comment:
45+
layout: "reach,diff,flags,tree,betaprofiling"
46+
behavior: default
47+
require_changes: false
48+
require_base: true
49+
require_head: true
50+
show_carryforward_flags: true
51+
show_critical_paths: true
52+
53+
# Test results in PR comments
54+
show_test_results: true
55+
56+
# Ignore certain files/paths
57+
ignore:
58+
- "**/*_test.go"
59+
- "**/testdata/**"
60+
- "examples/**"
61+
- "docs/**"
62+
- "*.md"
63+
- "go.mod"
64+
- "go.sum"
65+
- ".github/**"
66+
- ".gitignore"
67+
- "LICENSE"
68+
- "Makefile"
69+
- ".golangci.yml"
70+
- ".goreleaser.yml"
71+
72+
# Parsers configuration
73+
parsers:
74+
junit:
75+
branch_detection:
76+
conditional: true
77+
loop: true
78+
method: false
79+
macro: false
80+
81+
# GitHub integration
82+
github_checks:
83+
annotations: true
84+
85+
# Codecov CI settings
86+
codecov:
87+
require_ci_to_pass: true
88+
notify:
89+
wait_for_ci: true

0 commit comments

Comments
 (0)