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

chore: cache custom generators #311

Merged
merged 5 commits into from
Mar 30, 2022
Merged

Conversation

shortcuts
Copy link
Member

🧭 What and Why

🎟 JIRA Ticket: -

Changes included:

This PR extracts the caching logic of the build specs step to use it when building custom generators.

🧪 Test

CI :D

@shortcuts shortcuts requested a review from millotp March 30, 2022 09:36
@shortcuts shortcuts self-assigned this Mar 30, 2022
@netlify
Copy link

netlify bot commented Mar 30, 2022

Deploy Preview for api-clients-automation canceled.

Name Link
🔨 Latest commit 7162df1
🔍 Latest deploy log https://app.netlify.com/sites/api-clients-automation/deploys/624432f2694de8000834fdcf

@algolia-bot
Copy link
Collaborator

algolia-bot commented Mar 30, 2022

✗ The generated branch has been deleted.

If the PR has been merged, you can check the generated code on the generated/main branch.

Copy link
Collaborator

@millotp millotp left a comment

Choose a reason for hiding this comment

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

Good idea ! It could be applied to everything ahah

return cache;
}

for (const fileToCache of filesToCache) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this would be more elegant with map and join('-')

Copy link
Member Author

Choose a reason for hiding this comment

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

But less readable :( I'd rather keep this one

Copy link
Collaborator

Choose a reason for hiding this comment

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

by elegant I meant readable, as you prefer

@shortcuts
Copy link
Member Author

It could be applied to everything ahah

Yep definitely, but already a good starting point :D

@shortcuts shortcuts enabled auto-merge (squash) March 30, 2022 10:29
@shortcuts shortcuts requested a review from millotp March 30, 2022 13:37
{
job: 'custom generators',
folder: toAbsolutePath('generators/'),
generatedFiles: ['build'],
Copy link
Collaborator

Choose a reason for hiding this comment

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

The issue with only checking if the generatedFiles exists is that they are not just files, build is a folder and if you remove something in it, the cache skip but the gen won't work.
One way to solve it would be to enforce real files in the generatedFiles list, no folder, for example it would be build/libs/algolia-java-openapi-generator-1.0.0.jar.
But then it would make the cache harder to use, if we really want all the files under build for the cache to be valid, then we can also store a hash of the generated files and compare that

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'll let you choose what to do here

Copy link
Member Author

Choose a reason for hiding this comment

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

I've went with the naive solution because I wanted to have it merged before the demo, but storing hash as we do on the CI might be the more precise solution.

Copy link
Member Author

@shortcuts shortcuts Mar 30, 2022

Choose a reason for hiding this comment

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

fun fact, I had the local changes during the demo but built #313 before so it invalidated the cache and added like 5s to the demo 🤷🏼

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah on the CI they store a zip of the generated files it's even more hardcore

{
job: 'custom generators',
folder: toAbsolutePath('generators/'),
generatedFiles: ['build'],
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'll let you choose what to do here

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.

3 participants