Skip to content

Commit

Permalink
chore: use coreutils hashsum (#333)
Browse files Browse the repository at this point in the history
  • Loading branch information
thesayyn authored Mar 10, 2023
1 parent be41c1d commit e318673
Show file tree
Hide file tree
Showing 54 changed files with 139 additions and 200 deletions.
2 changes: 1 addition & 1 deletion .bcr/presubmit.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
bcr_test_module:
module_path: "e2e/bzlmod"
module_path: "e2e/smoke"
matrix:
platform: ["debian10", "macos", "ubuntu2004", "windows"]
tasks:
Expand Down
29 changes: 18 additions & 11 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,22 +83,20 @@ jobs:
config: ${{ fromJSON(needs.matrix-prep-config.outputs.configs) }}
bazelversion: ${{ fromJSON(needs.matrix-prep-bazelversion.outputs.bazelversions) }}
os: ${{ fromJSON(needs.matrix-prep-os.outputs.os) }}
bzlmodEnabled: [true, false]
folder:
- "."
- "e2e/bzlmod"
- "e2e/coreutils"
- "e2e/copy_to_directory"
- "e2e/workspace"
- "e2e/smoke"
exclude:
# bzlmod broken at 5.3.2 which the RBE:
# ```
# ERROR: /home/runner/work/bazel-lib/bazel-lib/e2e/bzlmod/BUILD.bazel:37:10: While resolving
# toolchains for target //:test: com.google.devtools.build.lib.packages.BuildFileNotFoundException:
# no such package '@aspect_bazel_lib//platforms': The repository '@aspect_bazel_lib' could not be
# resolved: Repository '@aspect_bazel_lib' is not defined
# ```
- config: rbe
# this e2e meant to work under bzlmod
- bzlmodEnabled: false
folder: bzlmod_write_source_files_external

# Don't test Bazel 5.3 with bzlmod. (Unrecognized option: --enable_bzlmod)
- bzlmodEnabled: true
bazelversion: 5.3.2
folder: e2e/bzlmod
# Don't test MacOS with RBE to minimize MacOS minutes (billed at 10X)
- config: rbe
os: macos-latest
Expand Down Expand Up @@ -164,6 +162,14 @@ jobs:
rm -Force .aspect/bazelrc/bazel6.bazelrc
}
- name: Set bzlmod flag
# Store the --enable_bzlmod flag that we add to the test command below
# only when we're running bzlmod in our test matrix.
id: set_bzlmod_flag
if: matrix.bzlmodEnabled
run: echo "bzlmod_flag=--enable_bzlmod" >> $GITHUB_OUTPUT

- name: Write engflow credentials
if: ${{ matrix.config == 'rbe' }}
working-directory: ${{ matrix.folder }}
Expand Down Expand Up @@ -200,6 +206,7 @@ jobs:
--bazelrc=${{ github.workspace }}/.github/workflows/ci.bazelrc `
--bazelrc=${{ github.workspace }}/.aspect/bazelrc/bazel$BAZEL_MAJOR_VERSION.bazelrc `
--bazelrc=.bazelrc `
${{ steps.set_bzlmod_flag.outputs.bzlmod_flag }}
test --config=${{ matrix.config }} //...
env:
# Bazelisk will download bazel to here
Expand Down
3 changes: 2 additions & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ bazel_dep(name = "stardoc", repo_name = "io_bazel_stardoc", version = "0.5.0")

ext = use_extension("@aspect_bazel_lib//lib:extensions.bzl", "ext")

use_repo(ext, "copy_directory_toolchains", "copy_to_directory_toolchains", "jq_toolchains", "yq_toolchains")
use_repo(ext, "copy_directory_toolchains", "copy_to_directory_toolchains", "jq_toolchains", "yq_toolchains", "coreutils_toolchains")

register_toolchains(
"@copy_directory_toolchains//:all",
"@copy_to_directory_toolchains//:all",
"@jq_toolchains//:all",
"@yq_toolchains//:all",
"@coreutils_toolchains//:all"
)
95 changes: 0 additions & 95 deletions e2e/bzlmod/BUILD.bazel

This file was deleted.

2 changes: 0 additions & 2 deletions e2e/bzlmod/WORKSPACE

This file was deleted.

1 change: 0 additions & 1 deletion e2e/bzlmod/defs.bzl

This file was deleted.

4 changes: 0 additions & 4 deletions e2e/bzlmod/docs.md

This file was deleted.

2 changes: 1 addition & 1 deletion e2e/bzlmod_write_source_files_external/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module(
name = "e2e_bzlmod_write_source_files_external",
name = "bzlmod_write_source_files_external",
compatibility_level = 1,
version = "0.0.0",
)
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module(
name = "e2e_bzlmod",
name = "copy_to_directory",
compatibility_level = 1,
version = "0.0.0",
)
Expand Down
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
40 changes: 40 additions & 0 deletions e2e/coreutils/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files")
load("@aspect_bazel_lib//tools:hashes.bzl", "hashes")

genrule(
name = "ls",
outs = ["ls.txt"],
cmd = "$(COREUTILS_BIN) ls > $@",
toolchains = ["@coreutils_toolchains//:resolved_toolchain"],
)

hashes(
name = "hash",
src = "test.bin"
)

filegroup(
name = "md5",
output_group = "md5",
srcs = [":hash"]
)

filegroup(
name = "sha1",
output_group = "sha1",
srcs = [":hash"]
)


# This tests that the "in" file to write_source_files can be a
# label to an external repository target when bzlmod is enabled.
write_source_files(
name = "write_ls",
files = {
"ls.txt.expected": ":ls.txt",
"sha256.txt": ":hash",
"sha1.txt": ":sha1",
"md5.txt": ":md5"
},
)

15 changes: 15 additions & 0 deletions e2e/coreutils/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module(
name = "coreutils",
compatibility_level = 1,
version = "0.0.0",
)

bazel_dep(name = "aspect_bazel_lib", version = "0.0.0")

local_path_override(
module_name = "aspect_bazel_lib",
path = "../..",
)

ext = use_extension("@aspect_bazel_lib//lib:extensions.bzl", "ext")
use_repo(ext, "coreutils_toolchains")
10 changes: 10 additions & 0 deletions e2e/coreutils/WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
local_repository(
name = "aspect_bazel_lib",
path = "../..",
)

load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies", "register_coreutils_toolchains")

aspect_bazel_lib_dependencies()

register_coreutils_toolchains()
Empty file added e2e/coreutils/WORKSPACE.bzlmod
Empty file.
2 changes: 2 additions & 0 deletions e2e/coreutils/ls.txt.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bazel-out
external
1 change: 1 addition & 0 deletions e2e/coreutils/md5.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
160e389707f172f2d1333084fec4e650 test.bin
1 change: 1 addition & 0 deletions e2e/coreutils/sha1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
b3dd96b0db6a12a3ae53899e8fbc04b749c980d6 test.bin
1 change: 1 addition & 0 deletions e2e/coreutils/sha256.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3285d399e870df47749162ab2ebfd0b727e9142925ab5f5ad221c3a42a852b08 test.bin
1 change: 1 addition & 0 deletions e2e/coreutils/test.bin
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
act as if this is binary file
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 1 addition & 3 deletions e2e/bzlmod/.bazelrc → e2e/smoke/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@
# Import Aspect bazelrc presets
import %workspace%/.aspect/bazelrc/convenience.bazelrc
import %workspace%/.aspect/bazelrc/correctness.bazelrc
import %workspace%/.aspect/bazelrc/performance.bazelrc
import %workspace%/.aspect/bazelrc/debug.bazelrc
import %workspace%/.aspect/bazelrc/javascript.bazelrc
import %workspace%/.aspect/bazelrc/performance.bazelrc

### PROJECT SPECIFIC OPTIONS ###

common --experimental_enable_bzlmod

# Load any settings & overrides specific to the current user from `.aspect/bazelrc/user.bazelrc`.
# This file should appear in `.gitignore` so that settings are not shared with team members. This
# should be last statement in this config so the user configuration is able to overwrite flags from
Expand Down
File renamed without changes.
File renamed without changes.
14 changes: 14 additions & 0 deletions e2e/smoke/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module(
name = "smoke",
compatibility_level = 1,
version = "0.0.0",
)

bazel_dep(name = "bazel_skylib", version = "1.1.1")

bazel_dep(name = "aspect_bazel_lib", version = "0.0.0")

local_path_override(
module_name = "aspect_bazel_lib",
path = "../..",
)
File renamed without changes.
Empty file added e2e/smoke/WORKSPACE.bzlmod
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion e2e/workspace/d/1

This file was deleted.

1 change: 0 additions & 1 deletion e2e/workspace/expected_jq

This file was deleted.

1 change: 0 additions & 1 deletion e2e/workspace/expected_yq

This file was deleted.

2 changes: 2 additions & 0 deletions lib/extensions.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ load(
"register_copy_to_directory_toolchains",
"register_jq_toolchains",
"register_yq_toolchains",
"register_coreutils_toolchains"
)
load("//lib/private:host_repo.bzl", "host_repo")

Expand All @@ -14,6 +15,7 @@ def _toolchain_extension(mctx):
register_copy_to_directory_toolchains(register = False)
register_jq_toolchains(register = False)
register_yq_toolchains(register = False)
register_coreutils_toolchains(register = False)

create_host_repo = False
for module in mctx.modules:
Expand Down
3 changes: 3 additions & 0 deletions lib/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ def aspect_bazel_lib_dependencies(override_local_config_platform = False):
register_copy_directory_toolchains()
register_copy_to_directory_toolchains()

# Always register the coreutils toolchain
register_coreutils_toolchains()

# Re-export the default versions
DEFAULT_JQ_VERSION = _DEFAULT_JQ_VERSION
DEFAULT_YQ_VERSION = _DEFAULT_YQ_VERSION
Expand Down
Loading

0 comments on commit e318673

Please sign in to comment.