I would like to be able to run the task only if the source file was changed.
Proposed Solution
Since calculating the hash sum of a file can take a long time, depending on the size and number of files, it would make sense to find the SHA of the commit on which the file was modified:
If the sha of the file differs from the cached one, then the task is started.
API Stability
To maintain backward compatibility, we can add a new parameter to the task that defines the methods for comparing source files:
[task.foo]
diff_strategy = ["timestamp", "git"]
In the future, it will be possible to add a diff strategy based on the checksum of the file.
Alternative Solution
A more flexible option is to add a parameter for embedding scripts whose stdout would be cached, based on which comparisons between runs would occur:
# Example 1: install a tool that cannot be deployed locally
[task.install_brew]
checksum = [
"brew --version",
"echo $REQUIRED_BREW_VERSION"
]
run = "<command to install brew>"
# Example 2: compile binary only if sources changed
[task.compile_binary]
checksum = "md5 script.cpp"
run = "<command to compile script binary>"
# Example 3: codegen if sources changed (on git checkout)
checksum = "git log -1 ..."
run = "swiftgen run ..."
Hi 👋 @jdx !
Motivation
I would like to be able to run the task only if the source file was changed.
Proposed Solution
Since calculating the hash sum of a file can take a long time, depending on the size and number of files, it would make sense to find the SHA of the commit on which the file was modified:
If the sha of the file differs from the cached one, then the task is started.
API Stability
To maintain backward compatibility, we can add a new parameter to the task that defines the methods for comparing source files:
In the future, it will be possible to add a diff strategy based on the checksum of the file.
Alternative Solution
A more flexible option is to add a parameter for embedding scripts whose stdout would be cached, based on which comparisons between runs would occur: