-
Notifications
You must be signed in to change notification settings - Fork 38
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
Rake tasks are invoked when they shouldn't be. #95
Comments
I've done more digging into this issue and have discovered that there are 3 real issues at play here. They are all triggered by having multiple pipelines in a project (or input blocks in the The major issue is stated in the original post in this thread. This is a two step fix. Initially it may seem trivial to simply reset def fingerprint
@fingerprint ||= Digest::SHA1.hexdigest(eligible_input_files.collect(&:fullpath).join("-"))[0..7]
end
# Generate a new temporary directory name.
#
# @return [String] a unique temporary directory name
def generate_tmpname
"pipeline-tmp-#{fingerprint}-#{@tmp_id += 1}"
end Hash generation may be slow, but it will work as an initial case and patch. This method should be reworked to be faster. Solving problem #1 means the def dynamic?
has_dynamic_block? && !invoke_dynamic_block.empty?
end The def needed?
# tasks without dynamic deps are just regular file tasks. Act accordingly.
return super unless dynamic?
# if we have no manifest, this file task is needed
return true !last_manifest_entry
# If any of this task's dynamic dependencies have changed,
# this file task is needed
last_manifest_entry.deps.each do |dep, time|
if File.mtime(dep) > time
return true
end
end
# Otherwise, it's not needed
false
end This solves the logic errors. At this point There is an issue with manifest and multiple pipelines. The problem is here: https://github.com/livingsocial/rake-pipeline/blob/master/lib/rake-pipeline/project.rb#L130. The manifest is actually written at the end of all pipelines. This means that calls to All in all, all the issues can be resolved by moving genration of temporary directory to the instance level, fixing @wycats there is your epic update. |
@twinturbo should this be closed since #99 was merged? |
@wagenet ya you can close this |
@twinturbo I can't close it. Don't have admin :( Can't you close tickets you made? |
I've been chasing down an issue related to "caching" in my application's pipeline. I think I've finally found the problem. I'm assuming this is true: I build the pipeline. I don't change anything. Building the pipeline again should "skip" everything since no input files have changed. IE: only rebuild the pipeline if input files have changed.
This behavior is accomplished through
Rake::FileTask
s. Each filter in the pipeline is a rake rask that setups up a task with preqreqs (the input files).Rake::FileTask
decides if a task should be invoked by looking at itself and it's preqreqs. If anyone of those need to be invoked it will be done.Rake::FileTask
simply checks File.mtime to see if a file as changed. It compares the preqreq timestamp to the file itself. If the prereq is newer than the file itself then the task needs to be invoked again. This is the call tosuper
in theRake::Pipeline::DynamicFileTask#needed?
. The class also does it's own logic but that's unimportant because it will return ifsuper
is true.Internally all files in the build process are copied into a tmp directory. This make sense. However there is a problem. The tmp directory is unique per process. The variable is incremented automatically every time the method is called. Here's the link to the method: https://github.com/livingsocial/rake-pipeline/blob/master/lib/rake-pipeline.rb#L389. This means that isolated builds of the same pipeline (inputs and assetfile) will generate the same number of temp directories. The intermediate build files should be the same and be skipped accordingly. The problem occurs when multiple build occur from the same process. This is the exact use case for the preview server--however I'm not sure if this the intended use case.
Building the pipeline multiple times in the same process will continually increment the class variable. The second time the pipeline is invoked, files will be placed into new temporary directories. The dependencies are also wired up. However since a new file is created every time, File.mtime will always be newer than before causing rake tasks to be invoked when they shouldn't. I think this is a major problem.
Here is my debugging session from deep inside rake to find out what bit of code is actually making that decision. It's from inside this method: https://github.com/jimweirich/rake/blob/master/lib/rake/file_task.rb#L32
Here is the assetfile used in my project: https://github.com/radiumsoftware/iridium/blob/master/lib/iridium/Assetfile
@dudleyf @wycats can you confirm this is a bug?
The text was updated successfully, but these errors were encountered: