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

Cleanup #184

Merged
merged 3 commits into from
Jan 3, 2024
Merged
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
13 changes: 6 additions & 7 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# Always tell why tests fail
test --test_output=errors

# We use Bazel's modern dependency management system for development.
build --enable_bzlmod=true

# We are not yet sure if we really want to lock the bzlmod resolution down given we test with various Bazel versions
# and configurations. It seems the main benefits of the lock file are not having to reanalyze the central registry
# when working without a cached workspace and being safeguarded against changed or yanked modules in the central
# registry. Both don't matter much to us right now.
# The performance gains offered by the lockfile are minimal for us.
# Pinning the dependencies should be superfluous from a reproducibility perspective as the central registry is supposed
# to be immutable for a module X in version Y after it has ben registered with the registry (ignoring the possibility of
# yanking a module). Furthermore, the module resolution is deterministic.
# However, there are several open issues suggesting the lock file will change in one way or another.
# Thus, we don't use the bzlmod locking yet.
build --lockfile_mode=off

# When working with hermetic Python toolchains, supporting the legacy runfiles layout is needlessly wasting resources.
Expand Down
17 changes: 16 additions & 1 deletion test/apply_fixes/execution_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@
load("@depend_on_what_you_use//:setup_step_2.bzl", "setup_step_2")
setup_step_2()

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")

maybe(
http_archive,
name = "rules_python",
sha256 = "9acc0944c94adb23fba1c9988b48768b1bacc6583b52a2586895c5b7491e2e31",
strip_prefix = "rules_python-0.27.0",
urls = ["https://github.com/bazelbuild/rules_python/releases/download/0.27.0/rules_python-0.27.0.tar.gz"],
)

load("@rules_python//python:repositories.bzl", "python_register_toolchains")
python_register_toolchains(
name = "python",
Expand All @@ -44,6 +55,8 @@ def setup_test_workspace(
)
with open(temporary_workspace / ".bazelversion", mode="w", encoding="utf-8") as ws_file:
ws_file.write("7.0.0")
with open(temporary_workspace / ".bazelrc", mode="w", encoding="utf-8") as ws_file:
ws_file.write("common --nolegacy_external_runfiles\ncommon --noenable_bzlmod")


def cleanup(test_workspace: Path) -> None:
Expand All @@ -60,9 +73,11 @@ def cleanup(test_workspace: Path) -> None:
)
output_base = process.stdout.strip()

# Has to be done before output base cleanup, otherwise the shutdown will create the output base anew
subprocess.run(["bazel", "shutdown"], cwd=test_workspace, check=True)

# Has to be done after the shutdown, otherwise the shutdown will create the output base anew
# The hermetic Python toolchain contains read oly files which we can't remove without making them writable
subprocess.run(["chmod", "-R", "+rw", output_base], check=True)
rmtree(output_base)


Expand Down
2 changes: 0 additions & 2 deletions test/apply_fixes/test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ def _create_reports(
"bazel",
*cmd_startup_args,
"build",
"--nolegacy_external_runfiles",
f"--aspects=//:aspect.bzl%{aspect}",
"--output_groups=dwyu",
*cmd_extra_args,
Expand All @@ -93,7 +92,6 @@ def _run_automatic_fix(self, extra_args: Optional[List[str]] = None) -> None:
cmd=[
"bazel",
"run",
"--nolegacy_external_runfiles",
"@depend_on_what_you_use//:apply_fixes",
"--",
f"--workspace={self._workspace}",
Expand Down
2 changes: 1 addition & 1 deletion third_party/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ alias(

compile_pip_requirements(
name = "mypy_requirements",
src = "mypy_requirements.in",
extra_args = ["--resolver=backtracking"],
requirements_in = "mypy_requirements.in",
requirements_txt = "mypy_requirements.txt",
)