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

Actually run in bzlmod mode on CI #2005

Merged
merged 9 commits into from
Nov 3, 2023
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
4 changes: 4 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
import %workspace%/.bazelrc.common
import %workspace%/.bazelrc.bzlmod

# User Configuration
# ------------------
try-import %workspace%/.bazelrc.local
3 changes: 2 additions & 1 deletion .bazelrc.bzlmod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
common --noenable_bzlmod

common:bzlmod --enable_bzlmod
common:bzlmod --registry=file:%workspace%/registry --registry=https://bcr.bazel.build
# Note, have to use /// to make Bazel not crash on Windows
common --registry=file:///%workspace%/registry --registry=https://bcr.bazel.build
4 changes: 0 additions & 4 deletions .bazelrc.common
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,3 @@ build:windows-bindist --proto_compiler @rules_haskell//tests:protoc.cmd
# This flag will become the default in bazel 7
# https://github.com/bazelbuild/bazel/issues/17032
build --incompatible_disable_starlark_host_transitions

# User Configuration
# ------------------
try-import %workspace%/.bazelrc.local
39 changes: 23 additions & 16 deletions .github/workflows/workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,17 @@ jobs:
matrix:
os: [ubuntu-latest, macos-11]
module: [rules_haskell, rules_haskell_nix, rules_haskell_tests]
bzlmod: [bzlmod, workspace]
bzlmod: [true, false]
ghc:
- 9.2.5
- 9.4.5
exclude:
- module: rules_haskell_nix
bzlmod: workspace
bzlmod: false
# TODO: in a MODULE.bazel file we declare version specific dependencies, would need to use stack snapshot json
# and stack config per GHC version
- ghc: 9.4.5
bzlmod: true
runs-on: ${{ matrix.os }}
steps:
- if: ${{ matrix.os == 'ubuntu-latest' }}
Expand Down Expand Up @@ -62,16 +66,11 @@ jobs:
else
cache_setting="--remote_header=x-buildbuddy-api-key=$BUILDBUDDY_API_KEY"
fi
if [ ${{ matrix.bzlmod }} == bzlmod ]; then
bzlmod_setting='common --config bzlmod'
else
bzlmod_setting=''
fi
cat >.bazelrc.local <<EOF
common --config=ci
build --config=$BUILD_CONFIG
build $cache_setting
$bzlmod_setting
common --enable_bzlmod=${{ matrix.bzlmod }}
EOF
cp .bazelrc.local rules_haskell_nix
cp .bazelrc.local rules_haskell_tests
Expand Down Expand Up @@ -121,10 +120,15 @@ jobs:
matrix:
os: [ubuntu-latest, macos-11, windows-latest]
module: [rules_haskell, rules_haskell_tests]
bzlmod: [bzlmod, workspace]
bzlmod: [true, false]
ghc:
- 9.2.5
- 9.4.5
exclude:
# TODO: in a MODULE.bazel file we declare version specific dependencies, would need to use stack snapshot json
# and stack config per GHC version
- ghc: 9.4.5
bzlmod: true
env:
GHC_VERSION: ${{ matrix.ghc }}
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -168,16 +172,15 @@ jobs:
else
cache_setting="--remote_header=x-buildbuddy-api-key=$BUILDBUDDY_API_KEY"
fi
if [ ${{ matrix.bzlmod }} == bzlmod]; then
bzlmod_setting='common --config bzlmod'
else
bzlmod_setting=''
fi
if [[ ${{ runner.os }} == Windows ]]; then
output_root_setting="startup --output_user_root=C:/_bzl"
# On windows, we use a separate remote cache for bzlmod,
# because the c dependency analysis is leaking absolute paths which are different
bzlmod_cache_silo_key="build --remote_default_exec_properties=bzlmod-cache-silo-key=${{ matrix.bzlmod }}"
if ${{ matrix.bzlmod }}; then
bzlmod_cache_silo_key='build --remote_default_exec_properties=bzlmod-cache-silo-key=bzlmod'
else
bzlmod_cache_silo_key='build --remote_default_exec_properties=bzlmod-cache-silo-key=workspace'
fi
else
output_root_setting=""
bzlmod_cache_silo_key=""
Expand All @@ -188,7 +191,7 @@ jobs:
build $cache_setting
$output_root_setting
$bzlmod_cache_silo_key
$bzlmod_setting
common --enable_bzlmod=${{ matrix.bzlmod }}
EOF
cp .bazelrc.local rules_haskell_tests
cat >~/.netrc <<EOF
Expand All @@ -201,6 +204,8 @@ jobs:
run: |
[[ ${{ runner.os }} == macOS ]] && export BAZEL_USE_CPP_ONLY_TOOLCHAIN=1
if [[ ${{ runner.os }} == Windows ]]; then
# prevent auto-detection of system compilers
export BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
# On Windows `//...` expands to `/...`.
bazel test ///...
else
Expand All @@ -215,6 +220,8 @@ jobs:
[[ ${{ runner.os }} == macOS ]] && export BAZEL_USE_CPP_ONLY_TOOLCHAIN=1
./tests/run-start-script.sh --use-bindists
if [[ ${{ runner.os }} == Windows ]]; then
# prevent auto-detection of system compilers
export BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
# On Windows `//...` expands to `/...`.
bazel test ///...
else
Expand Down
2 changes: 2 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ haskell_toolchains.bindists()
use_repo(
haskell_toolchains,
"all_bindist_toolchains",
"rules_haskell_ghc_windows_amd64_cc_toolchain",
"rules_haskell_python_local",
)

Expand All @@ -95,6 +96,7 @@ register_toolchains(

register_toolchains(
"@all_bindist_toolchains//:all",
"@rules_haskell_ghc_windows_amd64_cc_toolchain//:all",
"@rules_haskell_python_local//:toolchain",
)

Expand Down
4 changes: 2 additions & 2 deletions examples/.bazelrc.bzlmod
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
common:bzlmod --experimental_enable_bzlmod
common:bzlmod --registry=file://%workspace%/../registry --registry=https://bcr.bazel.build
common:bzlmod --enable_bzlmod
common --registry=file://%workspace%/../registry --registry=https://bcr.bazel.build
4 changes: 4 additions & 0 deletions rules_haskell_nix/.bazelrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
import %workspace%/../.bazelrc.common
import %workspace%/.bazelrc.bzlmod

# User Configuration
# ------------------
try-import %workspace%/.bazelrc.local
4 changes: 3 additions & 1 deletion rules_haskell_nix/.bazelrc.bzlmod
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
common:bzlmod --enable_bzlmod
common:bzlmod --registry=file://%workspace%/../registry --registry=https://bcr.bazel.build

# Note, have to use /// to make Bazel not crash on Windows
common --registry=file:///%workspace%/../registry --registry=https://bcr.bazel.build
4 changes: 4 additions & 0 deletions rules_haskell_tests/.bazelrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
import %workspace%/../.bazelrc.common
import %workspace%/.bazelrc.bzlmod

# User Configuration
# ------------------
try-import %workspace%/.bazelrc.local
4 changes: 3 additions & 1 deletion rules_haskell_tests/.bazelrc.bzlmod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
common --noenable_bzlmod

common:bzlmod --enable_bzlmod
common:bzlmod --registry=file:%workspace%/../registry --registry=https://bcr.bazel.build

# Note, have to use /// to make Bazel not crash on Windows
common --registry=file:///%workspace%/../registry --registry=https://bcr.bazel.build
8 changes: 7 additions & 1 deletion rules_haskell_tests/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,6 @@ stack_snapshot.package(
"process",
"profunctors",
"proto-lens",
"proto-lens-runtime",
"safe-exceptions",
"streaming",
"temporary",
Expand All @@ -410,13 +409,20 @@ stack_snapshot.package(
setup_deps = ["@Cabal//:Cabal"],
)
for package in [
"bifunctors",
"call-stack",
"c2hs",
"doctest",
"HUnit",
"happy",
"hspec",
"hspec-core",
"hspec-discover",
"hspec-expectations",
"proto-lens-runtime",
"quickcheck-io",
"transformers-compat",
"type-errors",
]
]

Expand Down
4 changes: 2 additions & 2 deletions tutorial/.bazelrc.bzlmod
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
common:bzlmod --experimental_enable_bzlmod
common:bzlmod --registry=file://%workspace%/../registry --registry=https://bcr.bazel.build
common:bzlmod --enable_bzlmod
common --registry=file://%workspace%/../registry --registry=https://bcr.bazel.build