You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
pkg_npm should support stamping with arbitrary stable/volatile keys #1694
I want to be able to stamp multiple pieces of version information in npm archive.
Describe the solution you'd like
pkg_npm (and probably pkg_web) should allow values to use make-style variable replacements in the substitutions dictionary. The keys would still refer to strings in the source files to find and replace.
pkg_npm(
substitutions= {
# normal substitution"blaze": "bazel",
# Make-style substitutions (from both volatile-keys and stable-keys)"GIT_HASH": "$(BUILD_SCM_HASH)",
"HOST": "$(BUILD_HOST)",
"GIT_BRANCH": "$(STABLE_SCM_BRANCH)",
},
stamp=1# or 0,
)
Describe alternatives you've considered
Writing a rule to manually copy the info from the version file into the relevant files.
Yea I can look into it hopefully. I would want to see your thoughts on #1693 and how it relates to this ticket. My needs would only be satisfied here if I could mark some targets as to never rely on stamping and some conditional on the stamp flag.
It seems like there might be place for a generic rule or task that makes the stamping easy for plain text interpolations as opposed to duplicating this functionality in multiple places.
Also I'd be curious why it's good to support both stable keys and volatile keys. In particular since contributing npm publishing to bazelisk I was wondering why they use the stable keys file, and whether we should be recommending users to do the same. @philwo if you have a minute to comment?
It would seem that the use of stable keys vs. volatile keys is up to the needs of the user/organization. Some orgs may want to re-use via cache as much as possible and only ever stamp an artifact the first time its contents are generated, and others may want to re-stamp it when certain criteria is met (branch change, user/host change, etc...)
It would seem to me that the stamping feature of Bazel is representative of the needs of Google but may not be very flexible for a wider variety of needs, especially when it comes to remote caching of stamped builds
Okay I just did stamping at work with rules_go so it's super clear what to do (they did a nice job in rules_go docs of presenting it simply as well, so I'll borrow from them)
Activity
alexeagle commentedon Mar 7, 2020
Yeah that makes a lot of sense. Do you have time to contribute it?
joeljeske commentedon Mar 8, 2020
Yea I can look into it hopefully. I would want to see your thoughts on #1693 and how it relates to this ticket. My needs would only be satisfied here if I could mark some targets as to never rely on stamping and some conditional on the stamp flag.
It seems like there might be place for a generic rule or task that makes the stamping easy for plain text interpolations as opposed to duplicating this functionality in multiple places.
alexeagle commentedon Mar 9, 2020
Also I'd be curious why it's good to support both stable keys and volatile keys. In particular since contributing npm publishing to bazelisk I was wondering why they use the stable keys file, and whether we should be recommending users to do the same. @philwo if you have a minute to comment?
philwo commentedon Mar 9, 2020
@meisterT told me he can help us out here. I'm not very knowledgeable about this particular feature of Bazel.
joeljeske commentedon Mar 9, 2020
It would seem that the use of stable keys vs. volatile keys is up to the needs of the user/organization. Some orgs may want to re-use via cache as much as possible and only ever stamp an artifact the first time its contents are generated, and others may want to re-stamp it when certain criteria is met (branch change, user/host change, etc...)
It would seem to me that the stamping feature of Bazel is representative of the needs of Google but may not be very flexible for a wider variety of needs, especially when it comes to remote caching of stamped builds
thesayyn commentedon Jun 22, 2020
I have opened up a PR for the stamping feature of pkg_web a long time ago. It works the way you've described. Which still waiting for a review BTW.
See #1621, #1664
mattem commentedon Jun 22, 2020
@thesayyn, thanks for the contribution, apologies that we missed following up the on review. I'll take a look at the PR shortly and ping Alex too.
thesayyn commentedon Jun 22, 2020
Thank you. Also, I can implement the same feature for pkg_npm too.
alexeagle commentedon Aug 30, 2020
Okay I just did stamping at work with rules_go so it's super clear what to do (they did a nice job in rules_go docs of presenting it simply as well, so I'll borrow from them)
feat(builtin): accept any stamp vars in pkg_npm
feat(builtin): accept any stamp vars in pkg_npm
feat(builtin): accept any stamp vars in pkg_npm
feat(builtin): accept any stamp vars in pkg_npm
feat(builtin): accept any stamp vars in pkg_npm
feat(builtin): accept any stamp vars in pkg_npm
feat(builtin): accept any stamp vars in pkg_npm
alexeagle commentedon Aug 31, 2020
Fixed by #2157
fix: test file pattern (bazel-contrib#2089)