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

perf: improve preprocess action perf by only resolving template strings when absolutely needed #6745

Merged
merged 180 commits into from
Jan 31, 2025

Conversation

stefreak
Copy link
Member

@stefreak stefreak commented Dec 30, 2024

What this PR does / why we need it:

Improve preprocess action performance

In large monorepo settings, this change improves the performance of the garden validate command (Which processes actions and templates) by about 35%. In smaller projects the performance improvement is not noticeable.

We achieve this by fully separating parsing of configs and evaluation of configs, and also dropping partial evaluation of template expressions. Whenever a value needs to be known right now, we fully resolve the template string.

This will fix long-standing issues like #5825 (We were prone to template injection before).

We also keep track of the YAML source for all template strings automatically and don't need to worry about manually keeping track of this anymore. This means that error messages will be improved for all users, even for Modules.

The ModuleResolver is the only place left where we partially resolve configs, and where we evaluate template strings and then parse them again.

Exclude variables and varfile contents from version calculation

This PR also excludes values of variables and varfile contents from version calculation, because
what counts is how variables affect the action or module spec. If a variable is actually used and impacts the spec, it will affect version calculation. This should fix #3473

Which issue(s) this PR fixes:

Fixes #5202, #5442, #5825, #3473 (and possibly more)

@stefreak stefreak marked this pull request as ready for review January 31, 2025 15:01
@stefreak stefreak added this pull request to the merge queue Jan 31, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 31, 2025
@stefreak stefreak added this pull request to the merge queue Jan 31, 2025
Merged via the queue into main with commit c968c61 Jan 31, 2025
42 checks passed
@stefreak stefreak deleted the preprocess-perf branch January 31, 2025 17:37
stefreak added a commit that referenced this pull request Feb 24, 2025
…n action configs

This commit fixes a regression introduced in #6745 where we stopped throwing an error for unknown keys in action configs.
stefreak added a commit that referenced this pull request Feb 24, 2025
…n action configs

This commit fixes a regression introduced in #6745 where we stopped throwing an error for unknown keys in action configs.
stefreak added a commit that referenced this pull request Feb 24, 2025
…n action configs

This commit fixes a regression introduced in #6745 where we stopped throwing an error for unknown keys in action configs.
github-merge-queue bot pushed a commit that referenced this pull request Feb 24, 2025
…n action configs (#6875)

* fix(config): throw validation errors when encountering unknown keys in action configs

This commit fixes a regression introduced in #6745 where we stopped throwing an error for unknown keys in action configs.

* test: add test for invalid keys in action configs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants