-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add
bzlmod_e2e
in preparation for publishing to BCR (#234)
- Add `examples/bzlmod_e2e` child workspace as test for publish_to_bcr presubmit. - Add `.bcr` files for public_to_bcr. Related to #195.
- Loading branch information
Showing
30 changed files
with
408 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fixedReleaser: | ||
login: cgrindel | ||
email: chuck.grindel@gmail.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"homepage": "https://github.com/cgrindel/bazel-starlib", | ||
"maintainers": [ | ||
{ | ||
"email": "chuck.grindel@gmail.com", | ||
"github": "cgrindel", | ||
"name": "Chuck Grindel" | ||
} | ||
], | ||
"repository": [ | ||
"github:OWNER/REPO" | ||
], | ||
"versions": [], | ||
"yanked_versions": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
bcr_test_module: | ||
module_path: "examples/bzlmod_e2e" | ||
matrix: | ||
platform: ["macos", "ubuntu2004"] | ||
tasks: | ||
run_tests: | ||
name: "Run test module" | ||
platform: ${{ platform }} | ||
test_targets: | ||
- "//..." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"integrity": "", | ||
"strip_prefix": "{REPO}-{VERSION}", | ||
"url": "https://github.com/{OWNER}/{REPO}/archive/refs/tags/{TAG}.tar.gz" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
load( | ||
"@contrib_rules_bazel_integration_test//bazel_integration_test:defs.bzl", | ||
"bazel_integration_tests", | ||
"default_test_runner", | ||
"integration_test_utils", | ||
) | ||
load("//:bazel_versions.bzl", "CURRENT_BAZEL_VERSION", "SUPPORTED_BAZEL_VERSIONS") | ||
load("//bzlformat:defs.bzl", "bzlformat_pkg") | ||
load("//bzllib:defs.bzl", "lists") | ||
|
||
bzlformat_pkg(name = "bzlformat") | ||
|
||
# MARK: - Integration Tests | ||
|
||
_EXAMPLE_DIRS = ["bzlmod_e2e"] | ||
|
||
default_test_runner(name = "default_test_runner") | ||
|
||
[ | ||
bazel_integration_tests( | ||
name = "{}_test".format(dirname), | ||
timeout = "eternal", | ||
bazel_versions = SUPPORTED_BAZEL_VERSIONS, | ||
test_runner = ":default_test_runner", | ||
workspace_files = integration_test_utils.glob_workspace_files(dirname) + [ | ||
"//:workspace_integration_test_files", | ||
], | ||
workspace_path = dirname, | ||
) | ||
for dirname in _EXAMPLE_DIRS | ||
] | ||
|
||
test_suite( | ||
name = "smoke_integration_tests", | ||
tags = integration_test_utils.DEFAULT_INTEGRATION_TEST_TAGS, | ||
tests = [ | ||
integration_test_utils.bazel_integration_test_name( | ||
":{}_test".format(dirname), | ||
CURRENT_BAZEL_VERSION, | ||
) | ||
for dirname in _EXAMPLE_DIRS | ||
], | ||
visibility = ["//:__subpackages__"], | ||
) | ||
|
||
test_suite( | ||
name = "integration_tests", | ||
tags = integration_test_utils.DEFAULT_INTEGRATION_TEST_TAGS, | ||
tests = lists.flatten([ | ||
integration_test_utils.bazel_integration_test_names( | ||
":{}_test".format(dirname), | ||
SUPPORTED_BAZEL_VERSIONS, | ||
) | ||
for dirname in _EXAMPLE_DIRS | ||
]), | ||
visibility = ["//:__subpackages__"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Import Shared settings | ||
import %workspace%/../../shared.bazelrc | ||
|
||
# Import CI settings. | ||
import %workspace%/../../ci.bazelrc | ||
|
||
# Try to import a local.rc file; typically, written by CI | ||
try-import %workspace%/../../local.bazelrc | ||
|
||
# Explicitly enable bzlmod | ||
common --enable_bzlmod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
load( | ||
"@cgrindel_bazel_starlib//bzlformat:defs.bzl", | ||
"bzlformat_missing_pkgs", | ||
"bzlformat_pkg", | ||
) | ||
load("@cgrindel_bazel_starlib//markdown:defs.bzl", "markdown_pkg") | ||
load( | ||
"@cgrindel_bazel_starlib//updatesrc:defs.bzl", | ||
"updatesrc_update_all", | ||
) | ||
|
||
# Ensures that the Starlark files in this package are formatted properly. | ||
bzlformat_pkg(name = "bzlformat") | ||
|
||
# Provides targets to find, test, and fix any Bazel packages that are missing bzlformat_pkg | ||
# declarations. | ||
# | ||
# bzlformat_missing_pkgs_find: Find and report any Bazel packages that missing the bzlformat_pkg | ||
# declaration. | ||
# bzlformat_missing_pkgs_test: Like find except it fails if any missing packages are found. This is | ||
# useful to run in CI tests to ensure that all is well. | ||
# bzlformat_missing_pkgs_fix: Adds bzlformat_pkg declarations to any packages that are missing | ||
# the declaration. | ||
bzlformat_missing_pkgs(name = "bzlformat_missing_pkgs") | ||
|
||
# Define a runnable target to execute all of the updatesrc_update targets | ||
# that are defined in your workspace. | ||
updatesrc_update_all( | ||
name = "update_all", | ||
targets_to_run = [ | ||
# Fix the Bazel packages when we update our source files from build outputs. | ||
":bzlformat_missing_pkgs_fix", | ||
], | ||
) | ||
|
||
# Ensure that the markdown files are formatted properly | ||
markdown_pkg(name = "markdown") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module( | ||
name = "bzlmod_e2e", | ||
version = "0.0.0", | ||
compatibility_level = 1, | ||
) | ||
|
||
bazel_dep(name = "cgrindel_bazel_starlib", version = "0.0.0") | ||
local_path_override( | ||
module_name = "cgrindel_bazel_starlib", | ||
path = "../..", | ||
) | ||
|
||
bazel_dep(name = "bazel_skylib", version = "1.4.1") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# E2E Test Workspace for bzlmod | ||
|
||
This workspace demonstrates a number of `bazel-starlib` capabilities in a bzlmod-enabled repository. | ||
|
||
## Table of Contents | ||
|
||
The following TOC is maintained by a | ||
[`markdown_generate_toc`](https://github.com/cgrindel/bazel-starlib/blob/main/doc/markdown/rules_and_macros_overview.md#markdown_generate_toc) | ||
rule that is defined by a | ||
[`markdown_pkg`](https://github.com/cgrindel/bazel-starlib/blob/main/doc/markdown/rules_and_macros_overview.md#markdown_pkg). | ||
|
||
<!-- MARKDOWN TOC: BEGIN --> | ||
* [Foo](#foo) | ||
* [Foo Subtitle](#foo-subtitle) | ||
* [Bar](#bar) | ||
<!-- MARKDOWN TOC: END --> | ||
|
||
## Foo | ||
|
||
This section talks about foo. | ||
|
||
### Foo Subtitle | ||
|
||
This section talks about something specific to foo. | ||
|
||
## Bar | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Intentionally blank | ||
# This repository uses bzlmod. Please see MODULE.bazel for configuration. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
load("@bazel_skylib//:bzl_library.bzl", "bzl_library") | ||
|
||
package(default_visibility = ["//visibility:public"]) | ||
|
||
exports_files(["header.sh"]) | ||
|
||
sh_binary( | ||
name = "add_header", | ||
srcs = ["header.sh"], | ||
) | ||
|
||
bzl_library( | ||
name = "header", | ||
srcs = ["header.bzl"], | ||
deps = ["@cgrindel_bazel_starlib//updatesrc:defs"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
load( | ||
"@cgrindel_bazel_starlib//updatesrc:defs.bzl", | ||
"UpdateSrcsInfo", | ||
"update_srcs", | ||
) | ||
|
||
def _header_impl(ctx): | ||
outs = [] | ||
updsrcs = [] | ||
for src in ctx.files.srcs: | ||
out = ctx.actions.declare_file(src.basename + "_with_header") | ||
outs.append(out) | ||
updsrcs.append(update_srcs.create(src = src, out = out)) | ||
ctx.actions.run( | ||
outputs = [out], | ||
inputs = [src], | ||
executable = ctx.executable._header_tool, | ||
arguments = [src.path, out.path, ctx.attr.header], | ||
) | ||
|
||
return [ | ||
DefaultInfo(files = depset(outs)), | ||
UpdateSrcsInfo(update_srcs = depset(updsrcs)), | ||
] | ||
|
||
header = rule( | ||
implementation = _header_impl, | ||
attrs = { | ||
"header": attr.string( | ||
mandatory = True, | ||
), | ||
"srcs": attr.label_list( | ||
allow_files = True, | ||
mandatory = True, | ||
), | ||
"_header_tool": attr.label( | ||
default = "//header:header.sh", | ||
executable = True, | ||
cfg = "exec", | ||
allow_files = True, | ||
), | ||
}, | ||
doc = "Copies the output files to the workspace directory.", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
src="$1" | ||
out="$2" | ||
header="$3" | ||
|
||
first_line=$(head -n 1 "${src}") | ||
if [[ "${first_line}" != "${header}" ]]; then | ||
echo "${header}" > "${out}" | ||
fi | ||
cat "${src}" >> "${out}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
load("@bazel_skylib//:bzl_library.bzl", "bzl_library") | ||
load("@cgrindel_bazel_starlib//bzlformat:defs.bzl", "bzlformat_pkg") | ||
|
||
bzl_library( | ||
name = "mockascript", | ||
srcs = ["mockascript.bzl"], | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
"//mockascript/internal:mockascript_library", | ||
"@cgrindel_bazel_starlib//bzlformat:defs", | ||
], | ||
) | ||
|
||
bzlformat_pkg() | ||
|
||
bzl_library( | ||
name = "deps", | ||
srcs = ["deps.bzl"], | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
"@bazel_tools//tools/build_defs/repo:http.bzl", | ||
"@bazel_tools//tools/build_defs/repo:utils.bzl", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
"""Dependencies for mockascript rules.""" | ||
|
||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | ||
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") | ||
|
||
def mockascript_rules_dependencies(): | ||
maybe( | ||
http_archive, | ||
name = "bazel_skylib", | ||
sha256 = "1c531376ac7e5a180e0237938a2536de0c54d93f5c278634818e0efc952dd56c", | ||
urls = [ | ||
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.0.3/bazel-skylib-1.0.3.tar.gz", | ||
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.3/bazel-skylib-1.0.3.tar.gz", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
load("@bazel_skylib//:bzl_library.bzl", "bzl_library") | ||
load("@cgrindel_bazel_starlib//bzlformat:defs.bzl", "bzlformat_pkg") | ||
|
||
package(default_visibility = ["//mockascript:__subpackages__"]) | ||
|
||
bzlformat_pkg(name = "bzlformat") | ||
|
||
bzl_library( | ||
name = "foo", | ||
srcs = ["foo.bzl"], | ||
) | ||
|
||
bzl_library( | ||
name = "mockascript_library", | ||
srcs = ["mockascript_library.bzl"], | ||
) |
Oops, something went wrong.