Skip to content

Commit 7c6f729

Browse files
authored
fix dockerignore and tarball uploads for cloud agents (#673)
* fix dockerignore for projects without a dockerignore and loading an existing dockerignore * ensure we include the Dockerfile in the upload as it's required for the build * add tests for windows, mac and ubuntu * fix test log * update to toolchain version and set workflow perms * typo * remove test fmt for now, use path.Join with embedded fs instead of filepath.Join * add back test fmt * fix gotestfmt * remove gotestfmt since it's panicing on some output * bump version
1 parent cb33eeb commit 7c6f729

File tree

10 files changed

+602
-117
lines changed

10 files changed

+602
-117
lines changed

.github/workflows/test.yaml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Go Test
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
strategy:
12+
matrix:
13+
os: [ubuntu-latest, macos-latest, windows-latest]
14+
15+
runs-on: ${{ matrix.os }}
16+
17+
permissions:
18+
contents: read
19+
packages: read
20+
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- name: Set up Go
25+
uses: actions/setup-go@v4
26+
with:
27+
go-version: "1.25"
28+
cache: true
29+
30+
- name: Download Go modules
31+
run: go mod download
32+
33+
- name: Static Check
34+
uses: dominikh/staticcheck-action@v1
35+
with:
36+
checks: '["all", "-ST1000", "-ST1003", "-ST1016", "-ST1020", "-ST1021", "-ST1022", "-SA1019"]'
37+
version: "latest"
38+
install-go: false
39+
40+
- name: Test
41+
shell: bash
42+
run: |
43+
set -euo pipefail
44+
go test -race -json -v ./... 2>&1 | tee test.log
45+
46+
- name: Upload test log
47+
uses: actions/upload-artifact@v4
48+
if: always()
49+
with:
50+
name: test-log-${{ matrix.os }}
51+
path: test.log
52+
if-no-files-found: warn

cmd/lk/agent.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ func createAgent(ctx context.Context, cmd *cli.Command) error {
432432
return err
433433
}
434434

435-
err = agentfs.UploadTarball(workingDir, resp.PresignedUrl, []string{config.LiveKitTOMLFile})
435+
err = agentfs.UploadTarball(workingDir, resp.PresignedUrl, []string{fmt.Sprintf("**/%s", config.LiveKitTOMLFile)}, projectType)
436436
if err != nil {
437437
return err
438438
}
@@ -595,7 +595,7 @@ func deployAgent(ctx context.Context, cmd *cli.Command) error {
595595
}
596596

597597
presignedUrl := resp.PresignedUrl
598-
err = agentfs.UploadTarball(workingDir, presignedUrl, []string{config.LiveKitTOMLFile})
598+
err = agentfs.UploadTarball(workingDir, presignedUrl, []string{fmt.Sprintf("**/%s", config.LiveKitTOMLFile)}, projectType)
599599
if err != nil {
600600
return err
601601
}

pkg/agentfs/docker.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ func GenerateDockerArtifacts(dir string, projectType ProjectType, settingsMap ma
7373
return nil, nil, fmt.Errorf("unable to fetch client settings from server, please try again later")
7474
}
7575

76-
dockerfileContent, err := fs.ReadFile("examples/" + string(projectType) + ".Dockerfile")
76+
dockerfileContent, err := fs.ReadFile(filepath.Join("examples", string(projectType)+".Dockerfile"))
7777
if err != nil {
7878
return nil, nil, err
7979
}
8080

81-
dockerIgnoreContent, err := fs.ReadFile("examples/" + string(projectType) + ".dockerignore")
81+
dockerIgnoreContent, err := fs.ReadFile(filepath.Join("examples", string(projectType)+".dockerignore"))
8282
if err != nil {
8383
return nil, nil, err
8484
}

pkg/agentfs/docker_test.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
package agentfs
22

33
import (
4+
"path"
45
"testing"
56
)
67

78
func TestLoadDockerFiles(t *testing.T) {
89
expectedFiles := []string{
9-
"examples/node.Dockerfile",
10-
"examples/node.dockerignore",
11-
"examples/python.pip.Dockerfile",
12-
"examples/python.pip.dockerignore",
13-
"examples/python.uv.Dockerfile",
14-
"examples/python.uv.dockerignore",
10+
path.Join("examples", "node.Dockerfile"),
11+
path.Join("examples", "node.dockerignore"),
12+
path.Join("examples", "python.pip.Dockerfile"),
13+
path.Join("examples", "python.pip.dockerignore"),
14+
path.Join("examples", "python.uv.Dockerfile"),
15+
path.Join("examples", "python.uv.dockerignore"),
1516
}
1617

1718
for _, file := range expectedFiles {

pkg/agentfs/examples/node.dockerignore

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
# Node.js dependencies
2-
node_modules
3-
npm-debug.log
4-
yarn-error.log
5-
pnpm-debug.log
2+
**/node_modules
3+
**/npm-debug.log
4+
**/yarn-error.log
5+
**/pnpm-debug.log
66

77
# Build outputs
8-
dist
9-
build
10-
coverage
8+
**/dist
9+
**/build
10+
**/coverage
1111

1212
# Local environment & config files
13-
.env
14-
.env.local
13+
**/.env
14+
**/.env.local
1515
.DS_Store
1616

1717
# Logs & temp files
18-
*.log
19-
*.gz
20-
*.tgz
21-
.tmp
22-
.cache
18+
**/*.log
19+
**/*.gz
20+
**/*.tgz
21+
**/.tmp
22+
**/.cache
2323

2424
# Docker artifacts
2525
Dockerfile*
Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
# Python bytecode and artifacts
2-
__pycache__/
3-
*.py[cod]
4-
*.pyo
5-
*.pyd
6-
*.egg-info/
7-
dist/
8-
build/
2+
**/__pycache__/
3+
**/*.py[cod]
4+
**/*.pyo
5+
**/*.pyd
6+
**/*.egg-info/
7+
**/dist/
8+
**/build/
99

1010
# Virtual environments
11-
.venv/
12-
venv/
11+
**/.venv/
12+
**/venv/
1313

1414
# Caches and test output
15-
.cache/
16-
.pytest_cache/
17-
.ruff_cache/
18-
coverage/
15+
**/.cache/
16+
**/.pytest_cache/
17+
**/.ruff_cache/
18+
**/coverage/
1919

2020
# Logs and temp files
21-
*.log
22-
*.gz
23-
*.tgz
24-
.tmp
25-
.cache
21+
**/*.log
22+
**/*.gz
23+
**/*.tgz
24+
**/.tmp
25+
**/.cache
2626

2727
# Environment variables
28-
.env
29-
.env.*
28+
**/.env
29+
**/.env.*
3030

3131
# VCS, editor, OS
3232
.git
@@ -45,4 +45,4 @@ LICENSE
4545
test/
4646
tests/
4747
eval/
48-
evals/
48+
evals/
Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
# Python bytecode and artifacts
2-
__pycache__/
3-
*.py[cod]
4-
*.pyo
5-
*.pyd
6-
*.egg-info/
7-
dist/
8-
build/
2+
**/__pycache__/
3+
**/*.py[cod]
4+
**/*.pyo
5+
**/*.pyd
6+
**/*.egg-info/
7+
**/dist/
8+
**/build/
99

1010
# Virtual environments
11-
.venv/
12-
venv/
11+
**/.venv/
12+
**/venv/
1313

1414
# Caches and test output
15-
.cache/
16-
.pytest_cache/
17-
.ruff_cache/
18-
coverage/
15+
**/.cache/
16+
**/.pytest_cache/
17+
**/.ruff_cache/
18+
**/coverage/
1919

2020
# Logs and temp files
21-
*.log
22-
*.gz
23-
*.tgz
24-
.tmp
25-
.cache
21+
**/*.log
22+
**/*.gz
23+
**/*.tgz
24+
**/.tmp
25+
**/.cache
2626

2727
# Environment variables
28-
.env
29-
.env.*
28+
**/.env
29+
**/.env.*
3030

3131
# VCS, editor, OS
3232
.git
@@ -45,4 +45,4 @@ LICENSE
4545
test/
4646
tests/
4747
eval/
48-
evals/
48+
evals/

0 commit comments

Comments
 (0)