Skip to content

Commit a110a55

Browse files
authored
Merge pull request #4 from git-pkgs/add-ci
Add CI workflow
2 parents 6b5e451 + b739af1 commit a110a55

7 files changed

Lines changed: 59 additions & 9 deletions

File tree

.github/workflows/ci.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
go-version: ['1.25']
15+
16+
steps:
17+
- uses: actions/checkout@v6
18+
19+
- name: Set up Go
20+
uses: actions/setup-go@v6
21+
with:
22+
go-version: ${{ matrix.go-version }}
23+
24+
- name: Build
25+
run: go build -v ./...
26+
27+
- name: Test
28+
run: go test -v -race -coverprofile=coverage.out ./...
29+
30+
- name: Upload coverage
31+
if: matrix.go-version == '1.25'
32+
uses: codecov/codecov-action@v5
33+
with:
34+
files: coverage.out
35+
fail_ci_if_error: false
36+
37+
lint:
38+
runs-on: ubuntu-latest
39+
steps:
40+
- uses: actions/checkout@v6
41+
42+
- name: Set up Go
43+
uses: actions/setup-go@v6
44+
with:
45+
go-version: '1.25'
46+
47+
- name: golangci-lint
48+
uses: golangci/golangci-lint-action@v9
49+
with:
50+
version: latest

docs/examples/dependabot-cron/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ func updateDependency(ctx context.Context, tr *managers.Translator, managerName,
223223
if err := gitCommand(repoPath, "checkout", "-b", branchName); err != nil {
224224
return fmt.Errorf("creating branch: %w", err)
225225
}
226-
defer gitCommand(repoPath, "checkout", "-") // Return to original branch
226+
defer func() { _ = gitCommand(repoPath, "checkout", "-") }() // Return to original branch
227227

228228
// Build and run the update command
229229
cmd, err := tr.BuildCommand(managerName, "update", managers.CommandInput{

docs/examples/git-pkgs-integration/apply.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,10 @@ func ecosystemToManagerWithFallback(ecosystem, detected string) string {
208208
// getGitPkgsOutdated calls git-pkgs outdated --json and parses the output
209209
func getGitPkgsOutdated(repoPath, updateType string) ([]OutdatedPackage, error) {
210210
args := []string{"outdated", "--format", "json"}
211-
if updateType == "patch" {
211+
switch updateType {
212+
case "patch":
212213
// No filter needed, include all
213-
} else if updateType == "minor" {
214+
case "minor":
214215
args = append(args, "--minor") // Skip patch-only
215216
}
216217

docs/examples/git-pkgs-integration/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func applyUpdate(ctx context.Context, tr *managers.Translator, manager, repoPath
128128

129129
// runCommand executes a command in the specified directory
130130
func runCommand(ctx context.Context, args []string, dir string) error {
131-
ctx, cancel := context.WithTimeout(ctx, 5*time.Minute)
131+
_, cancel := context.WithTimeout(ctx, 5*time.Minute)
132132
defer cancel()
133133

134134
// In a real implementation, use os/exec

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module github.com/git-pkgs/managers
22

3-
go 1.25.0
3+
go 1.25.6
44

5-
require gopkg.in/yaml.v3 v3.0.1 // indirect
5+
require gopkg.in/yaml.v3 v3.0.1

go.sum

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
12
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
23
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
34
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

translator.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,7 @@ func (t *Translator) buildSingleCommand(binary string, cmd definitions.Command,
180180
}
181181

182182
// Add default flags
183-
for _, flagStr := range cmd.DefaultFlags {
184-
args = append(args, flagStr)
185-
}
183+
args = append(args, cmd.DefaultFlags...)
186184

187185
// Add user-specified flags
188186
for name, val := range input.Flags {

0 commit comments

Comments
 (0)