Skip to content

Commit

Permalink
Merge pull request #2132 from tweag/ylecornec/ghc_9_8_1
Browse files Browse the repository at this point in the history
Support for ghc 9.8.1
  • Loading branch information
mergify[bot] authored Mar 5, 2024
2 parents fd9ef6e + a2ad1b0 commit e97f4e4
Show file tree
Hide file tree
Showing 21 changed files with 622 additions and 64 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,16 @@ jobs:
module: [rules_haskell, rules_haskell_nix, rules_haskell_tests]
bzlmod: [true, false]
ghc:
- 9.2.8
- 9.4.6
- 9.6.2
- 9.8.1
exclude:
- module: rules_haskell_nix

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.2.8
- ghc: 9.8.1
bzlmod: true
- ghc: 9.6.2
bzlmod: true
Expand Down Expand Up @@ -143,19 +143,21 @@ jobs:
module: [rules_haskell, rules_haskell_tests]
bzlmod: [true, false]
ghc:
- 9.2.8
- 9.4.6
- 9.6.2
- 9.8.1
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.2.8
- ghc: 9.8.1
bzlmod: true
- ghc: 9.6.2
bzlmod: true
# currently proto-lens-protoc fails with an access violation on Windows
- ghc: 9.6.2
os: windows-latest
- ghc: 9.8.1
os: windows-latest
env:
GHC_VERSION: ${{ matrix.ghc }}
runs-on: ${{ matrix.os }}
Expand Down
3 changes: 2 additions & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ load("//haskell:private/ghc_ci.bzl", "ghc_version")

ghc_version(name = "rules_haskell_ghc_version")

load("@rules_haskell//haskell:private/versions.bzl", "is_at_least")
load("//haskell:repositories.bzl", "rules_haskell_dependencies")

rules_haskell_dependencies()
Expand Down Expand Up @@ -179,7 +180,7 @@ stack_snapshot(
"proto-lens-runtime",
"lens-family",
],
setup_deps = {} if GHC_VERSION and GHC_VERSION.startswith("9.6.") else {
setup_deps = {} if GHC_VERSION and is_at_least("9.6", GHC_VERSION) else {
# See https://github.com/tweag/rules_haskell/issues/1871
"HUnit": ["@Cabal//:Cabal"],
"bifunctors": ["@Cabal//:Cabal"],
Expand Down
4 changes: 3 additions & 1 deletion extensions/rules_haskell_dependencies.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
load("@rules_haskell//tools:os_info.bzl", "os_info")
load("@rules_haskell_ghc_version//:ghc_version.bzl", "GHC_VERSION")
load("@rules_haskell//haskell:private/versions.bzl", "is_at_least")

def _empty_repo_impl(rctx):
fail(rctx.attr.error_msg)
Expand Down Expand Up @@ -38,7 +39,8 @@ def repositories(*, bzlmod): # @unused

# TODO: Remove when tests are run with a ghc version containing Cabal >= 3.10
# See https://github.com/tweag/rules_haskell/issues/1871
if GHC_VERSION and GHC_VERSION.startswith("9.6."):

if GHC_VERSION and is_at_least("9.6", GHC_VERSION):
_empty_repo(
name = "Cabal",
error_msg = "When using GHC >= 9.6, do not depend on @Cabal, as https://github.com/tweag/rules_haskell/issues/1871 is fixed.",
Expand Down
8 changes: 4 additions & 4 deletions haskell/private/versions.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def _parse_bazel_version(bazel_version):
"""
return [int(_parse_version_chunk(x)) for x in bazel_version.split(".")]

def _is_at_least(threshold, version):
def is_at_least(threshold, version):
"""Check that a version is higher or equals to a threshold.
Args:
threshold: the minimum version string
Expand All @@ -64,7 +64,7 @@ def _is_at_least(threshold, version):
# Needed for check_bazel_version below.
return _parse_bazel_version(version) >= _parse_bazel_version(threshold)

def _is_at_most(threshold, version):
def is_at_most(threshold, version):
"""Check that a version is lower or equals to a threshold.
Args:
threshold: the maximum version string
Expand Down Expand Up @@ -103,7 +103,7 @@ def check_bazel_version(minimum_bazel_version, maximum_bazel_version = None, baz
else:
bazel_version = native.bazel_version

if not _is_at_least(
if not is_at_least(
threshold = minimum_bazel_version,
version = bazel_version,
):
Expand All @@ -113,7 +113,7 @@ def check_bazel_version(minimum_bazel_version, maximum_bazel_version = None, baz
))

if maximum_bazel_version:
if not _is_at_most(
if not is_at_most(
threshold = maximum_bazel_version,
version = bazel_version,
):
Expand Down
3 changes: 2 additions & 1 deletion rules_haskell_tests/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ local_repository(
)

load("@rules_haskell//haskell:private/ghc_ci.bzl", "ghc_version")
load("@rules_haskell//haskell:private/versions.bzl", "is_at_least")

ghc_version(name = "rules_haskell_ghc_version")

Expand Down Expand Up @@ -297,7 +298,7 @@ stack_snapshot(
"typed-process": ["@Cabal//:Cabal"],
"unliftio-core": ["@Cabal//:Cabal"],
}.items()
if [d for d in deps if d != "@Cabal//:Cabal"] or not GHC_VERSION or not GHC_VERSION.startswith("9.6.")
if [d for d in deps if d != "@Cabal//:Cabal"] or not GHC_VERSION or not is_at_least("9.6", GHC_VERSION)
},
stack_snapshot_json = "//:stackage_snapshot{}.json".format(
"_" + str(GHC_VERSION) if GHC_VERSION else "",
Expand Down
Loading

0 comments on commit e97f4e4

Please sign in to comment.