Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: enable bzlmod #246

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@

test --test_output=errors

# TODO(alex): enable
common --noenable_bzlmod
# TODO(alex): enable the lockfile when we feel it has value.
# As of Bazel 7.0 there are some stability issues, and we don't feel we have any hermeticity problem
# that it solves.
common --lockfile_mode=off

# Define value used by tests
build --define=SOME_VAR=SOME_VALUE

# Use local rules_python
# Enable with --config=dev
common:dev --override_repository=rules_python=~/workspace/rules_python

# Load any settings specific to the current user.
# .bazelrc.user should appear in .gitignore so that settings are not shared with team members
# This needs to be last statement in this
Expand Down
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
7.0.0
7.0.1
# The first line of this file is used by Bazelisk and Bazel to be sure
# the right version of Bazel is used to build and test this repo.
# This also defines which version is used on CI.
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- uses: actions/checkout@v4
# Cache build and external artifacts so that the next ci build is incremental.
# Because github action caches cannot be updated after a build, we need to
# store the contents of each build in a unique cache key, then fall back to loading
Expand All @@ -37,7 +37,7 @@ jobs:
path: |
"~/.cache/bazel"
"~/.cache/bazel-repo"
key: bazel-cache-${{ hashFiles('**/BUILD.bazel', '**/*.bzl', 'WORKSPACE') }}
key: bazel-cache-${{ hashFiles('**/BUILD.bazel', '**/*.bzl', 'WORKSPACE', 'MODULE.bazel') }}
restore-keys: bazel-cache-
- name: bazel test //...
env:
Expand Down
6 changes: 5 additions & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@ archive_override(
urls = "https://github.com/bazelbuild/rules_python/archive/52381415be9d3618130f02a821aef50de1e3af09.tar.gz",
integrity = "sha256-pYfEFNWqygSEElDYgJsuIeDYn9oll/rZB0GcR+6rirA=",
strip_prefix = "rules_python-52381415be9d3618130f02a821aef50de1e3af09",
)
)

python = use_extension("@rules_python//python/extensions:python.bzl", "python")

python.toolchain(python_version = "3.9")
3 changes: 3 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ register_toolchains("//:container_py_toolchain")

load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains")

# TODO(alexeagle): this is redundant with the python.toolchain call in MODULE.bazel
# Either figure out how the python_versions and pythons_hub repo are wired upstream, or just
# clear out this file and use only bzlmod for everything python-related.
python_register_toolchains(
name = "python_toolchain",
python_version = "3.9",
Expand Down
8 changes: 4 additions & 4 deletions py/tests/external-deps/expected_pathing
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ sys path:
(py_toolchain)/lib/python3.9/lib-dynload
(pwd)/bazel-out/[exec]/bin/py/tests/external-deps/pathing.runfiles/pathing.venv/lib/python3.9/site-packages
(pwd)/bazel-out/[exec]/bin/py/tests/external-deps/pathing.runfiles
(pwd)/bazel-out/[exec]/bin/py/tests/external-deps/pathing.runfiles/aspect_rules_py/py/tests/external-deps
(pwd)/bazel-out/[exec]/bin/py/tests/external-deps/pathing.runfiles/aspect_rules_py
(pwd)/bazel-out/[exec]/bin/py/tests/external-deps/pathing.runfiles/_main/py/tests/external-deps
(pwd)/bazel-out/[exec]/bin/py/tests/external-deps/pathing.runfiles/_main

Entrypoint Path: (pwd)/bazel-out/[exec]/bin/py/tests/external-deps/pathing.runfiles/aspect_rules_py/py/tests/external-deps/pathing.py
Entrypoint Path: (pwd)/bazel-out/[exec]/bin/py/tests/external-deps/pathing.runfiles/_main/py/tests/external-deps/pathing.py

Django location: (pwd)/bazel-out/[exec]/bin/py/tests/external-deps/pathing.runfiles/pathing.venv/lib/python3.9/site-packages/django/__init__.py
Django version: 4.2.7

From lib with wheel dependency: Hello Matt
lib filepath: (pwd)/bazel-out/[exec]/bin/py/tests/external-deps/pathing.runfiles/aspect_rules_py/py/tests/external-deps/lib.py
lib filepath: (pwd)/bazel-out/[exec]/bin/py/tests/external-deps/pathing.runfiles/_main/py/tests/external-deps/lib.py
2 changes: 1 addition & 1 deletion py/tests/import-pathing/tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def _can_resolve_path_in_workspace_test_impl(ctx):
# Transitive imports are included in depset
fake_ctx = _ctx_with_imports([".."], [ctx.attr.import_dep])
imports = py_library.make_imports_depset(fake_ctx).to_list()
asserts.equals(env, "aspect_rules_py/py/tests/import-pathing/baz", imports[0])
asserts.equals(env, "_main/py/tests/import-pathing/baz", imports[0])
asserts.equals(env, "aspect_rules_py/foo", imports[1])

return unittest.end(env)
Expand Down
2 changes: 1 addition & 1 deletion py/tests/py-test/test_env_vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ def test_env(env, expected):
test_env('LOCATION', "py/tests/py-test/test_env_vars.py")
test_env('DEFINE', "SOME_VALUE")
test_env('BAZEL_TARGET', "//py/tests/py-test:test_env_vars")
test_env('BAZEL_WORKSPACE', "aspect_rules_py")
test_env('BAZEL_WORKSPACE', "_main")
test_env('BAZEL_TARGET_NAME', "test_env_vars")