-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: use shared .ftl folder for stubs #1843
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I imagine we don't really need tests, because if this wasn't working, all of our integration tests would fail.
.gitignore
Outdated
**/testdata/**/_ftl | ||
**/examples/**/_ftl | ||
**/testdata/**/.ftl | ||
**/examples/**/.ftl | ||
**/_ftl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove these, they were deliberately not present because they exclude the same name in templates.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I added the equivalent of what we had before with _ftl
but maybe I'm missing something. I reordered these a bit to group them as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
**/_ftl
and **/.ftl
, shouldn't be there. It's the reason why your new template dir is missing. They need to be removed.
Edit: sorry, I removed **/_ftl
a while back but it looks like someone added it back in
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But let's remove them now!
buildengine/engine.go
Outdated
|
||
meta, ok := e.moduleMetas.Load(module) | ||
if !ok { | ||
return fmt.Errorf("Module %q not found", module) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: errors shouldn't be upper cased
@@ -16,7 +16,7 @@ func TestEngine(t *testing.T) { | |||
t.SkipNow() | |||
} | |||
ctx := log.ContextWithNewDefaultLogger(context.Background()) | |||
engine, err := buildengine.New(ctx, nil, []string{"testdata/alpha", "testdata/other", "testdata/another"}) | |||
engine, err := buildengine.New(ctx, nil, t.TempDir(), []string{"testdata/alpha", "testdata/other", "testdata/another"}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a heads up that t.TempDir()
will create a new tempdir each time it's called. Just make sure that's what you want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to look that up while I was working on this :)
Replace map[string]string `short:"r" help:"Replace a module import path with a local path in the initialised FTL module." placeholder:"OLD=NEW,..." env:"FTL_INIT_GO_REPLACE"` | ||
Dir string `arg:"" help:"Directory to initialize the module in."` | ||
Name string `arg:"" help:"Name of the FTL module to create underneath the base directory."` | ||
GoVersion string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delete
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this one so that it could be used in the scaffolding template since that uses newGoCmd
directly as it's context. Would it be better to create a new context and add what I need there for the template instead of using the newGoCmd
for template context?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, if you need it in the context but it's not a flag, it shouldn't be in the flag struct.
go-runtime/compile/build.go
Outdated
@@ -87,14 +93,15 @@ func (b ExternalModuleContext) NonMainModules() []*schema.Module { | |||
return modules | |||
} | |||
|
|||
const buildDirName = "_ftl" | |||
const buildDirName = ".ftl" | |||
const DefaultGoModVersion = "1.21" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should never be a need for something like this, we should always pull the Go version from the module's go.mod
file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was something I wanted to chat about. With this new shared setup, I'm not sure which version to use here. Given that we might be generating shared modules for multiple modules. Or in the initial case we're generating shared modules for just builtins
so I don't have a go version to get from a module. In the other cases we're very likely generating a single shared .ftl/go/modules
for a multiple modules, so I wasn't sure which go version to use there either.
The big one is the builtins though. That's what led to me adding this here, but it felt dirty for sure. I also added this central one so we could share it with the cmd_new.go
go code that was using a hardcoded version in it's template.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah good question. In that case we should use the highest version.
cmd/ftl/cmd_new.go
Outdated
@@ -58,6 +60,8 @@ func (i newGoCmd) Run(ctx context.Context) error { | |||
|
|||
logger := log.FromContext(ctx) | |||
logger.Debugf("Creating FTL Go module %q in %s", name, path) | |||
|
|||
i.GoVersion = compile.DefaultGoModVersion |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should never be needed, either pull it from the go.mod
file or if that's really not possible, from the go
tool itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah maybe we should use the go tool for this one too. Before this change the version was hard coded in the template.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes this is for ftl new
- in that case it should definitely use the Go tool.
@@ -8,9 +8,14 @@ import ( | |||
"github.com/TBD54566975/ftl/internal" | |||
) | |||
|
|||
func mainWorkTemplateFiles() *zip.Reader { | |||
return internal.ZipRelativeToCaller("main-work-template") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see these files?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahh maybe a .gitignore issue. I'll fix. Thanks!
@@ -1,9 +1,9 @@ | |||
module ftl/{{ .Name }} | |||
|
|||
go 1.21 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OMG I wonder if this is the source of all those bugs we've seen ...
80a8da6
to
b6a7150
Compare
.gitignore
Outdated
buildengine/.gitignore | ||
go.work* | ||
junit*.xml | ||
/readme-tests | ||
**/_ftl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one shouldn't have been there.
.gitignore
Outdated
**/testdata/**/_ftl | ||
**/examples/**/_ftl | ||
**/testdata/**/.ftl | ||
**/examples/**/.ftl | ||
**/_ftl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But let's remove them now!
Let's not forget about this, looking forward to it! |
73fbaa0
to
b975a47
Compare
b975a47
to
9ba22ba
Compare
9ba22ba
to
caf6be9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Absolutely mammoth effort, thanks Wes :)
Fixes #1662
Fixes #1827