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

Script caching won't revalidate if script contains multiple files #4131

Open
2 tasks done
GeertvanHorrik opened this issue Mar 30, 2023 · 1 comment
Open
2 tasks done

Comments

@GeertvanHorrik
Copy link
Contributor

Prerequisites

  • I have written a descriptive issue title
  • I have searched issues to ensure it has not already been reported

Cake runner

Cake .NET Tool

Cake version

3.0.0

Operating system

Windows

Operating system architecture

64-Bit

CI Server

No response

What are you seeing?

I would like to enable this feature to see if we can take off a few minutes per build.

For now I would like to add a script cache per project (e.g. %temp%/cake-build/cache/my-project). This value will be set via an environment variable.

However, I checked the code and noticed that only the main script will be used for hash calculation. This means that if I change any of the "included files", the hash will not change.

In our case, we have several scripts that we include with this:

#l "./deployment/cake/tasks.cake"

Unfortunately, this file includes a lot of new includes, so I think there are a few options here:

Pre-process the script by parsing all the includes and use this to generate a hash for the "full script"

Cons: might be a bit slower
Pros: reliable script cache hash

Allow configuration of directories to include in the scripts

Cons: more configuration (but we can automate / use environment variable)
Pros: less "pre-processing", so "faster"

What is expected?

N/A

Steps to Reproduce

N/A

Output log

No response

@tstewart65
Copy link
Contributor

tstewart65 commented Mar 30, 2023

At the point in the code you are linking to the script is the complete script with all of the processing done. The ScriptRunner class calls the script analyzer which processes the script.

I currently use the caching on my projects and I use the #load to load a custom recipe we use. We use a nuget package for the recipe so technically if we change the external files the main script will also change for the version change. But for testing I go in and change the files in the cake tools folder where the nuget package exists and the changes are picked and the cached assembly is updated.

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

No branches or pull requests

2 participants