Skip to content
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

cleanups to "go generate" #166

Merged
2 commits merged into from
Jan 31, 2023
Merged

cleanups to "go generate" #166

2 commits merged into from
Jan 31, 2023

Conversation

ghost
Copy link

@ghost ghost commented Jan 31, 2023

I'm putting this out on spec; if people don't like it, I'm happy to withdraw it. My motivation is that I keep editing the wrong file and/or forgetting which I should edit, and I'm happier if my IDE reminds me which one is generated and which one is committed.

Changes in this PR:

  • don't check in the generated files
    • instead, add them to a local gitignore
    • delete the ones that were there before
  • use npx tsc rather than tsc. This means people don't need tsc globally installed, plus it ensures we all use the same version.
  • only invoke tsc once, to save some time (on my machine, it brought go generate ./... down from ~10 seconds to ~3).

This does have one tradeoff, which is that you need to run go generate ./... at least once before you build. In particular, this means that I had to add that command to the integ test runner. That's arguably a bit less convenient and a bit more safe (in terms of not compiling old code that someone forgot to generate), so whether it's good or bad in net is up for interpretation.

Standard checks

  • Unit tests: no issues, other than the ones mentioned above
  • Docs: no issues
  • Backwards compatibility: shouldn't be any issues:
    • I did run md5sum * in klotho/pkg/lang/[python|javascript]/aws_runtime (on main, vs on this branch after go generate), and confirmed that they're the same other than the bash scripts
    • this may delete people's local files when they pull, I'm not sure. If so, running go generate ./... will fix it

- don't check in the generated files; instead, add them to a local
  gitignore
- use "npx tsc" rather than "tsc". This means people don't need tsc
  globally installed, plus it ensures we all use the same version.
- only invoke tsc once, to save some time
Comment on lines 1 to +12
/node_modules/
dispatcher_fargate.js.tmpl
dispatcher_lambda.js.tmpl
emitter.js.tmpl
fs.js.tmpl
keyvalue.js.tmpl
orm.js.tmpl
proxy_eks.js.tmpl
proxy_fargate.js.tmpl
redis_cluster.js.tmpl
redis_node.js.tmpl
secret.js.tmpl
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why ignore checking these in? we dont have .js files for all of them so we need some of these checked in

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which ones don't we have .ts files for? I actually even create the changes to this file manually; they're all from the bash script's changes to add the generated files to this ignore.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh i guess this list doesnt include the ones which we dont have ts files for

Copy link
Contributor

@gordon-klotho gordon-klotho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, been waiting for this. Looks like we need to add the generate to the govulncheck action though

Comment on lines +22 to +23
sort -u .gitignore > gitignore-tmp
mv gitignore-tmp .gitignore
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clever, I like this a lot.

@github-actions
Copy link

Package Line Rate Health
github.com/klothoplatform/klotho/pkg/analytics 2%
github.com/klothoplatform/klotho/pkg/annotation 23%
github.com/klothoplatform/klotho/pkg/cli 4%
github.com/klothoplatform/klotho/pkg/core 21%
github.com/klothoplatform/klotho/pkg/env_var 82%
github.com/klothoplatform/klotho/pkg/exec_unit 54%
github.com/klothoplatform/klotho/pkg/infra/kubernetes 59%
github.com/klothoplatform/klotho/pkg/infra/kubernetes/helm 39%
github.com/klothoplatform/klotho/pkg/input 63%
github.com/klothoplatform/klotho/pkg/lang 37%
github.com/klothoplatform/klotho/pkg/lang/dockerfile 0%
github.com/klothoplatform/klotho/pkg/lang/golang 20%
github.com/klothoplatform/klotho/pkg/lang/javascript 47%
github.com/klothoplatform/klotho/pkg/lang/python 61%
github.com/klothoplatform/klotho/pkg/lang/yaml 0%
github.com/klothoplatform/klotho/pkg/logging 7%
github.com/klothoplatform/klotho/pkg/multierr 95%
github.com/klothoplatform/klotho/pkg/provider/aws 59%
github.com/klothoplatform/klotho/pkg/runtime 75%
github.com/klothoplatform/klotho/pkg/static_unit 33%
github.com/klothoplatform/klotho/pkg/validation 73%
github.com/klothoplatform/klotho/pkg/yaml_util 79%
Summary 40% (3799 / 9453)

@ghost ghost merged commit 25b30f2 into main Jan 31, 2023
@ghost ghost deleted the generate_cleanup branch January 31, 2023 20:20
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants