ballingt
ballingt•3y ago

However if you want to do codegen in CI

However if you want to do codegen in CI you can, I think a CONVEX_DEPLOY_KEY env var being available should do it.
5 Replies
Homostellaris
Homostellaris•3y ago
Hey Tom, just tried this but I get the same message about it not being able to find config.json and wanting me to run npx convex login I'm able to reproduce this locally by renaming ~/.convex and then running CONVEX_DEPLOY_KEY='...' npx convex codegen
ballingt
ballingtOP•3y ago
Ah shoot, thanks for trying In the meantime I'd suggest checking in your codegen'd files but I think we can support this workflow, we a deploy should be enough to run codegen I'll get back to you on this! (but it will be at least until the next release)
alexcole
alexcole•3y ago
This is a total hack, but I think you can actually run codegen with npx convex deploy --dry-run with CONVEX_DEPLOY_KEY. We rerun codegen as part of deploying and --dry-run will cause the actual deploy to not happen. But yeah, I think it would make sense to support CONVEX_DEPLOY_KEY in npx convex codegen as well.
Homostellaris
Homostellaris•3y ago
I hadn't considered checking the generated files in 🤔 I guess that's not an issue for small projects but I could see for larger projects the extra diff noise on PRs being an issue, perhaps there are other benefits to checking the files in that I'm not considering though
alexcole
alexcole•3y ago
Yep, totally up to you. Our default is to recommend checking it in so that your code on Github is readable, lintable etc without extra work. Our codegen also changes very little (2 lines per file in convex/!) so the diffs should be small. But I also I agree that there is a good argument to not check in build artifacts + derived state. Also, you can now run npx convex codegen without a deploy key! The newest version of Convex does the code generation entirely locally with no need to be logged in, so it should be quite easy to do it in CI if you'd like

Did you find this page helpful?