status
stringclasses 1
value | repo_name
stringclasses 31
values | repo_url
stringclasses 31
values | issue_id
int64 1
104k
| title
stringlengths 4
233
| body
stringlengths 0
186k
⌀ | issue_url
stringlengths 38
56
| pull_url
stringlengths 37
54
| before_fix_sha
stringlengths 40
40
| after_fix_sha
stringlengths 40
40
| report_datetime
unknown | language
stringclasses 5
values | commit_datetime
unknown | updated_file
stringlengths 7
188
| chunk_content
stringlengths 1
1.03M
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/integration/module_test.go | sdk string
source string
}
t.Run("basic", func(t *testing.T) {
t.Parallel()
for _, tc := range []testCase{
{
sdk: "go",
source: `package main
import (
"context"
)
func New(
ctx context.Context,
foo string,
bar *int, // +optional
baz []string,
dir *Directory,
) *Test {
bar2 := 42
if bar != nil {
bar2 = *bar
}
return &Test{ |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/integration/module_test.go | Foo: foo,
Bar: bar2,
Baz: baz,
Dir: dir,
}
}
type Test struct {
Foo string
Bar int
Baz []string
Dir *Directory
NeverSetDir *Directory
}
func (m *Test) GimmeFoo() string {
return m.Foo
}
func (m *Test) GimmeBar() int {
return m.Bar
}
func (m *Test) GimmeBaz() []string {
return m.Baz
}
func (m *Test) GimmeDirEnts(ctx context.Context) ([]string, error) {
return m.Dir.Entries(ctx)
}
`,
},
{
sdk: "python",
source: `import dagger |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/integration/module_test.go | from dagger import field, function, object_type
@object_type
class Test:
foo: str = field()
dir: dagger.Directory = field()
bar: int = field(default=42)
baz: list[str] = field(default=list)
never_set_dir: dagger.Directory | None = field(default=None)
@function
def gimme_foo(self) -> str:
return self.foo
@function
def gimme_bar(self) -> int:
return self.bar
@function
def gimme_baz(self) -> list[str]:
return self.baz
@function
async def gimme_dir_ents(self) -> list[str]:
return await self.dir.entries()
`,
},
{
sdk: "typescript",
source: `
import { Directory, object, func, field } from '@dagger.io/dagger';
@object()
class Test {
@field()
foo: string |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/integration/module_test.go | @field()
dir: Directory
@field()
bar: number
@field()
baz: string[]
@field()
neverSetDir?: Directory
constructor(foo: string, dir: Directory, bar = 42, baz: string[] = []) {
this.foo = foo;
this.dir = dir;
this.bar = bar;
this.baz = baz;
}
@func()
gimmeFoo(): string {
return this.foo;
}
@func()
gimmeBar(): number {
return this.bar;
}
@func()
gimmeBaz(): string[] {
return this.baz;
}
@func()
async gimmeDirEnts(): Promise<string[]> {
return this.dir.entries();
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/integration/module_test.go | }
`,
},
} {
tc := tc
t.Run(tc.sdk, func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
ctr := modInit(ctx, t, c, tc.sdk, tc.source)
out, err := ctr.With(daggerCall("--foo=abc", "--baz=x,y,z", "--dir=.", "foo")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, strings.TrimSpace(out), "abc")
out, err = ctr.With(daggerCall("--foo=abc", "--baz=x,y,z", "--dir=.", "gimme-foo")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, strings.TrimSpace(out), "abc")
out, err = ctr.With(daggerCall("--foo=abc", "--baz=x,y,z", "--dir=.", "bar")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, strings.TrimSpace(out), "42")
out, err = ctr.With(daggerCall("--foo=abc", "--baz=x,y,z", "--dir=.", "gimme-bar")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, strings.TrimSpace(out), "42")
out, err = ctr.With(daggerCall("--foo=abc", "--bar=123", "--baz=x,y,z", "--dir=.", "bar")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, strings.TrimSpace(out), "123")
out, err = ctr.With(daggerCall("--foo=abc", "--bar=123", "--baz=x,y,z", "--dir=.", "gimme-bar")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, strings.TrimSpace(out), "123")
out, err = ctr.With(daggerCall("--foo=abc", "--bar=123", "--baz=x,y,z", "--dir=.", "baz")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, strings.TrimSpace(out), "x\ny\nz") |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/integration/module_test.go | out, err = ctr.With(daggerCall("--foo=abc", "--bar=123", "--baz=x,y,z", "--dir=.", "gimme-baz")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, strings.TrimSpace(out), "x\ny\nz")
out, err = ctr.With(daggerCall("--foo=abc", "--bar=123", "--baz=x,y,z", "--dir=.", "gimme-dir-ents")).Stdout(ctx)
require.NoError(t, err)
require.Contains(t, strings.TrimSpace(out), "dagger.json")
})
}
})
t.Run("fields only", func(t *testing.T) {
t.Parallel()
for _, tc := range []testCase{
{
sdk: "go",
source: `package main
import (
"context"
)
func New(ctx context.Context) (Test, error) {
v, err := dag.Container().From("alpine:3.18.4").File("/etc/alpine-release").Contents(ctx)
if err != nil {
return Test{}, err
}
return Test{
AlpineVersion: v,
}, nil
}
type Test struct {
AlpineVersion string
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/integration/module_test.go | `,
},
{
sdk: "python",
source: `from dagger import dag, field, function, object_type
@object_type
class Test:
alpine_version: str = field()
@classmethod
async def create(cls) -> "Test":
return cls(alpine_version=await (
dag.container()
.from_("alpine:3.18.4")
.file("/etc/alpine-release")
.contents()
))
`,
},
{
sdk: "typescript",
source: `
import { dag, object, field } from "@dagger.io/dagger"
@object()
class Test {
@field()
alpineVersion: string
// NOTE: this is not standard to do async operations in the constructor.
// This is only for testing purpose but it shouldn't be done in real usage.
constructor() {
return (async () => { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/integration/module_test.go | this.alpineVersion = await dag.container().from("alpine:3.18.4").file("/etc/alpine-release").contents()
return this; // Return the newly-created instance
})();
}
}
`,
},
} {
tc := tc
t.Run(tc.sdk, func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
ctr := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work/test").
With(daggerExec("init", "--name=test", "--sdk="+tc.sdk)).
With(sdkSource(tc.sdk, tc.source))
out, err := ctr.With(daggerCall("alpine-version")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, strings.TrimSpace(out), "3.18.4")
})
}
})
t.Run("return error", func(t *testing.T) {
t.Parallel()
for _, tc := range []testCase{
{
sdk: "go",
source: `package main
import ( |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/integration/module_test.go | "fmt"
)
func New() (*Test, error) {
return nil, fmt.Errorf("too bad")
}
type Test struct {
Foo string
}
`,
},
{
sdk: "python",
source: `from dagger import object_type, field
@object_type
class Test:
foo: str = field()
def __init__(self):
raise ValueError("too bad")
`,
},
{
sdk: "typescript",
source: `
import { object, field } from "@dagger.io/dagger"
@object()
class Test {
@field()
foo: string
constructor() {
throw new Error("too bad") |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/integration/module_test.go | }
}
`,
},
} {
tc := tc
t.Run(tc.sdk, func(t *testing.T) {
t.Parallel()
var logs safeBuffer
c, ctx := connect(t, dagger.WithLogOutput(&logs))
ctr := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work/test").
With(daggerExec("init", "--name=test", "--sdk="+tc.sdk)).
With(sdkSource(tc.sdk, tc.source))
_, err := ctr.With(daggerCall("foo")).Stdout(ctx)
require.Error(t, err)
require.NoError(t, c.Close())
t.Log(logs.String())
require.Contains(t, logs.String(), "too bad")
})
}
})
t.Run("python: with default factory", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
content := identity.NewID()
ctr := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work/test"). |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/integration/module_test.go | With(daggerExec("init", "--name=test", "--sdk=python")).
With(sdkSource("python", fmt.Sprintf(`import dagger
from dagger import dag, object_type, field
@object_type
class Test:
foo: dagger.File = field(default=lambda: (
dag.directory()
.with_new_file("foo.txt", contents="%s")
.file("foo.txt")
))
bar: list[str] = field(default=list)
`, content),
))
out, err := ctr.With(daggerCall("foo", "contents")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, content, strings.TrimSpace(out))
out, err = ctr.With(daggerCall("--foo=dagger.json", "foo", "contents")).Stdout(ctx)
require.NoError(t, err)
require.Contains(t, out, `"sdk": "python"`)
_, err = ctr.With(daggerCall("bar")).Sync(ctx)
require.NoError(t, err)
})
t.Run("typescript: with default factory", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
content := identity.NewID()
ctr := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work/test").
With(daggerExec("init", "--name=test", "--sdk=typescript")). |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/integration/module_test.go | With(sdkSource("typescript", fmt.Sprintf(`
import { dag, File, object, field } from "@dagger.io/dagger"
@object()
class Test {
@field()
foo: File = dag.directory().withNewFile("foo.txt", "%s").file("foo.txt")
@field()
bar: string[] = []
// Allow foo to be set through the constructor
constructor(foo?: File) {
if (foo) {
this.foo = foo
}
}
}
`, content),
))
out, err := ctr.With(daggerCall("foo", "contents")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, content, strings.TrimSpace(out))
out, err = ctr.With(daggerCall("--foo=dagger.json", "foo", "contents")).Stdout(ctx)
require.NoError(t, err)
require.Contains(t, out, `"sdk": "typescript"`)
_, err = ctr.With(daggerCall("bar")).Sync(ctx)
require.NoError(t, err)
})
}
func TestModuleWrapping(t *testing.T) {
t.Parallel()
type testCase struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/integration/module_test.go | sdk string
source string
}
for _, tc := range []testCase{
{
sdk: "go",
source: `package main
type Wrapper struct{}
func (m *Wrapper) Container() *WrappedContainer {
return &WrappedContainer{
dag.Container().From("` + alpineImage + `"),
}
}
type WrappedContainer struct {
Unwrap *Container` + "`" + `json:"unwrap"` + "`" + `
}
func (c *WrappedContainer) Echo(msg string) *WrappedContainer {
return &WrappedContainer{
c.Unwrap.WithExec([]string{"echo", "-n", msg}),
}
}
`,
},
{
sdk: "python",
source: `from typing import Self
import dagger
from dagger import dag, field, function, object_type |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/integration/module_test.go | @object_type
class WrappedContainer:
unwrap: dagger.Container = field()
@function
def echo(self, msg: str) -> Self:
return WrappedContainer(unwrap=self.unwrap.with_exec(["echo", "-n", msg]))
@object_type
class Wrapper:
@function
def container(self) -> WrappedContainer:
return WrappedContainer(unwrap=dag.container().from_("` + alpineImage + `"))
`,
},
{
sdk: "typescript",
source: `
import { dag, Container, object, func, field } from "@dagger.io/dagger"
@object()
class WrappedContainer {
@field()
unwrap: Container
constructor(unwrap: Container) {
this.unwrap = unwrap
}
@func()
echo(msg: string): WrappedContainer {
return new WrappedContainer(this.unwrap.withExec(["echo", "-n", msg]))
}
}
@object() |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/integration/module_test.go | class Wrapper {
@func()
container(): WrappedContainer {
return new WrappedContainer(dag.container().from("` + alpineImage + `"))
}
}
`,
},
} {
tc := tc
t.Run(tc.sdk, func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--name=wrapper", "--sdk="+tc.sdk)).
With(sdkSource(tc.sdk, tc.source))
id := identity.NewID()
out, err := modGen.With(daggerQuery(
fmt.Sprintf(`{wrapper{container{echo(msg:%q){unwrap{stdout}}}}}`, id),
)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t,
fmt.Sprintf(`{"wrapper":{"container":{"echo":{"unwrap":{"stdout":%q}}}}}`, id),
out)
})
}
}
func TestModuleLotsOfFunctions(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/integration/module_test.go | t.Parallel()
const funcCount = 100
t.Run("go sdk", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
mainSrc := `
package main
type PotatoSack struct {}
`
for i := 0; i < funcCount; i++ {
mainSrc += fmt.Sprintf(`
func (m *PotatoSack) Potato%d() string {
return "potato #%d"
}
`, i, i)
}
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
WithNewFile("/work/main.go", dagger.ContainerWithNewFileOpts{
Contents: mainSrc,
}).
With(daggerExec("init", "--source=.", "--name=potatoSack", "--sdk=go"))
var eg errgroup.Group
for i := 0; i < funcCount; i++ {
i := i |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/integration/module_test.go | if i%10 != 0 {
continue
}
eg.Go(func() error {
_, err := modGen.
With(daggerCall(fmt.Sprintf("potato%d", i))).
Sync(ctx)
return err
})
}
require.NoError(t, eg.Wait())
})
t.Run("python sdk", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
mainSrc := `from dagger import function
`
for i := 0; i < funcCount; i++ {
mainSrc += fmt.Sprintf(`
@function
def potato_%d() -> str:
return "potato #%d"
`, i, i)
}
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
WithNewFile("./src/main.py", dagger.ContainerWithNewFileOpts{
Contents: mainSrc, |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/integration/module_test.go | }).
With(daggerExec("init", "--source=.", "--name=potatoSack", "--sdk=python"))
var eg errgroup.Group
for i := 0; i < funcCount; i++ {
i := i
if i%10 != 0 {
continue
}
eg.Go(func() error {
_, err := modGen.
With(daggerCall(fmt.Sprintf("potato%d", i))).
Sync(ctx)
return err
})
}
require.NoError(t, eg.Wait())
})
t.Run("typescript sdk", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
mainSrc := `
import { object, func } from "@dagger.io/dagger"
@object()
class PotatoSack {
`
for i := 0; i < funcCount; i++ {
mainSrc += fmt.Sprintf(`
@func()
potato_%d(): string { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/integration/module_test.go | return "potato #%d"
}
`, i, i)
}
mainSrc += "\n}"
modGen := c.
Container().
From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(sdkSource("typescript", mainSrc)).
With(daggerExec("init", "--name=potatoSack", "--sdk=typescript"))
var eg errgroup.Group
for i := 0; i < funcCount; i++ {
i := i
if i%10 != 0 {
continue
}
eg.Go(func() error {
_, err := modGen.
With(daggerCall(fmt.Sprintf("potato%d", i))).
Sync(ctx)
return err
})
}
require.NoError(t, eg.Wait())
})
}
func TestModuleLotsOfDeps(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/integration/module_test.go | t.Parallel()
c, ctx := connect(t)
modGen := goGitBase(t, c).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work")
modCount := 0
getModMainSrc := func(name string, depNames []string) string {
t.Helper()
mainSrc := fmt.Sprintf(`package main
import "context"
type %s struct {}
func (m *%s) Fn(ctx context.Context) (string, error) {
s := "%s"
var depS string
_ = depS
var err error
_ = err
`, strcase.ToCamel(name), strcase.ToCamel(name), name) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/integration/module_test.go | for _, depName := range depNames {
mainSrc += fmt.Sprintf(`
depS, err = dag.%s().Fn(ctx)
if err != nil {
return "", err
}
s += depS
`, strcase.ToCamel(depName))
}
mainSrc += "return s, nil\n}\n"
fmted, err := format.Source([]byte(mainSrc))
require.NoError(t, err)
return string(fmted)
}
var rootCfg modules.ModuleConfig
addModulesWithDeps := func(newMods int, depNames []string) []string {
t.Helper()
var newModNames []string
for i := 0; i < newMods; i++ {
name := fmt.Sprintf("mod%d", modCount)
modCount++
newModNames = append(newModNames, name)
modGen = modGen.
WithWorkdir("/work/"+name).
WithNewFile("./main.go", dagger.ContainerWithNewFileOpts{
Contents: getModMainSrc(name, depNames),
})
var depCfgs []*modules.ModuleConfigDependency |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/integration/module_test.go | for _, depName := range depNames {
depCfgs = append(depCfgs, &modules.ModuleConfigDependency{
Name: depName,
Source: filepath.Join("..", depName),
})
}
modGen = modGen.With(configFile(".", &modules.ModuleConfig{
Name: name,
SDK: "go",
Dependencies: depCfgs,
}))
}
return newModNames
}
curDeps := addModulesWithDeps(1, nil)
for i := 0; i < 6; i++ {
curDeps = addModulesWithDeps(len(curDeps)+1, curDeps)
}
addModulesWithDeps(1, curDeps)
modGen = modGen.With(configFile("..", &rootCfg))
_, err := modGen.With(daggerCall("fn")).Sync(ctx)
require.NoError(t, err)
}
func TestModuleNamespacing(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/integration/module_test.go | t.Parallel()
c, ctx := connect(t)
moduleSrcPath, err := filepath.Abs("./testdata/modules/go/namespacing")
require.NoError(t, err)
ctr := c.Container().From(alpineImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithMountedDirectory("/work", c.Host().Directory(moduleSrcPath)).
WithWorkdir("/work")
out, err := ctr.
With(daggerQuery(`{test{fn(s:"yo")}}`)).
Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"test":{"fn":["*dagger.Sub1Obj made 1:yo", "*dagger.Sub2Obj made 2:yo"]}}`, out)
}
func TestModuleLoops(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/integration/module_test.go | t.Parallel()
c, ctx := connect(t)
_, err := goGitBase(t, c).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
With(daggerExec("init", "--name=depA", "--sdk=go", "depA")).
With(daggerExec("init", "--name=depB", "--sdk=go", "depB")).
With(daggerExec("init", "--name=depC", "--sdk=go", "depC")).
With(daggerExec("install", "-m=depC", "./depB")).
With(daggerExec("install", "-m=depB", "./depA")).
With(daggerExec("install", "-m=depA", "./depC")).
Sync(ctx)
require.ErrorContains(t, err, `local module at "/work/depA" has a circular dependency`)
}
var badIDArgGoSrc string
var badIDArgPySrc string
var badIDArgTSSrc string
var badIDFieldGoSrc string
var badIDFieldTSSrc string
var badIDFnGoSrc string
var badIDFnPySrc string
var badIDFnTSSrc string
func TestModuleReservedWords(t *testing.T) {
t.Parallel()
type testCase struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/integration/module_test.go | sdk string
source string
}
t.Run("id", func(t *testing.T) {
t.Parallel()
t.Run("arg", func(t *testing.T) {
t.Parallel()
for _, tc := range []testCase{
{
sdk: "go",
source: badIDArgGoSrc,
},
{
sdk: "python",
source: badIDArgPySrc,
},
{
sdk: "typescript",
source: badIDArgTSSrc,
},
} {
tc := tc |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/integration/module_test.go | t.Run(tc.sdk, func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
_, err := modInit(ctx, t, c, tc.sdk, tc.source).
With(daggerQuery(`{test{fn(id:"no")}}`)).
Sync(ctx)
require.ErrorContains(t, err, "cannot define argument with reserved name \"id\"")
})
}
})
t.Run("field", func(t *testing.T) {
t.Parallel()
for _, tc := range []testCase{
{
sdk: "go",
source: badIDFieldGoSrc,
},
{
sdk: "typescript",
source: badIDFieldTSSrc,
},
} {
tc := tc
t.Run(tc.sdk, func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
_, err := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--name=test", "--sdk="+tc.sdk)). |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/integration/module_test.go | With(sdkSource(tc.sdk, tc.source)).
With(daggerQuery(`{test{fn{id}}}`)).
Sync(ctx)
require.ErrorContains(t, err, "cannot define field with reserved name \"id\"")
})
}
})
t.Run("fn", func(t *testing.T) {
t.Parallel()
for _, tc := range []testCase{
{
sdk: "go",
source: badIDFnGoSrc,
},
{
sdk: "python",
source: badIDFnPySrc,
},
{
sdk: "typescript",
source: badIDFnTSSrc,
},
} {
tc := tc
t.Run(tc.sdk, func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
_, err := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work"). |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/integration/module_test.go | With(daggerExec("init", "--name=test", "--sdk="+tc.sdk)).
With(sdkSource(tc.sdk, tc.source)).
With(daggerQuery(`{test{id}}`)).
Sync(ctx)
require.ErrorContains(t, err, "cannot define function with reserved name \"id\"")
})
}
})
})
}
func TestModuleExecError(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(alpineImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--source=.", "--name=playground", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `
package main
import (
"context"
"errors"
)
type Playground struct{}
func (p *Playground) DoThing(ctx context.Context) error {
_, err := dag.Container().From("` + alpineImage + `").WithExec([]string{"sh", "-c", "exit 5"}).Sync(ctx)
var e *ExecError
if errors.As(err, &e) {
if e.ExitCode == 5 { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/integration/module_test.go | return nil
}
}
panic("yikes")
}
`})
_, err := modGen.
With(daggerQuery(`{playground{doThing}}`)).
Stdout(ctx)
require.NoError(t, err)
}
func TestModuleCurrentModuleAPI(t *testing.T) {
t.Parallel()
t.Run("name", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
out, err := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--source=.", "--name=WaCkY", "--sdk=go")).
WithNewFile("/work/main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import "context"
type WaCkY struct {}
func (m *WaCkY) Fn(ctx context.Context) (string, error) {
return dag.CurrentModule().Name(ctx)
}
`,
}).
With(daggerCall("fn")). |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/integration/module_test.go | Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "WaCkY", strings.TrimSpace(out))
})
t.Run("source", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
out, err := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--source=.", "--name=test", "--sdk=go")).
WithNewFile("/work/subdir/coolfile.txt", dagger.ContainerWithNewFileOpts{
Contents: "nice",
}).
WithNewFile("/work/main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import "context"
type Test struct {}
func (m *Test) Fn(ctx context.Context) *File {
return dag.CurrentModule().Source().File("subdir/coolfile.txt")
}
`,
}).
With(daggerCall("fn", "contents")).
Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "nice", strings.TrimSpace(out))
})
t.Run("workdir", func(t *testing.T) {
t.Parallel() |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/integration/module_test.go | t.Run("dir", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
out, err := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--source=.", "--name=test", "--sdk=go")).
WithNewFile("/work/main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import (
"context"
"os"
)
type Test struct {}
func (m *Test) Fn(ctx context.Context) (*Directory, error) {
if err := os.MkdirAll("subdir/moresubdir", 0755); err != nil {
return nil, err
}
if err := os.WriteFile("subdir/moresubdir/coolfile.txt", []byte("nice"), 0644); err != nil {
return nil, err
}
return dag.CurrentModule().Workdir("subdir/moresubdir"), nil
}
`,
}).
With(daggerCall("fn", "file", "--path=coolfile.txt", "contents")).
Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "nice", strings.TrimSpace(out))
}) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/integration/module_test.go | t.Run("file", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
out, err := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--source=.", "--name=test", "--sdk=go")).
WithNewFile("/work/main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import (
"context"
"os"
)
type Test struct {}
func (m *Test) Fn(ctx context.Context) (*File, error) {
if err := os.MkdirAll("subdir/moresubdir", 0755); err != nil {
return nil, err
}
if err := os.WriteFile("subdir/moresubdir/coolfile.txt", []byte("nice"), 0644); err != nil {
return nil, err
}
return dag.CurrentModule().WorkdirFile("subdir/moresubdir/coolfile.txt"), nil
}
`,
}).
With(daggerCall("fn", "contents")).
Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "nice", strings.TrimSpace(out))
}) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/integration/module_test.go | t.Run("error on escape", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
ctr := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--source=.", "--name=test", "--sdk=go")).
WithNewFile("/work/main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import (
"context"
"os"
)
func New() (*Test, error) {
if err := os.WriteFile("/rootfile.txt", []byte("notnice"), 0644); err != nil {
return nil, err
}
if err := os.MkdirAll("/foo", 0755); err != nil {
return nil, err
}
if err := os.WriteFile("/foo/foofile.txt", []byte("notnice"), 0644); err != nil {
return nil, err
}
return &Test{}, nil
}
type Test struct {}
func (m *Test) EscapeFile(ctx context.Context) *File {
return dag.CurrentModule().WorkdirFile("../rootfile.txt")
}
func (m *Test) EscapeFileAbs(ctx context.Context) *File { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/integration/module_test.go | return dag.CurrentModule().WorkdirFile("/rootfile.txt")
}
func (m *Test) EscapeDir(ctx context.Context) *Directory {
return dag.CurrentModule().Workdir("../foo")
}
func (m *Test) EscapeDirAbs(ctx context.Context) *Directory {
return dag.CurrentModule().Workdir("/foo")
}
`,
})
_, err := ctr.
With(daggerCall("escape-file", "contents")).
Stdout(ctx)
require.ErrorContains(t, err, `workdir path "../rootfile.txt" escapes workdir`)
_, err = ctr.
With(daggerCall("escape-file-abs", "contents")).
Stdout(ctx)
require.ErrorContains(t, err, `workdir path "/rootfile.txt" escapes workdir`)
_, err = ctr.
With(daggerCall("escape-dir", "entries")).
Stdout(ctx)
require.ErrorContains(t, err, `workdir path "../foo" escapes workdir`)
_, err = ctr.
With(daggerCall("escape-dir-abs", "entries")).
Stdout(ctx)
require.ErrorContains(t, err, `workdir path "/foo" escapes workdir`)
})
})
}
func TestModuleCustomSDK(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/integration/module_test.go | t.Parallel()
c, ctx := connect(t)
ctr := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work/coolsdk").
With(daggerExec("init", "--source=.", "--name=cool-sdk", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
type CoolSdk struct {}
func (m *CoolSdk) ModuleRuntime(modSource *ModuleSource, introspectionJson string) *Container {
return modSource.WithSDK("go").AsModule().Runtime().WithEnvVariable("COOL", "true")
}
func (m *CoolSdk) Codegen(modSource *ModuleSource, introspectionJson string) *GeneratedCode {
return dag.GeneratedCode(modSource.WithSDK("go").AsModule().GeneratedContextDirectory())
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/integration/module_test.go | func (m *CoolSdk) RequiredPaths() []string {
return []string{
"**/go.mod",
"**/go.sum",
"**/go.work",
"**/go.work.sum",
"**/vendor/",
"**/*.go",
}
}
`,
}).
WithWorkdir("/work").
With(daggerExec("init", "--source=.", "--name=test", "--sdk=coolsdk")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import "os"
type Test struct {}
func (m *Test) Fn() string {
return os.Getenv("COOL")
}
`,
})
out, err := ctr.
With(daggerCall("fn")).
Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "true", strings.TrimSpace(out))
}
func TestModuleHostError(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/integration/module_test.go | t.Parallel()
c, ctx := connect(t)
_, err := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--source=.", "--name=test", "--sdk=go")).
WithNewFile("/work/main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import (
"context"
)
type Test struct {}
func (m *Test) Fn(ctx context.Context) *Directory {
return dag.Host().Directory(".")
}
`,
}).
With(daggerCall("fn")).
Sync(ctx)
require.ErrorContains(t, err, "dag.Host undefined")
}
func daggerExec(args ...string) dagger.WithContainerFunc { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/integration/module_test.go | return func(c *dagger.Container) *dagger.Container {
return c.WithExec(append([]string{"dagger", "--debug"}, args...), dagger.ContainerWithExecOpts{
ExperimentalPrivilegedNesting: true,
})
}
}
func daggerQuery(query string, args ...any) dagger.WithContainerFunc {
return daggerQueryAt("", query, args...)
}
func daggerQueryAt(modPath string, query string, args ...any) dagger.WithContainerFunc {
query = fmt.Sprintf(query, args...)
return func(c *dagger.Container) *dagger.Container {
execArgs := []string{"dagger", "--debug", "query"}
if modPath != "" {
execArgs = append(execArgs, "-m", modPath)
}
return c.WithExec(execArgs, dagger.ContainerWithExecOpts{
Stdin: query,
ExperimentalPrivilegedNesting: true,
})
}
}
func daggerCall(args ...string) dagger.WithContainerFunc {
return daggerCallAt("", args...)
}
func daggerCallAt(modPath string, args ...string) dagger.WithContainerFunc { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/integration/module_test.go | return func(c *dagger.Container) *dagger.Container {
execArgs := []string{"dagger", "--debug", "call"}
if modPath != "" {
execArgs = append(execArgs, "-m", modPath)
}
return c.WithExec(append(execArgs, args...), dagger.ContainerWithExecOpts{
ExperimentalPrivilegedNesting: true,
})
}
}
func daggerFunctions(args ...string) dagger.WithContainerFunc {
return func(c *dagger.Container) *dagger.Container {
return c.WithExec(append([]string{"dagger", "--debug", "functions"}, args...), dagger.ContainerWithExecOpts{
ExperimentalPrivilegedNesting: true,
})
}
}
func configFile(dirPath string, cfg *modules.ModuleConfig) dagger.WithContainerFunc {
return func(c *dagger.Container) *dagger.Container {
cfgPath := filepath.Join(dirPath, "dagger.json")
cfgBytes, err := json.Marshal(cfg)
if err != nil {
panic(err)
}
return c.WithNewFile(cfgPath, dagger.ContainerWithNewFileOpts{
Contents: string(cfgBytes),
})
}
}
func hostDaggerCommand(ctx context.Context, t testing.TB, workdir string, args ...string) *exec.Cmd { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/integration/module_test.go | t.Helper()
cmd := exec.CommandContext(ctx, daggerCliPath(t), args...)
cmd.Dir = workdir
return cmd
}
func hostDaggerExec(ctx context.Context, t testing.TB, workdir string, args ...string) ([]byte, error) {
t.Helper()
cmd := hostDaggerCommand(ctx, t, workdir, args...)
output, err := cmd.CombinedOutput()
if err != nil {
err = fmt.Errorf("%s: %w", string(output), err)
}
return output, err
}
func sdkSource(sdk, contents string) dagger.WithContainerFunc {
return func(c *dagger.Container) *dagger.Container {
sourcePath := sdkSourceFile(sdk)
if sourcePath == "" {
return c
}
return c.WithNewFile(sourcePath, dagger.ContainerWithNewFileOpts{
Contents: heredoc.Doc(contents),
})
}
}
func sdkSourceFile(sdk string) string { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/integration/module_test.go | switch sdk {
case "go":
return "dagger/main.go"
case "python":
return "dagger/src/main.py"
case "typescript":
return "dagger/src/index.ts"
default:
return ""
}
}
func sdkCodegenFile(t *testing.T, sdk string) string {
t.Helper()
switch sdk {
case "go":
return "dagger/dagger/dagger.gen.go"
case "python":
return "dagger/sdk/src/dagger/client/gen.py"
case "typescript":
return "dagger/sdk/api/client.gen.ts"
default:
return ""
}
}
func modInit(ctx context.Context, t *testing.T, c *dagger.Client, sdk, contents string) *dagger.Container { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/integration/module_test.go | t.Helper()
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--name=test", "--sdk="+sdk)).
With(sdkSource(sdk, contents))
return modGen
}
func currentSchema(ctx context.Context, t *testing.T, ctr *dagger.Container) *introspection.Schema {
t.Helper()
out, err := ctr.With(daggerQuery(introspection.Query)).Stdout(ctx)
require.NoError(t, err)
var schemaResp introspection.Response
err = json.Unmarshal([]byte(out), &schemaResp)
require.NoError(t, err)
return schemaResp.Schema
}
var moduleIntrospection = daggerQuery(`
query { host { directory(path: ".") { asModule { initialize {
description |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/integration/module_test.go | objects {
asObject {
name
description
constructor {
description
args {
name
description
defaultValue
}
}
functions {
name
description
args {
name
description
defaultValue
}
}
fields {
name
description
}
}
}
} } } } }
`)
func inspectModule(ctx context.Context, t *testing.T, ctr *dagger.Container) gjson.Result { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/integration/module_test.go | t.Helper()
out, err := ctr.With(moduleIntrospection).Stdout(ctx)
require.NoError(t, err)
result := gjson.Get(out, "host.directory.asModule.initialize")
t.Logf("module introspection:\n%v", result.Raw)
return result
}
func inspectModuleObjects(ctx context.Context, t *testing.T, ctr *dagger.Container) gjson.Result {
t.Helper()
return inspectModule(ctx, t, ctr).Get("objects.#.asObject")
}
func goGitBase(t *testing.T, c *dagger.Client) *dagger.Container {
t.Helper()
return c.Container().From(golangImage).
WithExec([]string{"apk", "add", "git"}).
WithExec([]string{"git", "config", "--global", "user.email", "[email protected]"}).
WithExec([]string{"git", "config", "--global", "user.name", "Dagger Tests"}).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
WithExec([]string{"git", "init"})
}
func logGen(ctx context.Context, t *testing.T, modSrc *dagger.Directory) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/integration/module_test.go | t.Helper()
generated, err := modSrc.File("dagger.gen.go").Contents(ctx)
require.NoError(t, err)
t.Cleanup(func() {
t.Name()
fileName := filepath.Join(
os.TempDir(),
t.Name(),
fmt.Sprintf("dagger.gen.%d.go", time.Now().Unix()),
)
if err := os.MkdirAll(filepath.Dir(fileName), 0o755); err != nil {
t.Logf("failed to create temp dir for generated code: %v", err)
return
}
if err := os.WriteFile(fileName, []byte(generated), 0644); err != nil {
t.Logf("failed to write generated code to %s: %v", fileName, err)
} else {
t.Logf("wrote generated code to %s", fileName)
}
})
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/modulesource.go | package core
import (
"context"
"encoding/json"
"fmt" |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/modulesource.go | "path/filepath"
"strings"
"github.com/dagger/dagger/core/modules"
"github.com/dagger/dagger/dagql"
"github.com/dagger/dagger/dagql/idproto"
"github.com/moby/buildkit/solver/pb"
"github.com/vektah/gqlparser/v2/ast"
)
type ModuleSourceKind string
var ModuleSourceKindEnum = dagql.NewEnum[ModuleSourceKind]()
var (
ModuleSourceKindLocal = ModuleSourceKindEnum.Register("LOCAL_SOURCE")
ModuleSourceKindGit = ModuleSourceKindEnum.Register("GIT_SOURCE")
)
func (proto ModuleSourceKind) Type() *ast.Type {
return &ast.Type{
NamedType: "ModuleSourceKind",
NonNull: true,
}
}
func (proto ModuleSourceKind) TypeDescription() string {
return "The kind of module source."
}
func (proto ModuleSourceKind) Decoder() dagql.InputDecoder {
return ModuleSourceKindEnum
}
func (proto ModuleSourceKind) ToLiteral() *idproto.Literal {
return ModuleSourceKindEnum.Literal(proto)
}
type ModuleSource struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/modulesource.go | Query *Query
Kind ModuleSourceKind `field:"true" name:"kind" doc:"The kind of source (e.g. local, git, etc.)"`
AsLocalSource dagql.Nullable[*LocalModuleSource] `field:"true" doc:"If the source is of kind local, the local source representation of it."`
AsGitSource dagql.Nullable[*GitModuleSource] `field:"true" doc:"If the source is a of kind git, the git source representation of it."`
WithName string
WithDependencies []dagql.Instance[*ModuleDependency]
WithSDK string
WithSourceSubpath string
}
func (src *ModuleSource) Type() *ast.Type {
return &ast.Type{
NamedType: "ModuleSource",
NonNull: true,
}
}
func (src *ModuleSource) TypeDescription() string {
return "The source needed to load and run a module, along with any metadata about the source such as versions/urls/etc."
}
func (src ModuleSource) Clone() *ModuleSource {
cp := src
if src.Query != nil {
cp.Query = src.Query.Clone()
}
if src.AsLocalSource.Valid {
cp.AsLocalSource.Value = src.AsLocalSource.Value.Clone()
}
if src.AsGitSource.Valid {
cp.AsGitSource.Value = src.AsGitSource.Value.Clone() |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/modulesource.go | }
if src.WithDependencies != nil {
cp.WithDependencies = make([]dagql.Instance[*ModuleDependency], len(src.WithDependencies))
copy(cp.WithDependencies, src.WithDependencies)
}
return &cp
}
func (src *ModuleSource) PBDefinitions(ctx context.Context) ([]*pb.Definition, error) {
switch src.Kind {
case ModuleSourceKindLocal:
return src.AsLocalSource.Value.PBDefinitions(ctx)
case ModuleSourceKindGit:
return src.AsGitSource.Value.PBDefinitions(ctx)
default:
return nil, fmt.Errorf("unknown module src kind: %q", src.Kind)
}
}
func (src *ModuleSource) RefString() (string, error) {
switch src.Kind {
case ModuleSourceKindLocal:
return src.AsLocalSource.Value.RefString(), nil
case ModuleSourceKindGit:
return src.AsGitSource.Value.RefString(), nil
default:
return "", fmt.Errorf("unknown module src kind: %q", src.Kind)
}
}
func (src *ModuleSource) Symbolic() (string, error) {
switch src.Kind {
case ModuleSourceKindLocal: |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/modulesource.go | return src.AsLocalSource.Value.Symbolic(), nil
case ModuleSourceKindGit:
return src.AsGitSource.Value.Symbolic(), nil
default:
return "", fmt.Errorf("unknown module src kind: %q", src.Kind)
}
}
func (src *ModuleSource) SourceRootSubpath() (string, error) {
switch src.Kind {
case ModuleSourceKindLocal:
return src.AsLocalSource.Value.RootSubpath, nil
case ModuleSourceKindGit:
return src.AsGitSource.Value.RootSubpath, nil
default:
return "", fmt.Errorf("unknown module src kind: %q", src.Kind)
}
}
func (src *ModuleSource) SourceSubpath(ctx context.Context) (string, error) {
rootSubpath, err := src.SourceRootSubpath()
if err != nil {
return "", fmt.Errorf("failed to get source root subpath: %w", err)
}
if src.WithSourceSubpath != "" {
return filepath.Join(rootSubpath, src.WithSourceSubpath), nil
}
cfg, ok, err := src.ModuleConfig(ctx)
if err != nil {
return "", fmt.Errorf("module config: %w", err)
}
if !ok { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/modulesource.go | return "", nil
}
if cfg.Source == "" {
return "", nil
}
return filepath.Join(rootSubpath, cfg.Source), nil
}
func (src *ModuleSource) SourceSubpathWithDefault(ctx context.Context) (string, error) {
sourceSubpath, err := src.SourceSubpath(ctx)
if err != nil {
return "", fmt.Errorf("source subpath: %w", err)
}
if sourceSubpath == "" {
return src.SourceRootSubpath()
}
return sourceSubpath, nil
}
func (src *ModuleSource) ModuleName(ctx context.Context) (string, error) {
if src.WithName != "" {
return src.WithName, nil
}
cfg, ok, err := src.ModuleConfig(ctx)
if err != nil {
return "", fmt.Errorf("module config: %w", err)
}
if !ok {
return "", nil
}
return cfg.Name, nil |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/modulesource.go | }
func (src *ModuleSource) ModuleOriginalName(ctx context.Context) (string, error) {
cfg, ok, err := src.ModuleConfig(ctx)
if err != nil {
return "", fmt.Errorf("module config: %w", err)
}
if !ok || cfg.Name == "" {
return src.WithName, nil
}
return cfg.Name, nil
}
func (src *ModuleSource) SDK(ctx context.Context) (string, error) {
if src.WithSDK != "" {
return src.WithSDK, nil
}
modCfg, ok, err := src.ModuleConfig(ctx)
if err != nil {
return "", fmt.Errorf("module config: %w", err)
}
if !ok {
return "", nil
}
return modCfg.SDK, nil
}
func (src *ModuleSource) ContextDirectory() (inst dagql.Instance[*Directory], err error) {
switch src.Kind {
case ModuleSourceKindLocal:
if !src.AsLocalSource.Valid { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/modulesource.go | return inst, fmt.Errorf("local src not set")
}
return src.AsLocalSource.Value.ContextDirectory, nil
case ModuleSourceKindGit:
if !src.AsGitSource.Valid {
return inst, fmt.Errorf("git src not set")
}
return src.AsGitSource.Value.ContextDirectory, nil
default:
return inst, fmt.Errorf("unknown module src kind: %q", src.Kind)
}
}
func (src *ModuleSource) ModuleConfig(ctx context.Context) (*modules.ModuleConfig, bool, error) {
contextDir, err := src.ContextDirectory()
if err != nil {
return nil, false, fmt.Errorf("failed to get context directory: %w", err)
}
if contextDir.Self == nil {
return nil, false, nil
}
rootSubpath, err := src.SourceRootSubpath()
if err != nil {
return nil, false, fmt.Errorf("failed to get source root subpath: %w", err)
}
var modCfg modules.ModuleConfig
configFile, err := contextDir.Self.File(ctx, filepath.Join(rootSubpath, modules.Filename))
if err != nil {
return nil, false, nil
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/modulesource.go | configBytes, err := configFile.Contents(ctx)
if err != nil {
return nil, false, fmt.Errorf("failed to read module config file: %w", err)
}
if err := json.Unmarshal(configBytes, &modCfg); err != nil {
return nil, false, fmt.Errorf("failed to decode module config: %w", err)
}
return &modCfg, true, nil
}
type LocalModuleSource struct {
RootSubpath string `field:"true" doc:"The path to the root of the module source under the context directory. This directory contains its configuration file. It also contains its source code (possibly as a subdirectory)."`
ContextDirectory dagql.Instance[*Directory] `field:"true" doc:"The directory containing everything needed to load load and use the module."`
}
func (src *LocalModuleSource) Type() *ast.Type {
return &ast.Type{
NamedType: "LocalModuleSource",
NonNull: true,
}
}
func (src *LocalModuleSource) TypeDescription() string {
return "Module source that that originates from a path locally relative to an arbitrary directory."
}
func (src LocalModuleSource) Clone() *LocalModuleSource {
cp := src
if src.ContextDirectory.Self != nil {
cp.ContextDirectory.Self = src.ContextDirectory.Self.Clone()
}
return &cp
}
func (src *LocalModuleSource) PBDefinitions(ctx context.Context) ([]*pb.Definition, error) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/modulesource.go | return src.ContextDirectory.Self.PBDefinitions(ctx)
}
func (src *LocalModuleSource) RefString() string {
srcPath := src.RootSubpath
if filepath.IsAbs(srcPath) {
srcPath = strings.TrimPrefix(filepath.Clean(srcPath), "/")
}
return srcPath
}
func (src *LocalModuleSource) Symbolic() string {
return src.RefString()
}
type GitModuleSource struct {
Version string `field:"true" doc:"The specified version of the git repo this source points to."`
Commit string `field:"true" doc:"The resolved commit of the git repo this source points to."`
URLParent string
RootSubpath string `field:"true" doc:"The path to the root of the module source under the context directory. This directory contains its configuration file. It also contains its source code (possibly as a subdirectory)."`
ContextDirectory dagql.Instance[*Directory] `field:"true" doc:"The directory containing everything needed to load load and use the module."`
}
func (src *GitModuleSource) Type() *ast.Type {
return &ast.Type{
NamedType: "GitModuleSource",
NonNull: true,
}
}
func (src *GitModuleSource) TypeDescription() string {
return "Module source originating from a git repo."
}
func (src GitModuleSource) Clone() *GitModuleSource {
cp := src |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/modulesource.go | if src.ContextDirectory.Self != nil {
cp.ContextDirectory.Self = src.ContextDirectory.Self.Clone()
}
return &src
}
func (src *GitModuleSource) PBDefinitions(ctx context.Context) ([]*pb.Definition, error) {
return src.ContextDirectory.Self.PBDefinitions(ctx)
}
func (src *GitModuleSource) RefString() string {
refPath := src.URLParent
subPath := filepath.Join("/", src.RootSubpath)
if subPath != "/" {
refPath += subPath
}
return fmt.Sprintf("%s@%s", refPath, src.Commit)
}
func (src *GitModuleSource) Symbolic() string {
return filepath.Join(src.CloneURL(), src.RootSubpath)
}
func (src *GitModuleSource) CloneURL() string {
return "https://" + src.URLParent
}
func (src *GitModuleSource) HTMLURL() string {
u := "https://" + src.URLParent + "/tree/" + src.Commit
if subPath := src.RootSubpath; subPath != "" {
u += "/" + subPath
}
return u
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/module.go | package schema
import (
"bytes"
"context"
"encoding/json"
"fmt"
"path/filepath"
"github.com/dagger/dagger/core"
"github.com/dagger/dagger/core/modules"
"github.com/dagger/dagger/dagql"
"github.com/dagger/dagger/engine"
"golang.org/x/sync/errgroup"
)
type moduleSchema struct {
dag *dagql.Server
}
var _ SchemaResolvers = &moduleSchema{}
func (s *moduleSchema) Install() {
dagql.Fields[*core.Query]{
dagql.Func("module", s.module).
Doc(`Create a new module.`),
dagql.Func("typeDef", s.typeDef).
Doc(`Create a new TypeDef.`),
dagql.Func("generatedCode", s.generatedCode).
Doc(`Create a code generation result, given a directory containing the generated code.`),
dagql.Func("moduleSource", s.moduleSource).
Doc(`Create a new module source instance from a source ref string.`). |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/module.go | ArgDoc("refString", `The string ref representation of the module source`).
ArgDoc("stable", `If true, enforce that the source is a stable version for source kinds that support versioning.`),
dagql.Func("moduleDependency", s.moduleDependency).
Doc(`Create a new module dependency configuration from a module source and name`).
ArgDoc("source", `The source of the dependency`).
ArgDoc("name", `If set, the name to use for the dependency. Otherwise, once installed to a parent module, the name of the dependency module will be used by default.`),
dagql.Func("function", s.function).
Doc(`Creates a function.`).
ArgDoc("name", `Name of the function, in its original format from the implementation language.`).
ArgDoc("returnType", `Return type of the function.`),
dagql.Func("currentModule", s.currentModule).
Impure(`Changes depending on which module is calling it.`).
Doc(`The module currently being served in the session, if any.`),
dagql.Func("currentTypeDefs", s.currentTypeDefs).
Impure(`Changes depending on which modules are currently installed.`).
Doc(`The TypeDef representations of the objects currently being served in the session.`),
dagql.Func("currentFunctionCall", s.currentFunctionCall).
Impure(`Changes depending on which function calls it.`).
Doc(`The FunctionCall context that the SDK caller is currently executing in.`,
`If the caller is not currently executing in a function, this will
return an error.`),
}.Install(s.dag)
dagql.Fields[*core.Directory]{
dagql.NodeFunc("asModule", s.directoryAsModule).
Doc(`Load the directory as a Dagger module`).
ArgDoc("sourceRootPath",
`An optional subpath of the directory which contains the module's configuration file.`,
`This is needed when the module code is in a subdirectory but requires
parent directories to be loaded in order to execute. For example, the
module source code may need a go.mod, project.toml, package.json, etc. |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/module.go | file from a parent directory.`,
`If not set, the module source code is loaded from the root of the directory.`),
}.Install(s.dag)
dagql.Fields[*core.FunctionCall]{
dagql.Func("returnValue", s.functionCallReturnValue).
Impure(`Updates internal engine state with the given value.`).
Doc(`Set the return value of the function call to the provided value.`).
ArgDoc("value", `JSON serialization of the return value.`),
}.Install(s.dag)
dagql.Fields[*core.ModuleSource]{
dagql.Func("contextDirectory", s.moduleSourceContextDirectory).
Doc(`The directory containing everything needed to load load and use the module.`),
dagql.Func("withContextDirectory", s.moduleSourceWithContextDirectory).
Doc(`Update the module source with a new context directory. Only valid for local sources.`).
ArgDoc("dir", `The directory to set as the context directory.`),
dagql.Func("directory", s.moduleSourceDirectory).
Doc(`The directory containing the module configuration and source code (source code may be in a subdir).`).
ArgDoc(`path`, `The path from the source directory to select.`),
dagql.Func("sourceRootSubpath", s.moduleSourceRootSubpath).
Doc(`The path relative to context of the root of the module source, which contains dagger.json. It also contains the module implementation source code, but that may or may not being a subdir of this root.`),
dagql.Func("sourceSubpath", s.moduleSourceSubpath).
Doc(`The path relative to context of the module implementation source code.`),
dagql.Func("withSourceSubpath", s.moduleSourceWithSourceSubpath).
Doc(`Update the module source with a new source subpath.`).
ArgDoc("path", `The path to set as the source subpath.`),
dagql.Func("moduleName", s.moduleSourceModuleName).
Doc(`If set, the name of the module this source references, including any overrides at runtime by callers.`),
dagql.Func("moduleOriginalName", s.moduleSourceModuleOriginalName).
Doc(`The original name of the module this source references, as defined in the module configuration.`),
dagql.Func("withName", s.moduleSourceWithName). |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/module.go | Doc(`Update the module source with a new name.`).
ArgDoc("name", `The name to set.`),
dagql.NodeFunc("dependencies", s.moduleSourceDependencies).
Doc(`The dependencies of the module source. Includes dependencies from the configuration and any extras from withDependencies calls.`),
dagql.Func("withDependencies", s.moduleSourceWithDependencies).
Doc(`Append the provided dependencies to the module source's dependency list.`).
ArgDoc("dependencies", `The dependencies to append.`),
dagql.Func("withSDK", s.moduleSourceWithSDK).
Doc(`Update the module source with a new SDK.`).
ArgDoc("sdk", `The SDK to set.`),
dagql.Func("configExists", s.moduleSourceConfigExists).
Doc(`Returns whether the module source has a configuration file.`),
dagql.Func("resolveDependency", s.moduleSourceResolveDependency).
Doc(`Resolve the provided module source arg as a dependency relative to this module source.`).
ArgDoc("dep", `The dependency module source to resolve.`),
dagql.Func("asString", s.moduleSourceAsString).
Doc(`A human readable ref string representation of this module source.`),
dagql.NodeFunc("asModule", s.moduleSourceAsModule).
Doc(`Load the source as a module. If this is a local source, the parent directory must have been provided during module source creation`),
dagql.Func("resolveFromCaller", s.moduleSourceResolveFromCaller).
Impure(`Loads live caller-specific data from their filesystem.`).
Doc(`Load the source from its path on the caller's filesystem, including only needed+configured files and directories. Only valid for local sources.`),
dagql.Func("resolveContextPathFromCaller", s.moduleSourceResolveContextPathFromCaller).
Impure(`Queries live caller-specific data from their filesystem.`).
Doc(`The path to the module source's context directory on the caller's filesystem. Only valid for local sources.`),
}.Install(s.dag)
dagql.Fields[*core.LocalModuleSource]{}.Install(s.dag)
dagql.Fields[*core.GitModuleSource]{
dagql.Func("cloneURL", s.gitModuleSourceCloneURL).
Doc(`The URL from which the source's git repo can be cloned.`), |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/module.go | dagql.Func("htmlURL", s.gitModuleSourceHTMLURL).
Doc(`The URL to the source's git repo in a web browser`),
}.Install(s.dag)
dagql.Fields[*core.ModuleDependency]{}.Install(s.dag)
dagql.Fields[*core.Module]{
dagql.Func("withSource", s.moduleWithSource).
Doc(`Retrieves the module with basic configuration loaded if present.`).
ArgDoc("source", `The module source to initialize from.`),
dagql.Func("generatedContextDiff", s.moduleGeneratedContextDiff).
Doc(`The generated files and directories made on top of the module source's context directory.`),
dagql.NodeFunc("initialize", s.moduleInitialize).
Doc(`Retrieves the module with the objects loaded via its SDK.`),
dagql.Func("withDescription", s.moduleWithDescription).
Doc(`Retrieves the module with the given description`).
ArgDoc("description", `The description to set`),
dagql.Func("withObject", s.moduleWithObject).
Doc(`This module plus the given Object type and associated functions.`),
dagql.Func("withInterface", s.moduleWithInterface).
Doc(`This module plus the given Interface type and associated functions`),
dagql.NodeFunc("serve", s.moduleServe).
Impure(`Mutates the calling session's global schema.`).
Doc(`Serve a module's API in the current session.`,
`Note: this can only be called once per session. In the future, it could return a stream or service to remove the side effect.`),
}.Install(s.dag)
dagql.Fields[*core.CurrentModule]{
dagql.Func("name", s.currentModuleName).
Doc(`The name of the module being executed in`),
dagql.Func("source", s.currentModuleSource).
Doc(`The directory containing the module's source code loaded into the engine (plus any generated code that may have been created).`),
dagql.Func("workdir", s.currentModuleWorkdir). |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/module.go | Impure(`Loads live caller-specific data from their filesystem.`).
Doc(`Load a directory from the module's scratch working directory, including any changes that may have been made to it during module function execution.`).
ArgDoc("path", `Location of the directory to access (e.g., ".").`).
ArgDoc("exclude", `Exclude artifacts that match the given pattern (e.g., ["node_modules/", ".git*"]).`).
ArgDoc("include", `Include only artifacts that match the given pattern (e.g., ["app/", "package.*"]).`),
dagql.Func("workdirFile", s.currentModuleWorkdirFile).
Impure(`Loads live caller-specific data from their filesystem.`).
Doc(`Load a file from the module's scratch working directory, including any changes that may have been made to it during module function execution.Load a file from the module's scratch working directory, including any changes that may have been made to it during module function execution.`).
ArgDoc("path", `Location of the file to retrieve (e.g., "README.md").`),
}.Install(s.dag)
dagql.Fields[*core.Function]{
dagql.Func("withDescription", s.functionWithDescription).
Doc(`Returns the function with the given doc string.`).
ArgDoc("description", `The doc string to set.`),
dagql.Func("withArg", s.functionWithArg).
Doc(`Returns the function with the provided argument`).
ArgDoc("name", `The name of the argument`).
ArgDoc("typeDef", `The type of the argument`).
ArgDoc("description", `A doc string for the argument, if any`).
ArgDoc("defaultValue", `A default value to use for this argument if not explicitly set by the caller, if any`),
}.Install(s.dag)
dagql.Fields[*core.FunctionArg]{}.Install(s.dag)
dagql.Fields[*core.FunctionCallArgValue]{}.Install(s.dag)
dagql.Fields[*core.TypeDef]{
dagql.Func("withOptional", s.typeDefWithOptional).
Doc(`Sets whether this type can be set to null.`),
dagql.Func("withKind", s.typeDefWithKind).
Doc(`Sets the kind of the type.`),
dagql.Func("withListOf", s.typeDefWithListOf).
Doc(`Returns a TypeDef of kind List with the provided type for its elements.`), |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/module.go | dagql.Func("withObject", s.typeDefWithObject).
Doc(`Returns a TypeDef of kind Object with the provided name.`,
`Note that an object's fields and functions may be omitted if the
intent is only to refer to an object. This is how functions are able to
return their own object, or any other circular reference.`),
dagql.Func("withInterface", s.typeDefWithInterface).
Doc(`Returns a TypeDef of kind Interface with the provided name.`),
dagql.Func("withField", s.typeDefWithObjectField).
Doc(`Adds a static field for an Object TypeDef, failing if the type is not an object.`).
ArgDoc("name", `The name of the field in the object`).
ArgDoc("typeDef", `The type of the field`).
ArgDoc("description", `A doc string for the field, if any`),
dagql.Func("withFunction", s.typeDefWithFunction).
Doc(`Adds a function for an Object or Interface TypeDef, failing if the type is not one of those kinds.`),
dagql.Func("withConstructor", s.typeDefWithObjectConstructor).
Doc(`Adds a function for constructing a new instance of an Object TypeDef, failing if the type is not an object.`),
}.Install(s.dag)
dagql.Fields[*core.ObjectTypeDef]{}.Install(s.dag)
dagql.Fields[*core.InterfaceTypeDef]{}.Install(s.dag)
dagql.Fields[*core.InputTypeDef]{}.Install(s.dag)
dagql.Fields[*core.FieldTypeDef]{}.Install(s.dag)
dagql.Fields[*core.ListTypeDef]{}.Install(s.dag)
dagql.Fields[*core.GeneratedCode]{
dagql.Func("withVCSGeneratedPaths", s.generatedCodeWithVCSGeneratedPaths).
Doc(`Set the list of paths to mark generated in version control.`),
dagql.Func("withVCSIgnoredPaths", s.generatedCodeWithVCSIgnoredPaths).
Doc(`Set the list of paths to ignore in version control.`),
}.Install(s.dag)
}
func (s *moduleSchema) typeDef(ctx context.Context, _ *core.Query, args struct{}) (*core.TypeDef, error) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/module.go | return &core.TypeDef{}, nil
}
func (s *moduleSchema) typeDefWithOptional(ctx context.Context, def *core.TypeDef, args struct {
Optional bool
}) (*core.TypeDef, error) {
return def.WithOptional(args.Optional), nil
}
func (s *moduleSchema) typeDefWithKind(ctx context.Context, def *core.TypeDef, args struct {
Kind core.TypeDefKind
}) (*core.TypeDef, error) {
return def.WithKind(args.Kind), nil
}
func (s *moduleSchema) typeDefWithListOf(ctx context.Context, def *core.TypeDef, args struct {
ElementType core.TypeDefID
}) (*core.TypeDef, error) {
elemType, err := args.ElementType.Load(ctx, s.dag)
if err != nil {
return nil, fmt.Errorf("failed to decode element type: %w", err)
}
return def.WithListOf(elemType.Self), nil
}
func (s *moduleSchema) typeDefWithObject(ctx context.Context, def *core.TypeDef, args struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/module.go | Name string
Description string `default:""`
}) (*core.TypeDef, error) {
if args.Name == "" {
return nil, fmt.Errorf("object type def must have a name")
}
return def.WithObject(args.Name, args.Description), nil
}
func (s *moduleSchema) typeDefWithInterface(ctx context.Context, def *core.TypeDef, args struct {
Name string
Description string `default:""`
}) (*core.TypeDef, error) {
return def.WithInterface(args.Name, args.Description), nil
}
func (s *moduleSchema) typeDefWithObjectField(ctx context.Context, def *core.TypeDef, args struct {
Name string
TypeDef core.TypeDefID
Description string `default:""`
}) (*core.TypeDef, error) {
fieldType, err := args.TypeDef.Load(ctx, s.dag)
if err != nil {
return nil, fmt.Errorf("failed to decode element type: %w", err)
}
return def.WithObjectField(args.Name, fieldType.Self, args.Description)
}
func (s *moduleSchema) typeDefWithFunction(ctx context.Context, def *core.TypeDef, args struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/module.go | Function core.FunctionID
}) (*core.TypeDef, error) {
fn, err := args.Function.Load(ctx, s.dag)
if err != nil {
return nil, fmt.Errorf("failed to decode element type: %w", err)
}
return def.WithFunction(fn.Self)
}
func (s *moduleSchema) typeDefWithObjectConstructor(ctx context.Context, def *core.TypeDef, args struct {
Function core.FunctionID
}) (*core.TypeDef, error) {
inst, err := args.Function.Load(ctx, s.dag)
if err != nil {
return nil, fmt.Errorf("failed to decode element type: %w", err)
}
fn := inst.Self.Clone()
fn.Name = ""
fn.OriginalName = ""
return def.WithObjectConstructor(fn)
}
func (s *moduleSchema) generatedCode(ctx context.Context, _ *core.Query, args struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/module.go | Code core.DirectoryID
}) (*core.GeneratedCode, error) {
dir, err := args.Code.Load(ctx, s.dag)
if err != nil {
return nil, err
}
return core.NewGeneratedCode(dir), nil
}
func (s *moduleSchema) generatedCodeWithVCSGeneratedPaths(ctx context.Context, code *core.GeneratedCode, args struct {
Paths []string
}) (*core.GeneratedCode, error) {
return code.WithVCSGeneratedPaths(args.Paths), nil
}
func (s *moduleSchema) generatedCodeWithVCSIgnoredPaths(ctx context.Context, code *core.GeneratedCode, args struct {
Paths []string
}) (*core.GeneratedCode, error) {
return code.WithVCSIgnoredPaths(args.Paths), nil
}
func (s *moduleSchema) module(ctx context.Context, query *core.Query, _ struct{}) (*core.Module, error) {
return query.NewModule(), nil
}
func (s *moduleSchema) function(ctx context.Context, _ *core.Query, args struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/module.go | Name string
ReturnType core.TypeDefID
}) (*core.Function, error) {
returnType, err := args.ReturnType.Load(ctx, s.dag)
if err != nil {
return nil, fmt.Errorf("failed to decode return type: %w", err)
}
return core.NewFunction(args.Name, returnType.Self), nil
}
func (s *moduleSchema) functionWithDescription(ctx context.Context, fn *core.Function, args struct {
Description string
}) (*core.Function, error) {
return fn.WithDescription(args.Description), nil
}
func (s *moduleSchema) functionWithArg(ctx context.Context, fn *core.Function, args struct {
Name string
TypeDef core.TypeDefID
Description string `default:""`
DefaultValue core.JSON `default:""`
}) (*core.Function, error) {
argType, err := args.TypeDef.Load(ctx, s.dag)
if err != nil {
return nil, fmt.Errorf("failed to decode arg type: %w", err)
}
return fn.WithArg(args.Name, argType.Self, args.Description, args.DefaultValue), nil
}
func (s *moduleSchema) moduleDependency(
ctx context.Context,
query *core.Query,
args struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/module.go | Source core.ModuleSourceID
Name string `default:""`
},
) (*core.ModuleDependency, error) {
src, err := args.Source.Load(ctx, s.dag)
if err != nil {
return nil, fmt.Errorf("failed to decode dependency source: %w", err)
}
return &core.ModuleDependency{
Source: src,
Name: args.Name,
}, nil
}
func (s *moduleSchema) currentModule(
ctx context.Context,
self *core.Query,
_ struct{}, |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/module.go | ) (*core.CurrentModule, error) {
mod, err := self.CurrentModule(ctx)
if err != nil {
return nil, fmt.Errorf("failed to get current module: %w", err)
}
return &core.CurrentModule{Module: mod}, nil
}
func (s *moduleSchema) currentFunctionCall(ctx context.Context, self *core.Query, _ struct{}) (*core.FunctionCall, error) {
return self.CurrentFunctionCall(ctx)
}
func (s *moduleSchema) moduleServe(ctx context.Context, modMeta dagql.Instance[*core.Module], _ struct{}) (dagql.Nullable[core.Void], error) {
return dagql.Null[core.Void](), modMeta.Self.Query.ServeModuleToMainClient(ctx, modMeta)
}
func (s *moduleSchema) currentTypeDefs(ctx context.Context, self *core.Query, _ struct{}) ([]*core.TypeDef, error) {
deps, err := self.CurrentServedDeps(ctx)
if err != nil {
return nil, fmt.Errorf("failed to get current module: %w", err)
}
return deps.TypeDefs(ctx)
}
func (s *moduleSchema) functionCallReturnValue(ctx context.Context, fnCall *core.FunctionCall, args struct {
Value core.JSON
}) (dagql.Nullable[core.Void], error) {
return dagql.Null[core.Void](), fnCall.ReturnValue(ctx, args.Value)
}
func (s *moduleSchema) moduleWithDescription(ctx context.Context, mod *core.Module, args struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/module.go | Description string
}) (*core.Module, error) {
return mod.WithDescription(args.Description), nil
}
func (s *moduleSchema) moduleWithObject(ctx context.Context, mod *core.Module, args struct {
Object core.TypeDefID
}) (_ *core.Module, rerr error) {
def, err := args.Object.Load(ctx, s.dag)
if err != nil {
return nil, err
}
return mod.WithObject(ctx, def.Self)
}
func (s *moduleSchema) moduleWithInterface(ctx context.Context, mod *core.Module, args struct {
Iface core.TypeDefID
}) (_ *core.Module, rerr error) {
def, err := args.Iface.Load(ctx, s.dag)
if err != nil {
return nil, err
}
return mod.WithInterface(ctx, def.Self)
}
func (s *moduleSchema) currentModuleName(
ctx context.Context,
curMod *core.CurrentModule,
args struct{}, |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/module.go | ) (string, error) {
return curMod.Module.Name(), nil
}
func (s *moduleSchema) currentModuleSource(
ctx context.Context,
curMod *core.CurrentModule,
args struct{},
) (inst dagql.Instance[*core.Directory], err error) {
srcSubpath, err := curMod.Module.Source.Self.SourceSubpathWithDefault(ctx)
if err != nil {
return inst, fmt.Errorf("failed to get module source subpath: %w", err)
}
err = s.dag.Select(ctx, curMod.Module.GeneratedContextDirectory, &inst,
dagql.Selector{
Field: "directory",
Args: []dagql.NamedInput{
{Name: "path", Value: dagql.String(srcSubpath)},
},
},
)
return inst, err
}
func (s *moduleSchema) currentModuleWorkdir(
ctx context.Context,
curMod *core.CurrentModule,
args struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/module.go | Path string
core.CopyFilter
},
) (inst dagql.Instance[*core.Directory], err error) {
if !filepath.IsLocal(args.Path) {
return inst, fmt.Errorf("workdir path %q escapes workdir", args.Path)
}
args.Path = filepath.Join(runtimeWorkdirPath, args.Path)
err = s.dag.Select(ctx, s.dag.Root(), &inst,
dagql.Selector{
Field: "host",
},
dagql.Selector{
Field: "directory",
Args: []dagql.NamedInput{
{Name: "path", Value: dagql.String(args.Path)},
{Name: "exclude", Value: asArrayInput(args.Exclude, dagql.NewString)},
{Name: "include", Value: asArrayInput(args.Include, dagql.NewString)},
},
},
)
return inst, err
}
func (s *moduleSchema) currentModuleWorkdirFile(
ctx context.Context,
curMod *core.CurrentModule,
args struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/module.go | Path string
},
) (inst dagql.Instance[*core.File], err error) {
if !filepath.IsLocal(args.Path) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/module.go | return inst, fmt.Errorf("workdir path %q escapes workdir", args.Path)
}
args.Path = filepath.Join(runtimeWorkdirPath, args.Path)
err = s.dag.Select(ctx, s.dag.Root(), &inst,
dagql.Selector{
Field: "host",
},
dagql.Selector{
Field: "file",
Args: []dagql.NamedInput{
{Name: "path", Value: dagql.String(args.Path)},
},
},
)
return inst, err
}
type directoryAsModuleArgs struct {
SourceRootPath string `default:"."`
}
func (s *moduleSchema) directoryAsModule(ctx context.Context, contextDir dagql.Instance[*core.Directory], args directoryAsModuleArgs) (*core.Module, error) {
var inst dagql.Instance[*core.Module]
err := s.dag.Select(ctx, s.dag.Root(), &inst,
dagql.Selector{
Field: "moduleSource",
Args: []dagql.NamedInput{
{Name: "refString", Value: dagql.String(args.SourceRootPath)},
},
},
dagql.Selector{
Field: "withContextDirectory", |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/module.go | Args: []dagql.NamedInput{
{Name: "dir", Value: dagql.NewID[*core.Directory](contextDir.ID())},
},
},
dagql.Selector{
Field: "asModule",
},
)
if err != nil {
return nil, fmt.Errorf("failed to create module from directory: %w", err)
}
return inst.Self, nil
}
func (s *moduleSchema) moduleInitialize(
ctx context.Context,
inst dagql.Instance[*core.Module],
args struct{},
) (*core.Module, error) {
if inst.Self.NameField == "" || inst.Self.SDKConfig == "" {
return nil, fmt.Errorf("module name and SDK must be set")
}
mod, err := inst.Self.Initialize(ctx, inst, dagql.CurrentID(ctx))
if err != nil {
return nil, fmt.Errorf("failed to initialize module: %w", err)
}
return mod, nil
}
func (s *moduleSchema) moduleWithSource(ctx context.Context, mod *core.Module, args struct {
Source core.ModuleSourceID
}) (*core.Module, error) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/module.go | src, err := args.Source.Load(ctx, s.dag)
if err != nil {
return nil, fmt.Errorf("failed to decode module source: %w", err)
}
mod = mod.Clone()
mod.Source = src
mod.NameField, err = src.Self.ModuleName(ctx)
if err != nil {
return nil, fmt.Errorf("failed to get module name: %w", err)
}
mod.OriginalName, err = src.Self.ModuleOriginalName(ctx)
if err != nil {
return nil, fmt.Errorf("failed to get module original name: %w", err)
}
mod.SDKConfig, err = src.Self.SDK(ctx)
if err != nil {
return nil, fmt.Errorf("failed to get module SDK: %w", err)
}
if err := s.updateDeps(ctx, mod, src); err != nil {
return nil, fmt.Errorf("failed to update module dependencies: %w", err)
}
if err := s.updateCodegenAndRuntime(ctx, mod, src); err != nil {
return nil, fmt.Errorf("failed to update codegen and runtime: %w", err)
}
if err := s.updateDaggerConfig(ctx, mod, src); err != nil {
return nil, fmt.Errorf("failed to update dagger.json: %w", err)
}
return mod, nil |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/module.go | }
func (s *moduleSchema) moduleGeneratedContextDiff(
ctx context.Context,
mod *core.Module,
args struct{},
) (inst dagql.Instance[*core.Directory], err error) {
baseContext, err := mod.Source.Self.ContextDirectory()
if err != nil {
return inst, fmt.Errorf("failed to get base context directory: %w", err)
}
var diff dagql.Instance[*core.Directory]
err = s.dag.Select(ctx, baseContext, &diff,
dagql.Selector{
Field: "diff",
Args: []dagql.NamedInput{
{Name: "other", Value: dagql.NewID[*core.Directory](mod.GeneratedContextDirectory.ID())},
},
},
)
if err != nil {
return inst, fmt.Errorf("failed to diff generated context: %w", err)
}
return diff, nil
}
func (s *moduleSchema) updateDeps(
ctx context.Context,
mod *core.Module,
src dagql.Instance[*core.ModuleSource],
) error {
var deps []dagql.Instance[*core.ModuleDependency] |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/module.go | err := s.dag.Select(ctx, src, &deps, dagql.Selector{Field: "dependencies"})
if err != nil {
return fmt.Errorf("failed to load module dependencies: %w", err)
}
mod.DependencyConfig = make([]*core.ModuleDependency, len(deps))
for i, dep := range deps {
mod.DependencyConfig[i] = dep.Self
}
mod.DependenciesField = make([]dagql.Instance[*core.Module], len(deps))
var eg errgroup.Group
for i, dep := range deps {
i, dep := i, dep
eg.Go(func() error {
err := s.dag.Select(ctx, dep.Self.Source, &mod.DependenciesField[i],
dagql.Selector{
Field: "withName",
Args: []dagql.NamedInput{
{Name: "name", Value: dagql.String(dep.Self.Name)},
},
},
dagql.Selector{
Field: "asModule",
},
dagql.Selector{
Field: "initialize",
},
)
if err != nil {
return fmt.Errorf("failed to initialize dependency module: %w", err)
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/module.go | return nil
})
}
if err := eg.Wait(); err != nil {
return fmt.Errorf("failed to initialize dependency modules: %w", err)
}
mod.Deps = core.NewModDeps(src.Self.Query, src.Self.Query.DefaultDeps.Mods)
for _, dep := range mod.DependenciesField {
mod.Deps = mod.Deps.Append(dep.Self)
}
return nil
}
func (s *moduleSchema) updateCodegenAndRuntime(
ctx context.Context,
mod *core.Module,
src dagql.Instance[*core.ModuleSource],
) error {
if mod.NameField == "" || mod.SDKConfig == "" {
return nil
}
baseContext, err := src.Self.ContextDirectory()
if err != nil {
return fmt.Errorf("failed to get base context directory: %w", err)
}
mod.GeneratedContextDirectory = baseContext
rootSubpath, err := src.Self.SourceRootSubpath()
if err != nil {
return fmt.Errorf("failed to get source root subpath: %w", err)
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/module.go | sdk, err := s.sdkForModule(ctx, src.Self.Query, mod.SDKConfig, src)
if err != nil {
return fmt.Errorf("failed to load sdk for module: %w", err)
}
generatedCode, err := sdk.Codegen(ctx, mod.Deps, src)
if err != nil {
return fmt.Errorf("failed to generate code: %w", err)
}
var diff dagql.Instance[*core.Directory]
err = s.dag.Select(ctx, baseContext, &diff,
dagql.Selector{
Field: "diff",
Args: []dagql.NamedInput{
{Name: "other", Value: dagql.NewID[*core.Directory](generatedCode.Code.ID())},
},
},
)
if err != nil {
return fmt.Errorf("failed to diff generated code: %w", err)
}
err = s.dag.Select(ctx, mod.GeneratedContextDirectory, &mod.GeneratedContextDirectory,
dagql.Selector{
Field: "withDirectory",
Args: []dagql.NamedInput{
{Name: "path", Value: dagql.String("/")},
{Name: "directory", Value: dagql.NewID[*core.Directory](diff.ID())},
},
},
)
if err != nil { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/module.go | return fmt.Errorf("failed to add codegen to module context directory: %w", err)
}
if len(generatedCode.VCSGeneratedPaths) > 0 {
gitAttrsPath := filepath.Join(rootSubpath, ".gitattributes")
var gitAttrsContents []byte
gitAttrsFile, err := baseContext.Self.File(ctx, gitAttrsPath)
if err == nil {
gitAttrsContents, err = gitAttrsFile.Contents(ctx)
if err != nil {
return fmt.Errorf("failed to get git attributes file contents: %w", err)
}
if !bytes.HasSuffix(gitAttrsContents, []byte("\n")) {
gitAttrsContents = append(gitAttrsContents, []byte("\n")...)
}
}
for _, fileName := range generatedCode.VCSGeneratedPaths {
if bytes.Contains(gitAttrsContents, []byte(fileName)) {
continue
}
gitAttrsContents = append(gitAttrsContents,
[]byte(fmt.Sprintf("/%s linguist-generated\n", fileName))...,
)
}
err = s.dag.Select(ctx, mod.GeneratedContextDirectory, &mod.GeneratedContextDirectory,
dagql.Selector{
Field: "withNewFile", |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/module.go | Args: []dagql.NamedInput{
{Name: "path", Value: dagql.String(gitAttrsPath)},
{Name: "contents", Value: dagql.String(gitAttrsContents)},
{Name: "permissions", Value: dagql.Int(0600)},
},
},
)
if err != nil {
return fmt.Errorf("failed to add vcs generated file: %w", err)
}
}
if len(generatedCode.VCSIgnoredPaths) > 0 {
gitIgnorePath := filepath.Join(rootSubpath, ".gitignore")
var gitIgnoreContents []byte
gitIgnoreFile, err := baseContext.Self.File(ctx, gitIgnorePath)
if err == nil {
gitIgnoreContents, err = gitIgnoreFile.Contents(ctx)
if err != nil {
return fmt.Errorf("failed to get .gitignore file contents: %w", err)
}
if !bytes.HasSuffix(gitIgnoreContents, []byte("\n")) {
gitIgnoreContents = append(gitIgnoreContents, []byte("\n")...)
}
}
for _, fileName := range generatedCode.VCSIgnoredPaths {
if bytes.Contains(gitIgnoreContents, []byte(fileName)) {
continue |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/module.go | }
gitIgnoreContents = append(gitIgnoreContents,
[]byte(fmt.Sprintf("/%s\n", fileName))...,
)
}
err = s.dag.Select(ctx, mod.GeneratedContextDirectory, &mod.GeneratedContextDirectory,
dagql.Selector{
Field: "withNewFile",
Args: []dagql.NamedInput{
{Name: "path", Value: dagql.String(gitIgnorePath)},
{Name: "contents", Value: dagql.String(gitIgnoreContents)},
{Name: "permissions", Value: dagql.Int(0600)},
},
},
)
if err != nil {
return fmt.Errorf("failed to add vcs ignore file: %w", err)
}
}
mod.Runtime, err = sdk.Runtime(ctx, mod.Deps, src)
if err != nil {
return fmt.Errorf("failed to get module runtime: %w", err)
}
return nil
}
func (s *moduleSchema) updateDaggerConfig(
ctx context.Context,
mod *core.Module,
src dagql.Instance[*core.ModuleSource],
) error { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/module.go | modCfg, ok, err := src.Self.ModuleConfig(ctx)
if err != nil {
return fmt.Errorf("failed to get module config: %w", err)
}
if !ok {
modCfg = &modules.ModuleConfig{}
}
modCfg.Name = mod.OriginalName
modCfg.SDK = mod.SDKConfig
modCfg.EngineVersion = engine.Version
sourceRootSubpath, err := src.Self.SourceRootSubpath()
if err != nil {
return fmt.Errorf("failed to get source root subpath: %w", err)
}
sourceSubpath, err := src.Self.SourceSubpathWithDefault(ctx)
if err != nil {
return fmt.Errorf("failed to get source subpath: %w", err)
}
sourceRelSubpath, err := filepath.Rel(sourceRootSubpath, sourceSubpath)
if err != nil {
return fmt.Errorf("failed to get relative source subpath: %w", err)
}
if sourceRelSubpath != "." {
modCfg.Source = sourceRelSubpath
}
modCfg.Dependencies = make([]*modules.ModuleConfigDependency, len(mod.DependencyConfig))
for i, dep := range mod.DependencyConfig {
var srcStr string
switch dep.Source.Self.Kind {
case core.ModuleSourceKindLocal: |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/module.go | depRootSubpath, err := dep.Source.Self.SourceRootSubpath()
if err != nil {
return fmt.Errorf("failed to get source root subpath: %w", err)
}
depRelPath, err := filepath.Rel(sourceRootSubpath, depRootSubpath)
if err != nil {
return fmt.Errorf("failed to get relative path to dep: %w", err)
}
srcStr = depRelPath
case core.ModuleSourceKindGit:
srcStr = dep.Source.Self.AsGitSource.Value.RefString()
default:
return fmt.Errorf("unsupported dependency source kind: %s", dep.Source.Self.Kind)
}
depName := dep.Name
if dep.Name == "" {
depName = mod.DependenciesField[i].Self.Name()
}
modCfg.Dependencies[i] = &modules.ModuleConfigDependency{
Name: depName,
Source: srcStr,
}
}
rootSubpath, err := src.Self.SourceRootSubpath()
if err != nil {
return fmt.Errorf("failed to get source root subpath: %w", err)
}
modCfgPath := filepath.Join(rootSubpath, modules.Filename) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/module.go | updatedModCfgBytes, err := json.MarshalIndent(modCfg, "", " ")
if err != nil {
return fmt.Errorf("failed to encode module config: %w", err)
}
updatedModCfgBytes = append(updatedModCfgBytes, '\n')
if mod.GeneratedContextDirectory.Self == nil {
err = s.dag.Select(ctx, s.dag.Root(), &mod.GeneratedContextDirectory,
dagql.Selector{Field: "directory"},
)
if err != nil {
return fmt.Errorf("failed to initialize module context directory: %w", err)
}
}
err = s.dag.Select(ctx, mod.GeneratedContextDirectory, &mod.GeneratedContextDirectory,
dagql.Selector{
Field: "withNewFile",
Args: []dagql.NamedInput{
{Name: "path", Value: dagql.String(modCfgPath)},
{Name: "contents", Value: dagql.String(updatedModCfgBytes)},
{Name: "permissions", Value: dagql.Int(0644)},
},
},
)
if err != nil {
return fmt.Errorf("failed to update module context directory config file: %w", err)
}
return nil
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/modulesource.go | package schema
import (
"context"
"encoding/json"
"errors"
"fmt"
"path/filepath"
"sort"
"strings"
"github.com/dagger/dagger/core"
"github.com/dagger/dagger/core/modules"
"github.com/dagger/dagger/dagql"
"github.com/dagger/dagger/engine/buildkit"
"github.com/vito/progrock"
"golang.org/x/sync/errgroup"
)
type moduleSourceArgs struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/modulesource.go | RefString string
Stable bool `default:"false"`
}
func (s *moduleSchema) moduleSource(ctx context.Context, query *core.Query, args moduleSourceArgs) (*core.ModuleSource, error) {
parsed := parseRefString(args.RefString)
modPath, modVersion, hasVersion, isGitHub := parsed.modPath, parsed.modVersion, parsed.hasVersion, parsed.isGitHub
if !hasVersion && isGitHub && args.Stable {
return nil, fmt.Errorf("no version provided for stable remote ref: %s", args.RefString)
}
src := &core.ModuleSource{
Query: query,
Kind: parsed.kind,
}
switch src.Kind {
case core.ModuleSourceKindLocal:
if filepath.IsAbs(modPath) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/modulesource.go | return nil, fmt.Errorf("local module source root path is absolute: %s", modPath)
}
src.AsLocalSource = dagql.NonNull(&core.LocalModuleSource{
RootSubpath: modPath,
})
case core.ModuleSourceKindGit:
if !isGitHub {
return nil, fmt.Errorf("for now, only github.com/ paths are supported: %q", args.RefString)
}
src.AsGitSource = dagql.NonNull(&core.GitModuleSource{})
segments := strings.SplitN(modPath, "/", 4)
if len(segments) < 3 {
return nil, fmt.Errorf("invalid github.com path: %s", modPath)
}
src.AsGitSource.Value.URLParent = segments[0] + "/" + segments[1] + "/" + segments[2]
cloneURL := src.AsGitSource.Value.CloneURL()
if !hasVersion {
if args.Stable {
return nil, fmt.Errorf("no version provided for stable remote ref: %s", args.RefString)
}
var err error
modVersion, err = defaultBranch(ctx, cloneURL)
if err != nil {
return nil, fmt.Errorf("determine default branch: %w", err)
}
}
src.AsGitSource.Value.Version = modVersion
var subPath string
if len(segments) == 4 {
subPath = segments[3] |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/modulesource.go | } else {
subPath = "/"
}
commitRef := modVersion
if hasVersion && isSemver(modVersion) {
allTags, err := gitTags(ctx, cloneURL)
if err != nil {
return nil, fmt.Errorf("get git tags: %w", err)
}
matched, err := matchVersion(allTags, modVersion, subPath)
if err != nil {
return nil, fmt.Errorf("matching version to tags: %w", err)
}
commitRef = matched
}
var gitRef dagql.Instance[*core.GitRef]
err := s.dag.Select(ctx, s.dag.Root(), &gitRef,
dagql.Selector{
Field: "git",
Args: []dagql.NamedInput{
{Name: "url", Value: dagql.String(cloneURL)},
},
},
dagql.Selector{
Field: "commit",
Args: []dagql.NamedInput{
{Name: "id", Value: dagql.String(commitRef)},
},
}, |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/modulesource.go | )
if err != nil {
return nil, fmt.Errorf("failed to resolve git src: %w", err)
}
gitCommit, err := gitRef.Self.Commit(ctx)
if err != nil {
return nil, fmt.Errorf("failed to resolve git src to commit: %w", err)
}
src.AsGitSource.Value.Commit = gitCommit
subPath = filepath.Clean(subPath)
if !filepath.IsAbs(subPath) && !filepath.IsLocal(subPath) {
return nil, fmt.Errorf("git module source subpath points out of root: %q", subPath)
}
if filepath.IsAbs(subPath) {
subPath = strings.TrimPrefix(subPath, "/")
}
err = s.dag.Select(ctx, gitRef, &src.AsGitSource.Value.ContextDirectory,
dagql.Selector{Field: "tree"},
)
if err != nil {
return nil, fmt.Errorf("failed to load git dir: %w", err)
}
src.AsGitSource.Value.RootSubpath = subPath
}
return src, nil
}
type parsedRefString struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/modulesource.go | modPath string
modVersion string
hasVersion bool
isGitHub bool
kind core.ModuleSourceKind
}
func parseRefString(refString string) parsedRefString {
var parsed parsedRefString
parsed.modPath, parsed.modVersion, parsed.hasVersion = strings.Cut(refString, "@")
parsed.isGitHub = strings.HasPrefix(parsed.modPath, "github.com/")
if !parsed.hasVersion && !parsed.isGitHub {
parsed.kind = core.ModuleSourceKindLocal
return parsed
}
parsed.kind = core.ModuleSourceKindGit
return parsed
}
func (s *moduleSchema) moduleSourceAsModule(
ctx context.Context,
src dagql.Instance[*core.ModuleSource],
args struct{}, |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/modulesource.go | ) (inst dagql.Instance[*core.Module], err error) {
err = s.dag.Select(ctx, s.dag.Root(), &inst,
dagql.Selector{
Field: "module",
},
dagql.Selector{
Field: "withSource",
Args: []dagql.NamedInput{
{Name: "source", Value: dagql.NewID[*core.ModuleSource](src.ID())},
},
},
)
if err != nil {
return inst, fmt.Errorf("failed to create module: %w", err)
}
return inst, err
}
func (s *moduleSchema) moduleSourceAsString(ctx context.Context, src *core.ModuleSource, args struct{}) (string, error) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/modulesource.go | return src.RefString()
}
func (s *moduleSchema) gitModuleSourceCloneURL(
ctx context.Context,
ref *core.GitModuleSource,
args struct{},
) (string, error) {
return ref.CloneURL(), nil
}
func (s *moduleSchema) gitModuleSourceHTMLURL(
ctx context.Context,
ref *core.GitModuleSource,
args struct{},
) (string, error) {
return ref.HTMLURL(), nil
}
func (s *moduleSchema) moduleSourceConfigExists(
ctx context.Context,
src *core.ModuleSource,
args struct{},
) (bool, error) {
_, ok, err := src.ModuleConfig(ctx)
return ok, err
}
func (s *moduleSchema) moduleSourceSubpath(ctx context.Context, src *core.ModuleSource, args struct{}) (string, error) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/modulesource.go | return src.SourceSubpath(ctx)
}
func (s *moduleSchema) moduleSourceWithSourceSubpath(
ctx context.Context,
src *core.ModuleSource,
args struct {
Path string
},
) (*core.ModuleSource, error) {
if args.Path == "" {
return src, nil
}
if !filepath.IsLocal(args.Path) {
return nil, fmt.Errorf("source subdir path %q escapes context", args.Path)
}
src = src.Clone()
src.WithSourceSubpath = args.Path
return src, nil
}
func (s *moduleSchema) moduleSourceRootSubpath(ctx context.Context, src *core.ModuleSource, args struct{}) (string, error) {
return src.SourceRootSubpath()
}
func (s *moduleSchema) moduleSourceModuleName(
ctx context.Context,
src *core.ModuleSource,
args struct{}, |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/modulesource.go | ) (string, error) {
return src.ModuleName(ctx)
}
func (s *moduleSchema) moduleSourceModuleOriginalName(
ctx context.Context,
src *core.ModuleSource,
args struct{},
) (string, error) {
return src.ModuleOriginalName(ctx)
}
func (s *moduleSchema) moduleSourceWithName(
ctx context.Context,
src *core.ModuleSource,
args struct {
Name string
},
) (*core.ModuleSource, error) {
src = src.Clone()
src.WithName = args.Name
return src, nil
}
func (s *moduleSchema) moduleSourceDependencies(
ctx context.Context,
src dagql.Instance[*core.ModuleSource],
args struct{}, |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/modulesource.go | ) ([]dagql.Instance[*core.ModuleDependency], error) {
modCfg, ok, err := src.Self.ModuleConfig(ctx)
if err != nil {
return nil, fmt.Errorf("failed to get module config: %w", err)
}
var existingDeps []dagql.Instance[*core.ModuleDependency]
if ok && len(modCfg.Dependencies) > 0 {
existingDeps = make([]dagql.Instance[*core.ModuleDependency], len(modCfg.Dependencies))
var eg errgroup.Group
for i, depCfg := range modCfg.Dependencies {
i, depCfg := i, depCfg
eg.Go(func() error {
var depSrc dagql.Instance[*core.ModuleSource]
err := s.dag.Select(ctx, s.dag.Root(), &depSrc,
dagql.Selector{
Field: "moduleSource",
Args: []dagql.NamedInput{
{Name: "refString", Value: dagql.String(depCfg.Source)},
},
},
)
if err != nil {
return fmt.Errorf("failed to create module source from dependency: %w", err)
}
var resolvedDepSrc dagql.Instance[*core.ModuleSource]
err = s.dag.Select(ctx, src, &resolvedDepSrc,
dagql.Selector{ |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/modulesource.go | Field: "resolveDependency",
Args: []dagql.NamedInput{
{Name: "dep", Value: dagql.NewID[*core.ModuleSource](depSrc.ID())},
},
},
)
if err != nil {
return fmt.Errorf("failed to resolve dependency: %w", err)
}
err = s.dag.Select(ctx, s.dag.Root(), &existingDeps[i],
dagql.Selector{
Field: "moduleDependency",
Args: []dagql.NamedInput{
{Name: "source", Value: dagql.NewID[*core.ModuleSource](resolvedDepSrc.ID())},
{Name: "name", Value: dagql.String(depCfg.Name)},
},
},
)
if err != nil {
return fmt.Errorf("failed to create module dependency: %w", err)
}
return nil
})
}
if err := eg.Wait(); err != nil {
return nil, fmt.Errorf("failed to load pre-configured dependencies: %w", err)
}
}
newDeps := make([]dagql.Instance[*core.ModuleDependency], len(src.Self.WithDependencies))
var eg errgroup.Group |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/modulesource.go | for i, dep := range src.Self.WithDependencies {
i, dep := i, dep
eg.Go(func() error {
var resolvedDepSrc dagql.Instance[*core.ModuleSource]
err := s.dag.Select(ctx, src, &resolvedDepSrc,
dagql.Selector{
Field: "resolveDependency",
Args: []dagql.NamedInput{
{Name: "dep", Value: dagql.NewID[*core.ModuleSource](dep.Self.Source.ID())},
},
},
)
if err != nil {
return fmt.Errorf("failed to resolve dependency: %w", err)
}
err = s.dag.Select(ctx, s.dag.Root(), &newDeps[i],
dagql.Selector{
Field: "moduleDependency",
Args: []dagql.NamedInput{
{Name: "source", Value: dagql.NewID[*core.ModuleSource](resolvedDepSrc.ID())},
{Name: "name", Value: dagql.String(dep.Self.Name)},
},
},
)
if err != nil {
return fmt.Errorf("failed to create module dependency: %w", err)
}
return nil
})
} |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.