diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2f69cfd..31ebdb6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,23 +38,13 @@ jobs: - name: Verify dependencies run: go mod verify + + - name: Build binary + run: go build -v -o bin/git-get ./cmd/ + + - name: Run tests + run: go test -race ./... - - name: Set up Git (for tests) - run: | - git config --global user.email "test@example.com" - git config --global user.name "CI Test" - - - name: Run tests with coverage - run: go test -race -coverprofile coverage.out -covermode=atomic ./... - - - name: Upload coverage to Codecov - if: matrix.os == 'ubuntu-latest' && matrix.go-version == '1.24' - uses: codecov/codecov-action@v5 - with: - file: ./coverage.out - flags: unittests - name: codecov-umbrella - fail_ci_if_error: false lint: name: Lint @@ -104,37 +94,3 @@ jobs: with: sarif_file: 'trivy-results.sarif' - build: - name: Build - needs: [test, lint, security] - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v5 - with: - fetch-depth: 0 - - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: '1.24' - cache: true - - - name: Build binary - run: | - go build -v -o bin/git-get ./cmd/ - - - name: Test binary and symlink behavior - run: | - ./bin/git-get --version - # Test symlink functionality - ln -sf git-get bin/git-list - ./bin/git-list --version - - - name: Upload build artifacts - uses: actions/upload-artifact@v4 - with: - name: binary - path: bin/ - retention-days: 30 diff --git a/pkg/git/test/helpers.go b/pkg/git/test/helpers.go index e71077a..fdac6ac 100644 --- a/pkg/git/test/helpers.go +++ b/pkg/git/test/helpers.go @@ -31,6 +31,17 @@ func TempDir(t *testing.T, parent string) string { func (r *Repo) init() { err := run.Git("init", "--quiet", "--initial-branch=main", r.path).AndShutUp() checkFatal(r.t, err) + + r.setupGitConfig() +} + +// setupGitConfig sets up local git config for test repository only. +func (r *Repo) setupGitConfig() { + err := run.Git("config", "user.name", "Test User").OnRepo(r.path).AndShutUp() + checkFatal(r.t, err) + + err = run.Git("config", "user.email", "test@example.com").OnRepo(r.path).AndShutUp() + checkFatal(r.t, err) } // writeFile writes the content string into a file. If file doesn't exists, it will create it. @@ -50,7 +61,7 @@ func (r *Repo) stageFile(path string) { } func (r *Repo) commit(msg string) { - err := run.Git("commit", "-m", fmt.Sprintf("%q", msg), "--author=\"user \"").OnRepo(r.path).AndShutUp() + err := run.Git("commit", "-m", fmt.Sprintf("%q", msg)).OnRepo(r.path).AndShutUp() checkFatal(r.t, err) } @@ -81,6 +92,9 @@ func (r *Repo) clone() *Repo { t: r.t, } + // Set up git config in the cloned repository + clone.setupGitConfig() + return clone }