#How to call a module's functions when loading it from source?

1 messages · Page 1 of 1 (latest)

tawny dove
#

I want to start unit testing my modules in my daggerverse.

I have the following structure with a tests submodule in each module and a dev module that defines the CI pipelines for the repo:

daggerverse
├── modA
│   ├── dagger.json
│   └── tests
│       └── dagger.json
├── modB
│   ├── dagger.json
│   └── tests
│       └── dagger.json
...
└── dev
    └── dagger.json

I can call each tests module using the cli with a common all function:
dagger call -m <module>/tests all

My issue is that I cannot call the functions from my dev module.
I can load the dagger.Module object using the following function on my dagger.Directory: src.AsModule(dagger.DirectoryAsModuleOpts{SourceRootPath: path})
However, I do not see how to call the all function once I get the module object.

Is is possible to call a module's functions when loaded dynamically?

void hollow
#

You can call them dynamically, by crafting a graphql query yourself, but you won't get generated client bindings

#

Instead what I do is just install the tested modules as dependencies inside the dev module

#

dagger -m ./dev install ./modA

#

Then you don't have to worry about dynamically loading - you can just call dag.ModA.All()

tawny dove
#

Ok, not sure I want to write graphQL myself 🙂

void hollow
tawny dove
#

I was trying to avoid the dagger install so tests would be discovered automatically but having the client binding will be nice 🙂

#

Do you have an example of what a graphQL query would look like?