feat: go 1.25.5, dependency updates, renamed internal/errors (#129)

* feat: rename internal/errors to internal/apperrors

* fix(tests): clear env values before using in tests

* feat: rename internal/errors to internal/apperrors

* chore(deps): update go and all dependencies

* chore: remove renovate from pre-commit, formatting

* chore: sonarcloud fixes

* feat: consolidate constants to appconstants/constants.go

* chore: sonarcloud fixes

* feat: simplification, deduplication, test utils

* chore: sonarcloud fixes

* chore: sonarcloud fixes

* chore: sonarcloud fixes

* chore: sonarcloud fixes

* chore: clean up

* fix: config discovery, const deduplication

* chore: fixes
This commit is contained in:
2026-01-01 23:17:29 +02:00
committed by GitHub
parent 85a439d804
commit 7f80105ff5
65 changed files with 2321 additions and 1710 deletions

View File

@@ -6,13 +6,14 @@ import (
"path/filepath"
"regexp"
"github.com/ivuorinen/gh-action-readme/appconstants"
"github.com/ivuorinen/gh-action-readme/internal/git"
)
// IsCommitSHA checks if a version string is a commit SHA.
func IsCommitSHA(version string) bool {
// Check if it's a 40-character hex string (full SHA) or 7+ character hex (short SHA)
re := regexp.MustCompile(`^[a-f0-9]{7,40}$`)
re := regexp.MustCompile(appconstants.RegexGitSHA)
return len(version) >= 7 && re.MatchString(version)
}
@@ -34,10 +35,10 @@ func IsVersionPinned(version string) bool {
// ValidateGitBranch checks if a branch exists in the given repository.
func ValidateGitBranch(repoRoot, branch string) bool {
cmd := exec.Command(
"git",
"show-ref",
"--verify",
"--quiet",
appconstants.GitCommand,
appconstants.GitShowRef,
appconstants.GitVerify,
appconstants.GitQuiet,
"refs/heads/"+branch,
) // #nosec G204 -- branch name validated by git
cmd.Dir = repoRoot
@@ -54,7 +55,7 @@ func ValidateActionYMLPath(path string) error {
// Check if it's an action.yml or action.yaml file
filename := filepath.Base(path)
if filename != "action.yml" && filename != "action.yaml" {
if filename != appconstants.ActionFileNameYML && filename != appconstants.ActionFileNameYAML {
return os.ErrInvalid
}

View File

@@ -5,6 +5,7 @@ import (
"path/filepath"
"testing"
"github.com/ivuorinen/gh-action-readme/appconstants"
"github.com/ivuorinen/gh-action-readme/testutil"
)
@@ -21,10 +22,8 @@ func TestValidateActionYMLPath(t *testing.T) {
name: "valid action.yml file",
setupFunc: func(t *testing.T, tmpDir string) string {
t.Helper()
actionPath := filepath.Join(tmpDir, "action.yml")
testutil.WriteTestFile(t, actionPath, testutil.MustReadFixture("actions/javascript/simple.yml"))
return actionPath
return testutil.WriteActionFixture(t, tmpDir, appconstants.TestFixtureJavaScriptSimple)
},
expectError: false,
},
@@ -32,10 +31,8 @@ func TestValidateActionYMLPath(t *testing.T) {
name: "valid action.yaml file",
setupFunc: func(t *testing.T, tmpDir string) string {
t.Helper()
actionPath := filepath.Join(tmpDir, "action.yaml")
testutil.WriteTestFile(t, actionPath, testutil.MustReadFixture("minimal-action.yml"))
return actionPath
return testutil.WriteActionFixtureAs(t, tmpDir, "action.yaml", appconstants.TestFixtureMinimalAction)
},
expectError: false,
},
@@ -50,10 +47,8 @@ func TestValidateActionYMLPath(t *testing.T) {
name: "file with wrong extension",
setupFunc: func(t *testing.T, tmpDir string) string {
t.Helper()
actionPath := filepath.Join(tmpDir, "action.txt")
testutil.WriteTestFile(t, actionPath, testutil.MustReadFixture("actions/javascript/simple.yml"))
return actionPath
return testutil.WriteActionFixtureAs(t, tmpDir, "action.txt", appconstants.TestFixtureJavaScriptSimple)
},
expectError: true,
},
@@ -522,9 +517,7 @@ func TestGetBinaryDir(t *testing.T) {
}
// Verify the directory exists
if _, err := os.Stat(dir); os.IsNotExist(err) {
t.Errorf("binary directory does not exist: %s", dir)
}
testutil.AssertFileExists(t, dir)
}
func TestEnsureAbsolutePath(t *testing.T) {