Skip to content

refactor: adopt Go 1.26 features and clean up test temp files#477

Merged
CybotTM merged 8 commits intomainfrom
feat/go126-modernization
Feb 15, 2026
Merged

refactor: adopt Go 1.26 features and clean up test temp files#477
CybotTM merged 8 commits intomainfrom
feat/go126-modernization

Conversation

@CybotTM
Copy link
Member

@CybotTM CybotTM commented Feb 15, 2026

Summary

  • Modernize reflect iteration: Replace index-based for i := range t.NumField() loops with Go 1.26 reflect.Type.Fields() range iterator in core/common.go (GetHash) and config/validator.go (validateStruct), consistent with existing usage in cli/config_decode.go
  • Add IPv6 URL test coverage: Go 1.26's stricter net/url.Parse() rejects unbracketed IPv6 addresses. Added tests verifying webhook URL validation handles both valid (bracketed) and invalid (unbracketed) IPv6 forms, plus whitelist matching
  • Replace os.CreateTemp/MkdirTemp with t.TempDir(): Removed 30 manual temp file/dir creation + cleanup patterns across 12 test files, replacing with t.TempDir() which handles cleanup automatically. Net reduction of ~100 lines

Test Plan

  • go build ./... passes
  • go vet ./... passes
  • golangci-lint run — 0 issues
  • go test -race ./... — all packages pass
  • Zero remaining os.CreateTemp/os.MkdirTemp in test files

Copilot AI review requested due to automatic review settings February 15, 2026 15:32
@gemini-code-assist
Copy link

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@github-actions
Copy link

github-actions bot commented Feb 15, 2026

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated approval for solo maintainer project

All CI checks passed. See SECURITY.md for compensating controls.

@github-actions
Copy link

⚠️ Mutation Testing Results

Mutation Score: 0.00% (threshold: 60%)

⚠️ Score is below threshold. Consider improving test coverage or test quality.

What is mutation testing?

Mutation testing measures test quality by introducing small changes (mutations) to the code and checking if tests detect them. A higher score means better test effectiveness.

  • Killed mutants: Tests caught the mutation (good!)
  • Survived mutants: Tests missed the mutation (needs improvement)

@CybotTM CybotTM added this pull request to the merge queue Feb 15, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR modernizes the codebase for Go 1.26 and simplifies test filesystem handling by switching to t.TempDir(), while adding coverage for stricter IPv6 URL parsing behavior affecting webhook validation.

Changes:

  • Refactor reflection field iteration to use Go 1.26 reflect.Type.Fields() iterators.
  • Add webhook URL validation tests for bracketed vs unbracketed IPv6 URLs and whitelist behavior.
  • Replace manual temp file/dir creation+cleanup in tests with t.TempDir() patterns.

Reviewed changes

Copilot reviewed 15 out of 16 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
core/common.go Update GetHash to iterate struct fields via t.Fields() (Go 1.26 iterator).
config/validator.go Update validateStruct to iterate fields via typ.Fields() and skip unexported via IsExported().
middlewares/webhook_security_test.go Add IPv6 URL parsing + whitelist test cases aligned with stricter net/url parsing.
middlewares/save_test.go Switch temp directory handling to t.TempDir() for save-folder creation test.
core/localjob_comprehensive_test.go Replace manual temp dir lifecycle with t.TempDir() for working-directory execution test.
core/adapters/docker/auth_test.go Use t.TempDir() for docker auth config fixture directories.
cli/validate_test.go Use t.TempDir() + os.WriteFile for config fixtures (no manual cleanup).
cli/daemon_lifecycle_test.go Use t.TempDir() + os.WriteFile for invalid config fixture.
cli/daemon_full_lifecycle_test.go Use t.TempDir() + os.WriteFile for daemon boot config fixtures.
cli/daemon_boot_test.go Use t.TempDir() + os.WriteFile and t.TempDir()-scoped missing-file paths.
cli/config_test.go Replace temp file/dir creation with t.TempDir() for config file and glob tests.
cli/config_show_test.go Replace temp file creation with t.TempDir() for config-show tests.
cli/config_parsing_test.go Replace temp dir creation with t.TempDir() in config file resolution tests.
cli/config_extra_test.go Replace temp file creation with t.TempDir() for INI reload/update tests.
cli/config_comprehensive_test.go Replace temp dir creation with t.TempDir() for latest-changed test.
.gitignore Ignore .worktrees/ directory.

@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to Branch Protection failures Feb 15, 2026
You're not authorized to push to this branch. Visit "About protected branches" for more information.
github-actions[bot]
github-actions bot previously approved these changes Feb 15, 2026
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated approval for solo maintainer project

All CI checks passed. See SECURITY.md for compensating controls.

@CybotTM CybotTM enabled auto-merge February 15, 2026 16:17
- Use portable t.TempDir() path instead of hardcoded /tmp for
  non-existent config file test case
- Check os.WriteFile errors in resolveConfigFiles test setup
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated approval for solo maintainer project

All CI checks passed. See SECURITY.md for compensating controls.

@CybotTM CybotTM added this pull request to the merge queue Feb 15, 2026
Merged via the queue into main with commit 6918e4f Feb 15, 2026
30 checks passed
@CybotTM CybotTM deleted the feat/go126-modernization branch February 15, 2026 16:31
@github-actions github-actions bot added the released:v0.20.0 Included in v0.20.0 release label Feb 17, 2026
@github-actions
Copy link

🚀 Released in v0.20.0

Thank you for your contribution! 🙏

This is now available in the latest release. Please test and verify everything works as expected in your environment.

If you encounter any issues, please open a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released:v0.20.0 Included in v0.20.0 release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants