Skip to content

Commit faaf1e5

Browse files
authored
fix: package version parsing when loading from git (#648)
also fixed other tests, added unit tests as part of CI
1 parent 644db45 commit faaf1e5

File tree

6 files changed

+33
-3
lines changed

6 files changed

+33
-3
lines changed

.github/workflows/build.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,6 @@ jobs:
4646
with:
4747
version: "latest"
4848
install-go: false
49+
50+
- name: Run Go tests
51+
run: go test -v ./...

pkg/agentfs/docker_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ func TestLoadDockerFiles(t *testing.T) {
88
expectedFiles := []string{
99
"examples/node.Dockerfile",
1010
"examples/node.dockerignore",
11-
"examples/python.Dockerfile",
12-
"examples/python.dockerignore",
11+
"examples/python.pip.Dockerfile",
12+
"examples/python.pip.dockerignore",
13+
"examples/python.uv.Dockerfile",
14+
"examples/python.uv.dockerignore",
1315
}
1416

1517
for _, file := range expectedFiles {

pkg/agentfs/sdk_version_check.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,12 @@ func checkPackageInFile(filePath string, projectType ProjectType, pythonMinVersi
134134

135135
// parsePythonPackageVersion parses a Python package line and extracts the version
136136
func parsePythonPackageVersion(line string) (string, bool) {
137+
// Git URLs don't have traditional versions, so we treat them as "latest"
138+
gitPattern := regexp.MustCompile(`(?i)^livekit-agents(?:\[[^\]]+\])?\s*@\s*git\+`)
139+
if gitPattern.MatchString(line) {
140+
return "latest", true
141+
}
142+
137143
// match with optional extras and version specifiers
138144
pattern := regexp.MustCompile(`(?i)^livekit-agents(?:\[[^\]]+\])?\s*([=~><!]+)?\s*([^#]+)?`)
139145
matches := pattern.FindStringSubmatch(line)

pkg/agentfs/sdk_version_check_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,24 @@ func TestParsePythonPackageVersion(t *testing.T) {
425425
expectedOutput: "",
426426
expectedFound: false,
427427
},
428+
{
429+
name: "Git URL format",
430+
input: "livekit-agents[openai,turn-detector,silero,cartesia,deepgram] @ git+https://github.com/livekit/agents.git@load-debug#subdirectory=livekit-agents",
431+
expectedOutput: "latest",
432+
expectedFound: true,
433+
},
434+
{
435+
name: "Git URL format with extras",
436+
input: "livekit-agents[voice] @ git+https://github.com/livekit/agents.git@main",
437+
expectedOutput: "latest",
438+
expectedFound: true,
439+
},
440+
{
441+
name: "Git URL format simple",
442+
input: "livekit-agents @ git+https://github.com/livekit/agents.git",
443+
expectedOutput: "latest",
444+
expectedFound: true,
445+
},
428446
}
429447

430448
for _, tt := range tests {

pkg/agentfs/tar.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ var (
3737
".gitignore",
3838
".git",
3939
"node_modules",
40+
".env",
4041
".env.*",
4142
}
4243

pkg/loadtester/loadtest.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ func (t *LoadTest) Run(ctx context.Context) error {
179179
formatBitrate(s.bytes, s.elapsed),
180180
formatBitrate(s.bytes/int64(len(summaries)), s.elapsed),
181181
)
182-
summaryTable.Row("Total", fmt.Sprintf("%d/%d", s.tracks, s.expected), sBitrate, sDropped, string(s.errCount))
182+
summaryTable.Row("Total", fmt.Sprintf("%d/%d", s.tracks, s.expected), sBitrate, sDropped, strconv.FormatInt(s.errCount, 10))
183183
}
184184
fmt.Println("\nSubscriber summaries:")
185185
fmt.Println(summaryTable)

0 commit comments

Comments
 (0)