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

feat(templates): add ability to call templates within a template #794

Merged
merged 24 commits into from
May 30, 2023

Conversation

ecrupper
Copy link
Contributor

@ecrupper ecrupper commented Mar 22, 2023

Closes go-vela/community#256

Using a configurable max depth, this change would allow Vela users to call templates within templates.

@codecov
Copy link

codecov bot commented Mar 22, 2023

Codecov Report

Merging #794 (b712d33) into main (f7c3c6b) will increase coverage by 0.08%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #794      +/-   ##
==========================================
+ Coverage   66.13%   66.21%   +0.08%     
==========================================
  Files         297      297              
  Lines       13876    13900      +24     
==========================================
+ Hits         9177     9204      +27     
+ Misses       4252     4250       -2     
+ Partials      447      446       -1     
Impacted Files Coverage Δ
compiler/native/compile.go 63.65% <100.00%> (+1.41%) ⬆️
compiler/native/expand.go 74.19% <100.00%> (+1.77%) ⬆️
compiler/native/native.go 85.71% <100.00%> (+0.45%) ⬆️
compiler/template/native/render.go 86.95% <100.00%> (ø)

@ecrupper ecrupper marked this pull request as ready for review March 22, 2023 16:49
@ecrupper ecrupper requested a review from a team as a code owner March 22, 2023 16:49
@JordanSussman
Copy link
Collaborator

JordanSussman commented Mar 24, 2023

We may want to consider adding some caching for the getTemplate function to avoid fetching the same templates multiple times.

EDIT: the extra compile duration caused by these changes could be concerning without caching since GitHub expects a response to webhooks within 10 seconds for github.com or 30 seconds for GHES.

@ecrupper
Copy link
Contributor Author

We may want to consider adding some caching for the getTemplate function to avoid fetching the same templates multiple times.

EDIT: the extra compile duration caused by these changes could be concerning without caching since GitHub expects a response to webhooks within 10 seconds for github.com or 30 seconds for GHES.

I really like the idea of caching templates. I know we have at least a few templates that have widespread usage and definitely would take up permanent residence in that cache.

As for the extra compile duration, that is definitely something to consider. In my testing the responses were rather quick, but since template depth is renewed for each individual step, it could definitely get messy with dozens of steps each calling a chain of templates. It would be worth investigating some of those recommendations in the links related to queuing up work and giving the SCM a quick response...

cmd/vela-server/main.go Outdated Show resolved Hide resolved
@ecrupper
Copy link
Contributor Author

Putting in draft for now. Let's reopen this discussion after v0.19 is released?

@ecrupper ecrupper marked this pull request as draft April 14, 2023 21:02
@ecrupper ecrupper marked this pull request as ready for review May 22, 2023 16:55
@ecrupper
Copy link
Contributor Author

Bringing this out of draft

@ecrupper
Copy link
Contributor Author

putting this back in draft, as I decided to tackle render_inline instead of leaving it as a to-do 👍

@ecrupper ecrupper marked this pull request as draft May 22, 2023 19:11
@ecrupper ecrupper marked this pull request as ready for review May 23, 2023 16:17
Copy link
Member

@wass3rw3rk wass3rw3rk left a comment

Choose a reason for hiding this comment

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

bunch of minor things and a couple of questions.

should we validate the value that was provided for max-template-depth?

cmd/vela-server/main.go Outdated Show resolved Hide resolved
compiler/engine.go Outdated Show resolved Hide resolved
compiler/native/compile.go Show resolved Hide resolved
compiler/native/expand.go Outdated Show resolved Hide resolved
Copy link
Member

@wass3rw3rk wass3rw3rk left a comment

Choose a reason for hiding this comment

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

nice work - would like to see docs pr as well

Copy link
Contributor

@plyr4 plyr4 left a comment

Choose a reason for hiding this comment

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

nice, i like the tests

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.

Update templates to allow them to call templates.
6 participants