bzl_library.bzl
- used by almost all rule sets, and thus requiring especial attention to maintaining backwards compatibility. Ideally, it ought to be moved out of Skylib and and into Bazel's bundled @bazel_tools
repo (see https://github.com/bazelbuild/bazel-skylib/issues/127).rules/analysis_test.bzl
, rules/build_test.bzl
, lib/unittest.bzl
; these are under more active development than the rest of Skylib, because we want to provide rule authors with a good testing story. Ideally, these ought to be moved out of Skylib and evolved at a faster pace.Because Skylib is so widely used, breaking backwards compatibility can cause widespread pain, and shouldn't be done lightly. Therefore:
native.foobar()
method which was introduced in the latest Bazel pre-release or is gated behind an --incompatible
flag, use an if hasattr(native, "foobar")
check to keep the rest of your module (which doesn't need native.foobar()
) working even when native.foobar()
is not available.In addition, make sure that new code is documented and tested.
If a PR changes any docstring in an existing module, the corresponding stardoc_with_diff_test
in docs
will fail. To fix the test, ask the PR author to run bazel run //docs:update
.
If a PR adds a new module, make sure that the PR also adds a corresponding stardoc_with_diff_test
target in docs/BUILD
and a corresponding *doc.md
file under docs
(generated by bazel run //docs:update
).
Release $VERSION
New Features
Incompatible Changes
Contributors
Name 1, Name 2, Name 3 (alphabetically from git log
)
version
in version.bzl, MODULE.bazel, and gazelle/MODULE.bazel to the new version. TODO(#386): add a test to make sure all the versions are in sync.bazel build //distribution
bazel-skylib-$VERSION.tar.gz
and bazel-skylib-gazelle-plugin-$VERSION.tar.gz
tarballs to the mirror (you'll need Bazel developer gcloud credentials; assuming you are a Bazel developer, you can obtain them via gcloud init
):gsutil cp bazel-bin/distribution/bazel-skylib{,-gazelle-plugin}-$VERSION.tar.gz gs://bazel-mirror/github.com/bazelbuild/bazel-skylib/releases/download/$VERSION/ gsutil setmeta -h "Cache-Control: public, max-age=31536000" gs://bazel-mirror/github.com/bazelbuild/bazel-skylib/releases/download/$VERSION/bazel-skylib{,-gazelle-plugin}-$VERSION.tar.gz
sha256sum bazel-bin/distribution/bazel-skylib-$VERSION.tar.gz sha256sum bazel-bin/distribution/bazel-skylib-gazelle-plugin-$VERSION.tar.gz
bazel-skylib-$VERSION.tar.gz
and bazel-skylib-gazelle-plugin-$VERSION.tar.gz
to the release. For the release notes, use the CHANGELOG.md entry plus the following template:WORKSPACE setup
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( name = "bazel_skylib", sha256 = "$SHA256SUM" urls = [ "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/$VERSION/bazel-skylib-$VERSION.tar.gz", "https://github.com/bazelbuild/bazel-skylib/releases/download/$VERSION/bazel-skylib-$VERSION.tar.gz", ], ) load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") bazel_skylib_workspace()
Additional WORKSPACE setup for the Gazelle plugin
http_archive( name = "bazel_skylib_gazelle_plugin", sha256 = "$SHA256SUM_GAZELLE_PLUGIN", urls = [ "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/$VERSION/bazel-skylib-gazelle-plugin-$VERSION.tar.gz", "https://github.com/bazelbuild/bazel-skylib/releases/download/$VERSION/bazel-skylib-gazelle-plugin-$VERSION.tar.gz", ], ) load("@bazel_skylib_gazelle_plugin//:workspace.bzl", "bazel_skylib_gazelle_plugin_workspace") bazel_skylib_gazelle_plugin_workspace() load("@bazel_skylib_gazelle_plugin//:setup.bzl", "bazel_skylib_gazelle_plugin_setup") bazel_skylib_gazelle_plugin_setup()
Using the rules
See the source.
echo -n sha256-; cat bazel-bin/distribution/bazel-skylib-$VERSION.tar.gz | openssl dgst -sha256 -binary | base64 echo -n sha256-; cat bazel-bin/distribution/bazel-skylib-gazelle-plugin-$VERSION.tar.gz | openssl dgst -sha256 -binary | base64
Create a PR at Bazel Central Registry to update the registry's versions of bazel_skylib and bazel_skylib_gazelle_plugin.
Use https://github.com/bazelbuild/bazel-central-registry/pull/403 as the model; you will need to update modules/bazel_skylib/metadata.json
and modules/bazel_skylib_gazelle_plugin/metadata.json
to list the new version in versions
, and create new $VERSION subdirectories for the updated modules, using the latest existing version subdirectories as the guide. Use Subresource Integrity checksums obtained above in the new source.json
files.
Ensure that the MODULE.bazel files you add in the new $VERSION subdirectories exactly match the MODULE.bazel file packaged in bazel-skylib-$VERSION.tar.gz and bazel-skylib-gazelle-plugin-$VERSION.tar.gz tarballs - or buildkite checks will fail.
Once the Bazel Central Registry PR is merged, insert in the release description after the WORKSPACE setup section:
MODULE.bazel setup
bazel_dep(name = "bazel_skylib", version = "$VERSION")
And for the Gazelle plugin:
bazel_dep(name = "bazel_skylib_gazelle_plugin", version = "$VERSION", dev_dependency = True)