aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandre Rostovtsev <arostovtsev@google.com>2023-01-20 16:48:10 -0500
committerGitHub <noreply@github.com>2023-01-20 16:48:10 -0500
commit99a6bcb240e38495d45290a91357c41fd4821b61 (patch)
treecdf00b9433787a5d97c727498606fb6bfa91661f
parent5bfcb1a684550626ce138fe0fe8f5f702b3764c3 (diff)
downloadbazel-skylib-99a6bcb240e38495d45290a91357c41fd4821b61.tar.gz
Add gazelle plugin to CI and distribution mechanism (#424)
After #400, the gazelle plugin has been cleanly separated out into its own bazel workspace, which will soon finally allow us to mark it stable. But this means: * we need to change our bazelci config to explicitly build and test it, since `bazel build //...` no longer includes the plugin; * we need to add proper distribution rules for it; * we need to update release instructions, since now we will have two distribution tarballs
-rw-r--r--.bazelci/presubmit.yml57
-rw-r--r--MODULE.bazel19
-rw-r--r--MODULE.bazel-remove-override.patch16
-rw-r--r--WORKSPACE6
-rw-r--r--distribution/BUILD44
-rw-r--r--docs/maintainers_guide.md36
-rw-r--r--gazelle/BUILD22
-rw-r--r--gazelle/MODULE.bazel11
-rw-r--r--gazelle/bzl/BUILD7
-rw-r--r--version.bzl1
10 files changed, 126 insertions, 93 deletions
diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml
index 31934d2..aabe02a 100644
--- a/.bazelci/presubmit.yml
+++ b/.bazelci/presubmit.yml
@@ -1,47 +1,44 @@
---
+.reusable_config: &reusable_config
+ build_targets:
+ - "--"
+ - "//..."
+ - "@bazel_skylib_gazelle_plugin//..."
+ test_targets:
+ - "--"
+ - "//..."
+ - "@bazel_skylib_gazelle_plugin//..."
+
tasks:
ubuntu1804_latest:
+ <<: *reusable_config
name: "Latest Bazel"
platform: ubuntu1804
bazel: latest
- build_targets:
- - "//..."
- test_targets:
- - "//..."
test_flags:
- "--test_env=PATH"
ubuntu1604_latest:
+ <<: *reusable_config
name: "Latest Bazel"
platform: ubuntu1604
bazel: latest
- build_targets:
- - "//..."
- test_targets:
- - "//..."
test_flags:
- "--test_env=PATH"
macos_latest:
+ <<: *reusable_config
name: "Latest Bazel"
platform: macos
bazel: latest
- build_targets:
- - "//..."
- test_targets:
- - "//..."
test_flags:
- "--test_env=PATH"
windows_latest:
+ <<: *reusable_config
name: "Latest Bazel"
platform: windows
bazel: latest
- build_targets:
- - "//..."
- test_targets:
- - "--"
- - "//..."
test_flags:
# TODO(laszlocsomor): remove "--test_env=LOCALAPPDATA" after
# https://github.com/bazelbuild/bazel/issues/7761 is fixed
@@ -49,47 +46,34 @@ tasks:
- "--test_tag_filters=-no_windows"
ubuntu1804_last_green:
+ <<: *reusable_config
name: "Last Green Bazel"
platform: ubuntu1804
bazel: last_green
- build_targets:
- - "//..."
- test_targets:
- - "//..."
test_flags:
- "--test_env=PATH"
ubuntu1604_last_green:
+ <<: *reusable_config
name: "Last Green Bazel"
platform: ubuntu1604
bazel: last_green
- build_targets:
- - "//..."
- test_targets:
- - "//..."
test_flags:
- "--test_env=PATH"
macos_last_green:
+ <<: *reusable_config
name: "Last Green Bazel"
platform: macos
bazel: last_green
- build_targets:
- - "//..."
- test_targets:
- - "//..."
test_flags:
- "--test_env=PATH"
windows_last_green:
+ <<: *reusable_config
name: "Last Green Bazel"
platform: windows
bazel: last_green
- build_targets:
- - "//..."
- test_targets:
- - "--"
- - "//..."
test_flags:
# TODO(laszlocsomor): remove "--test_env=LOCALAPPDATA" after
# https://github.com/bazelbuild/bazel/issues/7761 is fixed
@@ -97,13 +81,10 @@ tasks:
- "--test_tag_filters=-no_windows"
ubuntu1804_last_green_bzlmod:
+ <<: *reusable_config
name: "Last Green Bazel (with bzlmod)"
platform: ubuntu1804
bazel: last_green
- build_targets:
- - "//..."
- test_targets:
- - "//..."
build_flags:
- "--experimental_enable_bzlmod"
test_flags:
diff --git a/MODULE.bazel b/MODULE.bazel
index 81b8b5c..a8de50f 100644
--- a/MODULE.bazel
+++ b/MODULE.bazel
@@ -1,8 +1,8 @@
module(
name = "bazel_skylib",
- compatibility_level = 1,
- # If you change this, please also update @bazel_skylib_gazelle_plugin//:MODULE.bazel
+ # Keep in sync with version.bzl and @bazel_skylib_gazelle_plugin//:MODULE.bazel
version = "1.3.0",
+ compatibility_level = 1,
)
register_toolchains(
@@ -15,6 +15,15 @@ bazel_dep(name = "platforms", version = "0.0.4")
### INTERNAL ONLY - lines after this are not included in the release packaging.
# Build-only / test-only dependencies
-bazel_dep(name = "stardoc", dev_dependency = True, repo_name = "io_bazel_stardoc", version = "0.5.3")
-bazel_dep(name = "rules_pkg", dev_dependency = True, version = "0.5.1")
-bazel_dep(name = "rules_cc", dev_dependency = True, version = "0.0.2")
+bazel_dep(name = "stardoc", version = "0.5.3", dev_dependency = True, repo_name = "io_bazel_stardoc")
+bazel_dep(name = "rules_pkg", version = "0.7.0", dev_dependency = True)
+bazel_dep(name = "rules_cc", version = "0.0.2", dev_dependency = True)
+
+# Needed for bazelci and for building distribution tarballs.
+# If using an unreleased version of bazel_skylib via git_override, apply
+# MODULE.bazel-remove-override.patch to remove the following lines:
+bazel_dep(name = "bazel_skylib_gazelle_plugin", dev_dependency = True)
+local_path_override(
+ module_name = "bazel_skylib_gazelle_plugin",
+ path = "gazelle",
+)
diff --git a/MODULE.bazel-remove-override.patch b/MODULE.bazel-remove-override.patch
new file mode 100644
index 0000000..0f30777
--- /dev/null
+++ b/MODULE.bazel-remove-override.patch
@@ -0,0 +1,16 @@
+--- MODULE.bazel
++++ MODULE.bazel
+@@ -22,8 +22,8 @@
+ # Needed for bazelci and for building distribution tarballs.
+ # If using an unreleased version of bazel_skylib via git_override, apply
+ # MODULE.bazel-remove-override.patch to remove the following lines:
+-bazel_dep(name = "bazel_skylib_gazelle_plugin", dev_dependency = True)
+-local_path_override(
+- module_name = "bazel_skylib_gazelle_plugin",
+- path = "gazelle",
+-)
++# bazel_dep(name = "bazel_skylib_gazelle_plugin", dev_dependency = True)
++# local_path_override(
++# module_name = "bazel_skylib_gazelle_plugin",
++# path = "gazelle",
++# )
diff --git a/WORKSPACE b/WORKSPACE
index a9c182a..0cfb154 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -40,10 +40,10 @@ stardoc_repositories()
maybe(
http_archive,
name = "rules_pkg",
- sha256 = "a89e203d3cf264e564fcb96b6e06dd70bc0557356eb48400ce4b5d97c2c3720d",
+ sha256 = "8a298e832762eda1830597d64fe7db58178aa84cd5926d76d5b744d6558941c2",
urls = [
- "https://mirror.bazel.build/github.com/bazelbuild/rules_pkg/releases/download/0.5.1/rules_pkg-0.5.1.tar.gz",
- "https://github.com/bazelbuild/rules_pkg/releases/download/0.5.1/rules_pkg-0.5.1.tar.gz",
+ "https://mirror.bazel.build/github.com/bazelbuild/rules_pkg/releases/download/0.7.0/rules_pkg-0.7.0.tar.gz",
+ "https://github.com/bazelbuild/rules_pkg/releases/download/0.7.0/rules_pkg-0.7.0.tar.gz",
],
)
diff --git a/distribution/BUILD b/distribution/BUILD
index 326cee7..8762525 100644
--- a/distribution/BUILD
+++ b/distribution/BUILD
@@ -1,6 +1,6 @@
load("@bazel_skylib//:version.bzl", "version")
load("@rules_pkg//:pkg.bzl", "pkg_tar")
-load("@rules_pkg//releasing:defs.bzl", "print_rel_notes")
+load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
package(
default_visibility = ["//visibility:private"],
@@ -13,25 +13,47 @@ genrule(
cmd = "sed -e '/### INTERNAL ONLY/,$$d' $(location //:MODULE.bazel) >$@",
)
-# Build the artifact to put on the github release page.
+# Build the artifacts to put on the github release page.
pkg_tar(
- name = "bazel-skylib-%s" % version,
+ name = "bazel-skylib",
srcs = [
"distro_module_bazel",
"//:distribution",
],
+ out = "bazel-skylib-%s.tar.gz" % version,
extension = "tar.gz",
mode = "0644",
# Make it owned by root so it does not have the uid of the CI robot.
owner = "0.0",
- strip_prefix = ".",
+ strip_prefix = strip_prefix.from_root(),
)
-print_rel_notes(
- name = "relnotes",
- outs = ["relnotes.txt"],
- deps_method = "bazel_skylib_workspace",
- repo = "bazel-skylib",
- setup_file = ":workspace.bzl",
- version = version,
+pkg_files(
+ name = "bazel-skylib-gazelle-plugin-without-external-prefix",
+ srcs = [
+ "@bazel_skylib_gazelle_plugin//:distribution",
+ "@bazel_skylib_gazelle_plugin//bzl:distribution",
+ ],
+ strip_prefix = strip_prefix.from_root(),
+)
+
+pkg_tar(
+ name = "bazel-skylib-gazelle-plugin",
+ srcs = [
+ ":bazel-skylib-gazelle-plugin-without-external-prefix",
+ "//:LICENSE",
+ ],
+ out = "bazel-skylib-gazelle-plugin-%s.tar.gz" % version,
+ extension = "tar.gz",
+ mode = "0644",
+ # Make it owned by root so it does not have the uid of the CI robot.
+ owner = "0.0",
+)
+
+filegroup(
+ name = "distribution",
+ srcs = [
+ "bazel-skylib",
+ "bazel-skylib-gazelle-plugin",
+ ],
)
diff --git a/docs/maintainers_guide.md b/docs/maintainers_guide.md
index 5339b6a..09b2f3c 100644
--- a/docs/maintainers_guide.md
+++ b/docs/maintainers_guide.md
@@ -72,25 +72,33 @@ Name 1, Name 2, Name 3 (alphabetically from `git log`)
--------------------------------------------------------------------------------
-2. Bump `version` in version.bzl *and* MODULE.bazel to the new version.
- TODO(#386): add a test to make sure the two versions are in sync.
+2. Bump `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.
3. Ensure that the commits for steps 1 and 2 have been merged. All further
steps must be performed on a single, known-good git commit.
-4. `bazel build //distribution:bazel-skylib-$VERSION.tar.gz`
-5. Copy the `bazel-skylib-$VERSION.tar.gz` tarball 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-$VERSION.tar.gz gs://bazel-mirror/github.com/bazelbuild/bazel-skylib/releases/download/$VERSION/bazel-skylib-$VERSION.tar.gz
-gsutil setmeta -h "Cache-Control: public, max-age=31536000" "gs://bazel-mirror/github.com/bazelbuild/bazel-skylib/releases/download/$VERSION/bazel-skylib-$VERSION.tar.gz"
+4. `bazel build //distribution`
+5. Copy the `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`):
+
+```bash
+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
```
-6. Run `sha256sum bazel-bin/distro/bazel-skylib-$VERSION.tar.gz`; you'll need
- the checksum for the release notes.
+6. Obtain checksums for release notes:
+
+```bash
+sha256sum bazel-bin/distro/bazel-skylib-$VERSION.tar.gz
+sha256sum bazel-bin/distro/bazel-skylib-gazelle-plugin-$VERSION.tar.gz
+````
+
7. Draft a new release with a new tag named $VERSION in github. Attach
- `bazel-skylib-$VERSION.tar.gz` to the release. For the release notes, use
- the CHANGELOG.md entry plus the following template:
+ `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:
--------------------------------------------------------------------------------
diff --git a/gazelle/BUILD b/gazelle/BUILD
index 2259933..ff51bab 100644
--- a/gazelle/BUILD
+++ b/gazelle/BUILD
@@ -1,17 +1,5 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
-# The files needed for distribution
-filegroup(
- name = "distribution",
- srcs = glob(
- ["*"],
- allow_empty = True,
- ),
- visibility = [
- "//:__pkg__",
- ],
-)
-
bzl_library(
name = "setup",
srcs = ["setup.bzl"],
@@ -32,3 +20,13 @@ bzl_library(
"@bazel_tools//tools/build_defs/repo:utils.bzl",
],
)
+
+# TODO(arostovtsev): exclude everything below from distro tarball
+filegroup(
+ name = "distribution",
+ srcs = glob(
+ ["*"],
+ allow_empty = True,
+ ),
+ visibility = ["//visibility:public"],
+)
diff --git a/gazelle/MODULE.bazel b/gazelle/MODULE.bazel
index 4620c08..b897c81 100644
--- a/gazelle/MODULE.bazel
+++ b/gazelle/MODULE.bazel
@@ -1,22 +1,21 @@
module(
name = "bazel_skylib_gazelle_plugin",
- compatibility_level = 1,
- # If you change this, please also update @bazel_gazelle//:MODULE.bazel
+ # Keep in sync with @bazel_skylib//:MODULE.bazel and @bazel_skylib//:version.bzl
version = "1.3.0",
+ compatibility_level = 1,
)
+# Keep in sync with @bazel_skylib//:MODULE.bazel and @bazel_skylib//:version.bzl
bazel_dep(name = "bazel_skylib", version = "1.3.0")
-bazel_dep(name = "gazelle", repo_name = "bazel_gazelle", version = "0.28.0")
-bazel_dep(name = "rules_go", repo_name = "io_bazel_rules_go", version = "0.35.0")
+bazel_dep(name = "gazelle", version = "0.28.0", repo_name = "bazel_gazelle")
+bazel_dep(name = "rules_go", version = "0.35.0", repo_name = "io_bazel_rules_go")
# `rules_go` will register a toolchain for us if the user doesn't do so
go_deps = use_extension("@bazel_gazelle//:extensions.bzl", "go_deps")
-
go_deps.module(
path = "github.com/bazelbuild/buildtools",
sum = "h1:fmdo+fvvWlhldUcqkhAMpKndSxMN3vH5l7yow5cEaiQ=",
version = "v0.0.0-20220531122519-a43aed7014c8",
)
-
use_repo(go_deps, "com_github_bazelbuild_buildtools")
diff --git a/gazelle/bzl/BUILD b/gazelle/bzl/BUILD
index dca6b61..ab8a719 100644
--- a/gazelle/bzl/BUILD
+++ b/gazelle/bzl/BUILD
@@ -52,6 +52,8 @@ gazelle(
gazelle = ":gazelle-skylib",
)
+# TODO(arostovtsev): exclude everything below from distro tarball
+
# The files needed for distribution
# A fake testdata directory is created so that
# the build file has nothing missing, but we
@@ -62,10 +64,7 @@ filegroup(
"BUILD",
":fake-testdata",
],
- visibility = [
- "//:__pkg__",
- "//distribution:__pkg__",
- ],
+ visibility = ["//visibility:public"],
)
genrule(
diff --git a/version.bzl b/version.bzl
index 70a04d6..0bcd28a 100644
--- a/version.bzl
+++ b/version.bzl
@@ -13,4 +13,5 @@
# limitations under the License.
"""The version of bazel-skylib."""
+# Keep in sync with MODULE.bazel and @bazel_skylib_gazelle_plugin//:MODULE.bazel
version = "1.3.0"