Skip to content

Commit 0b9edf8

Browse files
authored
Merge pull request #2005 from tweag/ci-fix-bzlmod
Actually run in bzlmod mode on CI
2 parents 6b34cd1 + 42f460e commit 0b9edf8

File tree

12 files changed

+56
-28
lines changed

12 files changed

+56
-28
lines changed

.bazelrc

+4
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
import %workspace%/.bazelrc.common
22
import %workspace%/.bazelrc.bzlmod
3+
4+
# User Configuration
5+
# ------------------
6+
try-import %workspace%/.bazelrc.local

.bazelrc.bzlmod

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
common --noenable_bzlmod
33

44
common:bzlmod --enable_bzlmod
5-
common:bzlmod --registry=file:%workspace%/registry --registry=https://bcr.bazel.build
5+
# Note, have to use /// to make Bazel not crash on Windows
6+
common --registry=file:///%workspace%/registry --registry=https://bcr.bazel.build

.bazelrc.common

-4
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,3 @@ build:windows-bindist --proto_compiler @rules_haskell//tests:protoc.cmd
136136
# This flag will become the default in bazel 7
137137
# https://github.com/bazelbuild/bazel/issues/17032
138138
build --incompatible_disable_starlark_host_transitions
139-
140-
# User Configuration
141-
# ------------------
142-
try-import %workspace%/.bazelrc.local

.github/workflows/workflow.yaml

+23-16
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,17 @@ jobs:
2020
matrix:
2121
os: [ubuntu-latest, macos-11]
2222
module: [rules_haskell, rules_haskell_nix, rules_haskell_tests]
23-
bzlmod: [bzlmod, workspace]
23+
bzlmod: [true, false]
2424
ghc:
2525
- 9.2.5
2626
- 9.4.5
2727
exclude:
2828
- module: rules_haskell_nix
29-
bzlmod: workspace
29+
bzlmod: false
30+
# TODO: in a MODULE.bazel file we declare version specific dependencies, would need to use stack snapshot json
31+
# and stack config per GHC version
32+
- ghc: 9.4.5
33+
bzlmod: true
3034
runs-on: ${{ matrix.os }}
3135
steps:
3236
- if: ${{ matrix.os == 'ubuntu-latest' }}
@@ -62,16 +66,11 @@ jobs:
6266
else
6367
cache_setting="--remote_header=x-buildbuddy-api-key=$BUILDBUDDY_API_KEY"
6468
fi
65-
if [ ${{ matrix.bzlmod }} == bzlmod ]; then
66-
bzlmod_setting='common --config bzlmod'
67-
else
68-
bzlmod_setting=''
69-
fi
7069
cat >.bazelrc.local <<EOF
7170
common --config=ci
7271
build --config=$BUILD_CONFIG
7372
build $cache_setting
74-
$bzlmod_setting
73+
common --enable_bzlmod=${{ matrix.bzlmod }}
7574
EOF
7675
cp .bazelrc.local rules_haskell_nix
7776
cp .bazelrc.local rules_haskell_tests
@@ -121,10 +120,15 @@ jobs:
121120
matrix:
122121
os: [ubuntu-latest, macos-11, windows-latest]
123122
module: [rules_haskell, rules_haskell_tests]
124-
bzlmod: [bzlmod, workspace]
123+
bzlmod: [true, false]
125124
ghc:
126125
- 9.2.5
127126
- 9.4.5
127+
exclude:
128+
# TODO: in a MODULE.bazel file we declare version specific dependencies, would need to use stack snapshot json
129+
# and stack config per GHC version
130+
- ghc: 9.4.5
131+
bzlmod: true
128132
env:
129133
GHC_VERSION: ${{ matrix.ghc }}
130134
runs-on: ${{ matrix.os }}
@@ -168,16 +172,15 @@ jobs:
168172
else
169173
cache_setting="--remote_header=x-buildbuddy-api-key=$BUILDBUDDY_API_KEY"
170174
fi
171-
if [ ${{ matrix.bzlmod }} == bzlmod]; then
172-
bzlmod_setting='common --config bzlmod'
173-
else
174-
bzlmod_setting=''
175-
fi
176175
if [[ ${{ runner.os }} == Windows ]]; then
177176
output_root_setting="startup --output_user_root=C:/_bzl"
178177
# On windows, we use a separate remote cache for bzlmod,
179178
# because the c dependency analysis is leaking absolute paths which are different
180-
bzlmod_cache_silo_key="build --remote_default_exec_properties=bzlmod-cache-silo-key=${{ matrix.bzlmod }}"
179+
if ${{ matrix.bzlmod }}; then
180+
bzlmod_cache_silo_key='build --remote_default_exec_properties=bzlmod-cache-silo-key=bzlmod'
181+
else
182+
bzlmod_cache_silo_key='build --remote_default_exec_properties=bzlmod-cache-silo-key=workspace'
183+
fi
181184
else
182185
output_root_setting=""
183186
bzlmod_cache_silo_key=""
@@ -188,7 +191,7 @@ jobs:
188191
build $cache_setting
189192
$output_root_setting
190193
$bzlmod_cache_silo_key
191-
$bzlmod_setting
194+
common --enable_bzlmod=${{ matrix.bzlmod }}
192195
EOF
193196
cp .bazelrc.local rules_haskell_tests
194197
cat >~/.netrc <<EOF
@@ -201,6 +204,8 @@ jobs:
201204
run: |
202205
[[ ${{ runner.os }} == macOS ]] && export BAZEL_USE_CPP_ONLY_TOOLCHAIN=1
203206
if [[ ${{ runner.os }} == Windows ]]; then
207+
# prevent auto-detection of system compilers
208+
export BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
204209
# On Windows `//...` expands to `/...`.
205210
bazel test ///...
206211
else
@@ -215,6 +220,8 @@ jobs:
215220
[[ ${{ runner.os }} == macOS ]] && export BAZEL_USE_CPP_ONLY_TOOLCHAIN=1
216221
./tests/run-start-script.sh --use-bindists
217222
if [[ ${{ runner.os }} == Windows ]]; then
223+
# prevent auto-detection of system compilers
224+
export BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
218225
# On Windows `//...` expands to `/...`.
219226
bazel test ///...
220227
else

MODULE.bazel

+2
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ haskell_toolchains.bindists()
8383
use_repo(
8484
haskell_toolchains,
8585
"all_bindist_toolchains",
86+
"rules_haskell_ghc_windows_amd64_cc_toolchain",
8687
"rules_haskell_python_local",
8788
)
8889

@@ -95,6 +96,7 @@ register_toolchains(
9596

9697
register_toolchains(
9798
"@all_bindist_toolchains//:all",
99+
"@rules_haskell_ghc_windows_amd64_cc_toolchain//:all",
98100
"@rules_haskell_python_local//:toolchain",
99101
)
100102

examples/.bazelrc.bzlmod

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
common:bzlmod --experimental_enable_bzlmod
2-
common:bzlmod --registry=file://%workspace%/../registry --registry=https://bcr.bazel.build
1+
common:bzlmod --enable_bzlmod
2+
common --registry=file://%workspace%/../registry --registry=https://bcr.bazel.build

rules_haskell_nix/.bazelrc

+4
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
import %workspace%/../.bazelrc.common
22
import %workspace%/.bazelrc.bzlmod
3+
4+
# User Configuration
5+
# ------------------
6+
try-import %workspace%/.bazelrc.local

rules_haskell_nix/.bazelrc.bzlmod

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
common:bzlmod --enable_bzlmod
2-
common:bzlmod --registry=file://%workspace%/../registry --registry=https://bcr.bazel.build
2+
3+
# Note, have to use /// to make Bazel not crash on Windows
4+
common --registry=file:///%workspace%/../registry --registry=https://bcr.bazel.build

rules_haskell_tests/.bazelrc

+4
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
import %workspace%/../.bazelrc.common
22
import %workspace%/.bazelrc.bzlmod
3+
4+
# User Configuration
5+
# ------------------
6+
try-import %workspace%/.bazelrc.local

rules_haskell_tests/.bazelrc.bzlmod

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22
common --noenable_bzlmod
33

44
common:bzlmod --enable_bzlmod
5-
common:bzlmod --registry=file:%workspace%/../registry --registry=https://bcr.bazel.build
5+
6+
# Note, have to use /// to make Bazel not crash on Windows
7+
common --registry=file:///%workspace%/../registry --registry=https://bcr.bazel.build

rules_haskell_tests/MODULE.bazel

+7-1
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,6 @@ stack_snapshot.package(
387387
"process",
388388
"profunctors",
389389
"proto-lens",
390-
"proto-lens-runtime",
391390
"safe-exceptions",
392391
"streaming",
393392
"temporary",
@@ -410,13 +409,20 @@ stack_snapshot.package(
410409
setup_deps = ["@Cabal//:Cabal"],
411410
)
412411
for package in [
412+
"bifunctors",
413+
"call-stack",
413414
"c2hs",
414415
"doctest",
416+
"HUnit",
415417
"happy",
416418
"hspec",
417419
"hspec-core",
418420
"hspec-discover",
419421
"hspec-expectations",
422+
"proto-lens-runtime",
423+
"quickcheck-io",
424+
"transformers-compat",
425+
"type-errors",
420426
]
421427
]
422428

tutorial/.bazelrc.bzlmod

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
common:bzlmod --experimental_enable_bzlmod
2-
common:bzlmod --registry=file://%workspace%/../registry --registry=https://bcr.bazel.build
1+
common:bzlmod --enable_bzlmod
2+
common --registry=file://%workspace%/../registry --registry=https://bcr.bazel.build

0 commit comments

Comments
 (0)