From 3cfa5fd72dcb8eb5a5eb2e3ce570f1deea6b72c8 Mon Sep 17 00:00:00 2001 From: Kobayashi Date: Sun, 25 Feb 2024 05:36:22 -0500 Subject: [PATCH] Support ghc 9.4 and 9.6 (#18) * support ghc 9.4 and 9.6 * exclude some toolchains from CI * fix hoogle generation for ghc bundled libraries * run CI on more toolchains * always try the replacement --- .github/workflows/test.yml | 19 ++++-------------- cabal-hoogle.cabal | 4 ++-- cabal.project | 1 - flake.lock | 30 ++++++++++++++++++++++------ flake.nix | 12 +++++------ src/Hoogle/Cabal/Command/Generate.hs | 17 ++++++++++++++-- 6 files changed, 51 insertions(+), 32 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fe4607c..e263e7c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,15 +8,9 @@ jobs: - ubuntu-latest - macos-latest ghc: - - "8.10.7" - - "9.0.2" - - "9.2.4" - exclude: - # precompiled 9.0 and 9.2 don't have docs - - os: macos-latest - ghc: "9.0.2" - - os: macos-latest - ghc: "9.2.4" + - "9.2.8" + - "9.4.8" + - "9.6.4" runs-on: ${{ matrix.os }} defaults: run: @@ -31,18 +25,13 @@ jobs: ghcup list ghcup rm ghc ${{ matrix.ghc }} || true ghcup install ghc ${{ matrix.ghc }} --set - ghcup install cabal 3.6.2.0 --set + ghcup install cabal 3.10.2.1 --set cabal update - name: Build run: | cabal build all --enable-tests - name: Run Tests run: cabal test --test-show-details=always all - - name: Setup tmate session - if: ${{ failure() }} - uses: mxschmitt/action-tmate@v3 - with: - limit-access-to-actor: true post_job: runs-on: ubuntu-latest needs: [test] diff --git a/cabal-hoogle.cabal b/cabal-hoogle.cabal index e5b61b1..6257434 100644 --- a/cabal-hoogle.cabal +++ b/cabal-hoogle.cabal @@ -37,9 +37,9 @@ library , optparse-applicative >=0.16 && <1 , regex-tdfa ^>=1.3.1 , string-interpolate ^>=0.3.1.2 - , text ^>=1.2.4 + , text ^>=1.2.4 || ^>=2.0 , time >=1.10 && <2 - , transformers ^>=0.5.6 + , transformers ^>=0.5.6 || ^>=0.6 , typed-process ^>=0.2.10 default-language: Haskell2010 diff --git a/cabal.project b/cabal.project index 770bc62..6f92079 100644 --- a/cabal.project +++ b/cabal.project @@ -1,2 +1 @@ packages: ./ -index-state: 2023-06-05T00:00:00Z diff --git a/flake.lock b/flake.lock index e87e2cf..f4de6ef 100644 --- a/flake.lock +++ b/flake.lock @@ -1,12 +1,15 @@ { "nodes": { "flake-utils": { + "inputs": { + "systems": "systems" + }, "locked": { - "lastModified": 1676283394, - "narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=", + "lastModified": 1705309234, + "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", "owner": "numtide", "repo": "flake-utils", - "rev": "3db36a8b464d0c4532ba1c7dda728f4576d6d073", + "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", "type": "github" }, "original": { @@ -17,11 +20,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1678594102, - "narHash": "sha256-OHAHYiMWJFPNxuW/PcOMlSD2tvXnEYC1jxREBADHwwQ=", + "lastModified": 1707619277, + "narHash": "sha256-vKnYD5GMQbNQyyQm4wRlqi+5n0/F1hnvqSQgaBy4BqY=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "796b4a3c1d903c4b9270cd2548fe46f524eeb886", + "rev": "f3a93440fbfff8a74350f4791332a19282cc6dc8", "type": "github" }, "original": { @@ -36,6 +39,21 @@ "flake-utils": "flake-utils", "nixpkgs": "nixpkgs" } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 14f24b2..c411cbc 100644 --- a/flake.nix +++ b/flake.nix @@ -8,8 +8,8 @@ flake-utils.lib.eachDefaultSystem (system: let pkgs = import nixpkgs { inherit system; }; - compilers = [ "ghc8107" "ghc926" "ghc944" ]; - defaultCompiler = "ghc8107"; + compilers = [ "ghc92" "ghc94" "ghc96" ]; + defaultCompiler = "ghc94"; mkShell = compiler: pkgs.mkShell { buildInputs = with pkgs; [ @@ -20,10 +20,10 @@ haskell.compiler.${compiler} ormolu miniserve - ] ++ (with haskell.packages.${compiler}; [ - haskell-language-server - cabal-fmt - ]); + ] ++ (with haskell.packages.${compiler}; + (lib.lists.optional (compiler != "ghc96") haskell-language-server) ++ + [ cabal-fmt ghcid ] + ); shellHook = '' export CABAL_DIR=$(pwd)/.cabal export CABAL_CONFIG=$(pwd)/.cabal/config diff --git a/src/Hoogle/Cabal/Command/Generate.hs b/src/Hoogle/Cabal/Command/Generate.hs index 2d077a5..38aaa4a 100644 --- a/src/Hoogle/Cabal/Command/Generate.hs +++ b/src/Hoogle/Cabal/Command/Generate.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TupleSections #-} @@ -21,6 +22,7 @@ import qualified Data.List.NonEmpty.Extra as NonEmpty import qualified Data.Map.Strict as Map import Data.Maybe (catMaybes) import Data.String.Interpolate (i) +import qualified Data.Text as T import Data.Traversable (forM) import Distribution.Client.CmdBuild ( buildAction, @@ -33,7 +35,7 @@ import Distribution.Client.ProjectOrchestration ) import Distribution.Client.ProjectPlanning (ElaboratedConfiguredPackage) import Distribution.Client.ProjectPlanning.Types (elabDistDirParams) -import Distribution.InstalledPackageInfo (InstalledPackageInfo (haddockHTMLs, installedUnitId)) +import Distribution.InstalledPackageInfo (InstalledPackageInfo (haddockHTMLs, installedUnitId, pkgRoot)) import Distribution.Simple (UnitId) import Distribution.Simple.Configure (ConfigStateFileError, tryGetPersistBuildConfig) import Distribution.Simple.PackageIndex (allPackagesByName) @@ -150,7 +152,7 @@ symlinkDependencies logger localPackages hoogleDependenciesDir = do unless (null pkgs) $ logWith logger Warning $ LogPkgMoreThan1Version name (fmap installedUnitId allPkgs) - case haddockHTMLs pkg of + case haddockHTMLs' pkg of [htmlDir] -> pure $ Just (name, htmlDir) htmlDirs -> do logWith logger Warning $ LogPkgBadHaddockHtml name htmlDirs @@ -159,8 +161,19 @@ symlinkDependencies logger localPackages hoogleDependenciesDir = do createDirectoryLink dir (hoogleDependenciesDir PackageName.unPackageName name) pure name where + collectDependenciesForPkg :: LocalBuildInfo -> [(PackageName, NonEmpty InstalledPackageInfo)] collectDependenciesForPkg pkg = let depsWithName = allPackagesByName (LocalBuildInfo.installedPkgs pkg) in fmap (second (NonEmpty.:| [])) . concatMap (\(name, pkgs) -> fmap (name,) pkgs) $ depsWithName + +haddockHTMLs' :: InstalledPackageInfo -> [FilePath] +haddockHTMLs' pkg = + fmap + ( case pkgRoot pkg of + Nothing -> id + Just pkgRoot' -> T.unpack . T.replace "${pkgroot}" (T.pack pkgRoot') . T.pack + ) + . haddockHTMLs + $ pkg