-
Notifications
You must be signed in to change notification settings - Fork 176
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
Extend pkg_tar rule with stamp_mtime attribute #285
Conversation
… status variables
</p> | ||
<p> | ||
<code> | ||
stamp_mtime = "{STAMP_MTIME}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this using a different name than BUILD_TIMESTAMP?
But really, this should be a bool. Either stamp the time found in BUILD_TIMESTAMP or use the portable time.
Let's discuss solutions in an issue first. I would like to to have as many people as possible weigh in on what is useful.
|
Design and requirements gathering is tracked in #287. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried my own variant in #288.
It uses a similar technique, but supports --stamp directly, without having to modify the pkg_tar rule.
I prefer that because it feeds into the stamp
behavior of the built-in rules like cc_binary. https://docs.bazel.build/versions/master/be/c-cpp.html#cc_binary
Let's finish discussion of what we want in #287 and then see what to implement.
stamp_mtime_strip = ctx.attr.stamp_mtime.strip() | ||
if not stamp_mtime_strip.startswith("{") or not stamp_mtime_strip.endswith("}"): | ||
fail("You set stamp_mtime, but this doesn't contain a valid key variable") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should just use BUILD_STAMP. We don't need the flexibility to let the user set an arbitrary variable out of the volatile status file. This adds complexity that no one asked for.
#!/usr/bin/env bash | ||
stamp_mtime=946684741 # 1999-12-31, 23:58:01 | ||
cat << EOF | ||
STAMP_MTIME ${stamp_mtime} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be BUILD_TIMESTAMP
I'm opting for the path I have taken in #288. That will works the same way as the |
This change extends the
pkg_tar
rule for stamp support for files' mtime. The attributestamp_mtime
contains a "volatile" workspace status command key which allows to set dynamic mtime for files inside tar archives. The value of the key depends on the workspace status command result but only "volatile" keys are provided as input topkg_tar
rule.The motivation behind this change relates to #149 and #192. Files are build with Bazel and added as tar archive to
container_image
rule (rules_docker). These files are served by nginx inside the container. This change should provide proper ETag values for nginx which relies on file's last modification date for caching.