#generate + check
1 messages ยท Page 1 of 1 (latest)
maybe related: I have added a // +check function for each of my functions that would be a // +generate function (assuming i've guessed the use of dagger generate correctly) that ensures that its Changeset is empty.
not sure how you'd do it with a good UX, but it'd be nice if I didn't need to create a "stub" check function for each generate function
maybe if the function returns a Changeset, is a check function, and is a generate function, then dagger automatically ensures that the Changeset is empty?
here's an example "stub" function that I'm referring to:
// +check
func (m *Example) IsGenerated(ctx context.Context) error {
if empty, err := m.Generate(ctx).IsEmpty(ctx); err != nil {
return err
} else if !empty {
return fmt.Errorf("source is not generated (run `dagger call generate`)")
}
return nil
}
Here's how we plan on addressing that:
- Add first-class
dagger generatesupport - Add a builtin check function, always available in
dagger check, calledcheck-generated. This will automatically callgenerateand fail if the changeset is not empty
Desired end state: dagger check by default always checks that your generated files are up-to-date, without requiring any explicit +check on your part
sgtm
We have the exact same pattern in our own dagger module at the moment ๐ Once the improvements above ๐ are merged, we can remove that custom code
https://github.com/dagger/dagger/blob/main/.dagger/main.go#L18-L34