From 7fc1c3b66da8f9ba5ddbb951cdb17de9c6ac043f Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 18 Nov 2024 07:33:41 +0000 Subject: [PATCH 1/7] Update dependency bazel to v7 --- .bazelversion | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.bazelversion b/.bazelversion index f22d756da..815da58b7 100644 --- a/.bazelversion +++ b/.bazelversion @@ -1 +1 @@ -6.5.0 +7.4.1 From fda6e42999cdc169141a26be08724f178ad48dd1 Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Mon, 18 Nov 2024 08:39:19 +0100 Subject: [PATCH 2/7] Use Bazel version 7.1.0 by default (this version is currently available in nixpkgs) --- .bazelversion | 2 +- rules_haskell_tests/shell.nix | 2 +- shell.nix | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.bazelversion b/.bazelversion index 815da58b7..a3fcc7121 100644 --- a/.bazelversion +++ b/.bazelversion @@ -1 +1 @@ -7.4.1 +7.1.0 diff --git a/rules_haskell_tests/shell.nix b/rules_haskell_tests/shell.nix index 2bbf21c73..bcfa20b40 100644 --- a/rules_haskell_tests/shell.nix +++ b/rules_haskell_tests/shell.nix @@ -33,7 +33,7 @@ mkShell { file ] ++ lib.optionals docTools [ graphviz python3Packages.sphinx zip unzip ]; - packages = [ bazel_6 ]; + packages = [ bazel_7 ]; shellHook = '' # Add nix config flags to .bazelrc.local. diff --git a/shell.nix b/shell.nix index 1a44395fe..ad9cd863e 100644 --- a/shell.nix +++ b/shell.nix @@ -42,7 +42,7 @@ mkShell { ++ lib.optionals docTools [ graphviz python3Packages.sphinx zip unzip ] ++ lib.optional stdenv.isDarwin macOS-security; - packages = [ bazel_6 ]; + packages = [ bazel_7 ]; shellHook = '' # Add nix config flags to .bazelrc.local. From 2d34aa4cd9cb7656d5ecc2cce423385d05fdf5de Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Tue, 19 Nov 2024 15:19:04 +0100 Subject: [PATCH 3/7] Disable sandboxed exclusive tests This Bazel flag's value was flipped to `true` in Bazel 7 and causes some integration tests to fail: //tests/ghcWithPackages_2097:ghc_with_packages_test_nixpkgs_bazel_7 //tests/haskell_module/repl:haskell_module_repl_cross_library_deps_test_nixpkgs_bazel_7 //tests/recompilation:recompilation_test_nixpkgs_bazel_7 //tests/repl-targets:hs_bin_repl_test_nixpkgs_bazel_7 //tests/repl-targets:hs_lib_repl_test_nixpkgs_bazel_6 //tests/repl-targets:hs_lib_repl_test_nixpkgs_bazel_7 //tests/ghcWithPackages_2097:ghc_with_packages_test_bindist_7_1_0 //tests/haskell_module/repl:haskell_module_repl_cross_library_deps_test_bindist_7_1_0 //tests/recompilation:recompilation_test_bindist_7_1_0 //tests/repl-targets:hs_bin_repl_test_bindist_7_1_0 //tests/repl-targets:hs_lib_repl_test_bindist_6_0_0 //tests/repl-targets:hs_lib_repl_test_bindist_6_3_2 //tests/repl-targets:hs_lib_repl_test_bindist_6_5_0 //tests/repl-targets:hs_lib_repl_test_bindist_7_1_0 --- .bazelrc.common | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.bazelrc.common b/.bazelrc.common index 6d8fa4fd1..9e23e5757 100644 --- a/.bazelrc.common +++ b/.bazelrc.common @@ -17,6 +17,10 @@ startup --host_jvm_args=-Djdk.tls.client.protocols=TLSv1.2 common --incompatible_require_linker_input_cc_api common --incompatible_disallow_empty_glob=true +# explicitly disable sandboxing exclusive tests (it was false in Bazel 6, but is true in Bazel 7+) +# (otherise this causes some integration tests to fail) +common --noincompatible_exclusive_test_sandboxed + # test environment does not propagate locales by default some tests reads files # written in UTF8, we need to propagate the correct environment variables, such # as LOCALE_ARCHIVE We also need to setup an utf8 locale From 58e8f43c4e36445c58a0272b3672e7e925366a3b Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Tue, 19 Nov 2024 15:25:05 +0100 Subject: [PATCH 4/7] Set `requires_nix` tag on //tests/ghcWithPackages_2097:ghc_with_packages_test This test uses the `ghcWithPackages` nix function to provide a ghc toolchain. It is not intended to be used with a bindist. --- rules_haskell_tests/tests/ghcWithPackages_2097/BUILD.bazel | 1 + 1 file changed, 1 insertion(+) diff --git a/rules_haskell_tests/tests/ghcWithPackages_2097/BUILD.bazel b/rules_haskell_tests/tests/ghcWithPackages_2097/BUILD.bazel index 99347f3ca..391e896a2 100644 --- a/rules_haskell_tests/tests/ghcWithPackages_2097/BUILD.bazel +++ b/rules_haskell_tests/tests/ghcWithPackages_2097/BUILD.bazel @@ -3,6 +3,7 @@ load("//tests/integration_testing:rules_haskell_integration_test.bzl", "rules_ha rules_haskell_integration_test( name = "ghc_with_packages_test", srcs = ["Test.hs"], + tags = ["requires_nix"], workspace_path = "test", ) From 76567e97de6d6d647c8a6fe42c176409fba81722 Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Tue, 19 Nov 2024 15:26:01 +0100 Subject: [PATCH 5/7] Allow passing environment variables to `rules_haskell_integration_test` --- .../integration_testing/rules_haskell_integration_test.bzl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rules_haskell_tests/tests/integration_testing/rules_haskell_integration_test.bzl b/rules_haskell_tests/tests/integration_testing/rules_haskell_integration_test.bzl index 363990170..489b375cc 100644 --- a/rules_haskell_tests/tests/integration_testing/rules_haskell_integration_test.bzl +++ b/rules_haskell_tests/tests/integration_testing/rules_haskell_integration_test.bzl @@ -16,6 +16,7 @@ def rules_haskell_integration_test( workspace_path, srcs, deps = [], + env = {}, bindist_bazel_versions = SUPPORTED_BAZEL_VERSIONS, nixpkgs_bazel_packages = SUPPORTED_NIXPKGS_BAZEL_PACKAGES, **kwargs): @@ -33,7 +34,7 @@ def rules_haskell_integration_test( name = "%s_nixpkgs" % name, srcs = srcs, deps = deps, - env = { + env = env | { "NIXPKGS": "1", }, bazel_binaries = nixpkgs_bazel_binaries, @@ -50,6 +51,7 @@ def rules_haskell_integration_test( name = "%s_bindist" % name, srcs = srcs, deps = deps, + env = env, bazel_binaries = bindist_bazel_binaries, workspace_path = workspace_path, rule_files = ["@rules_haskell//:distribution"], From ae5f88210f7be1f0cab9ea710cd0b9278fe56996 Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Tue, 19 Nov 2024 15:26:53 +0100 Subject: [PATCH 6/7] Pass `BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1` to ghc_with_packages_test --- rules_haskell_tests/tests/ghcWithPackages_2097/BUILD.bazel | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rules_haskell_tests/tests/ghcWithPackages_2097/BUILD.bazel b/rules_haskell_tests/tests/ghcWithPackages_2097/BUILD.bazel index 391e896a2..4e15d010b 100644 --- a/rules_haskell_tests/tests/ghcWithPackages_2097/BUILD.bazel +++ b/rules_haskell_tests/tests/ghcWithPackages_2097/BUILD.bazel @@ -3,6 +3,9 @@ load("//tests/integration_testing:rules_haskell_integration_test.bzl", "rules_ha rules_haskell_integration_test( name = "ghc_with_packages_test", srcs = ["Test.hs"], + env = { + "BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN": "1", + }, tags = ["requires_nix"], workspace_path = "test", ) From 74077eee3965e1a666eb34522b0efd22437e64fe Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Tue, 19 Nov 2024 16:22:10 +0100 Subject: [PATCH 7/7] Make .ghcide script compatible with Bazel 7 The `--experimental_show_artifacts` flag was removed, so we do not rely on it anymore. --- rules_haskell_tests/.ghcide | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/rules_haskell_tests/.ghcide b/rules_haskell_tests/.ghcide index ceb0cd3de..c40d70560 100755 --- a/rules_haskell_tests/.ghcide +++ b/rules_haskell_tests/.ghcide @@ -1,13 +1,9 @@ #!/usr/bin/env bash set -euo pipefail build_ghcide() { - bazel build //tests/ghcide \ - --experimental_show_artifacts \ - 2>&1 \ - | awk ' - /^>>>/ { print substr($1, 4); next } - { print $0 > "/dev/stderr" } - ' + bazel build //tests/ghcide + outfile=$( bazel cquery --output=files //tests/ghcide ) + echo "$( bazel info execution_root)/${outfile}" } ghcide="$(build_ghcide)" "$ghcide" "$@"