Run the build with 3 latest GHC versions

This commit is contained in:
Mark Karpov 2020-04-14 15:14:08 +02:00
parent e7c080e2aa
commit 1e089f7dc8
6 changed files with 55 additions and 37 deletions

View File

@ -1,7 +1,18 @@
steps:
- label: Build and test
- label: Build and test with GHC 8.6.5
command: |
nix-build --keep-going --no-out-link --argstr ormoluCompiler ghc865
timeout: 100
- label: Build and test with GHC 8.8.3
command: |
nix-build --keep-going --no-out-link --argstr ormoluCompiler ghc883
timeout: 100
- label: Build and test with GHC 8.10.1
command: |
nix-build --keep-going --no-out-link --argstr ormoluCompiler ghc8101
timeout: 100
- wait
- label: Check formatting
command: |
nix-build --keep-going --no-out-link
./format.sh
git diff --exit-code --color=always
timeout: 100

View File

@ -1,7 +1,8 @@
{ pkgs ? (import ./nix/nixpkgs) }:
{ pkgs ? (import ./nix/nixpkgs)
, ormoluCompiler ? "ghc883" # the shell doesn't work with ghc8101 yet
}:
let
ormoluCompiler = "ghc865";
source = pkgs.lib.sourceByRegex ./. [
"^.*\.md$"
"^app.*$"
@ -14,16 +15,12 @@ let
overrides = ormoluOverlay;
};
ormoluOverlay = self: super: {
"ormolu" = pkgs.haskell.lib.enableCabalFlag
(super.callCabal2nix "ormolu" source { }) "dev";
# Nixpkgs provides ghc-lib-parser-8.8.0.20190424, but we want
# ghc-lib-parser-8.10.1. We disable Haddock generation because it's way
# too slow.
"ormolu" = super.callCabal2nixWithOptions "ormolu" source "-fdev" { };
"ghc-lib-parser" = pkgs.haskell.lib.dontHaddock
(super.callHackageDirect {
pkg = "ghc-lib-parser";
ver = "8.10.1.20200324";
sha256 = "0f2c68fzdj2lw6da2zpx7a0cx631im3kylwd85dzx1npsm1vzlbg";
ver = "8.10.1.20200412";
sha256 = "sha256-EjMzp8xRT3xVFKDI1fAfopkylGB0hv35Av2+uZeETRU=";
} {});
};
ormolize = import ./nix/ormolize {
@ -51,15 +48,22 @@ let
}) haskellPackages;
in {
ormolu = haskellPackages.ormolu;
ormoluShell = haskellPackages.shellFor {
packages = ps: [
ps.ormolu
];
buildInputs = [
haskellPackages.cabal-install
haskellPackages.ghcid
];
};
ormoluShell =
if ormoluCompiler == "ghc8101"
# HACK The shell doesn't compile with GHC 8.10.1
then haskellPackages.shellFor {
packages = ps: [];
buildInputs = [];
}
else haskellPackages.shellFor {
packages = ps: [
ps.ormolu
];
buildInputs = [
haskellPackages.cabal-install
haskellPackages.ghcid
];
};
withOrmolu = haskellPackages.shellFor {
packages = ps: [];
buildInputs = [
@ -81,7 +85,6 @@ in {
"cryptonite"
"diagrams-core"
"distributed-process"
"esqueleto"
"fay"
"hakyll"
"haxl"
@ -98,6 +101,10 @@ in {
"tls"
"yesod-core"
# Uses CPP to concatenate strings in a deprecation annotation
# "esqueleto"
# Comment idempotence issue
# "Agda"

View File

@ -1,6 +1,6 @@
let
rev = "19.09";
sha256 = "0mhqhq21y5vrr1f30qd2bvydv4bbbslvyzclhw0kdxmkgg3z4c92";
rev = "807ca93fadd5197c2260490de0c76e500562dc05";
sha256 = "10yq8bnls77fh3pk5chkkb1sv5lbdgyk1rr2v9xn71rr1k2x563p";
nixpkgs = builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/${rev}.tar.gz";
inherit sha256;

View File

@ -10,7 +10,7 @@ where
import Control.Monad
import Data.Char (isSpace, toLower)
import Data.List
import qualified Data.List as L
import qualified EnumSet as ES
import FastString (mkFastString, unpackFS)
import qualified Lexer as L
@ -35,8 +35,8 @@ parsePragma ::
String ->
Maybe Pragma
parsePragma input = do
inputNoPrefix <- stripPrefix "{-#" input
guard ("#-}" `isSuffixOf` input)
inputNoPrefix <- L.stripPrefix "{-#" input
guard ("#-}" `L.isSuffixOf` input)
let contents = take (length inputNoPrefix - 3) inputNoPrefix
(pragmaName, cs) = (break isSpace . dropWhile isSpace) contents
case toLower <$> pragmaName of
@ -46,7 +46,7 @@ parsePragma input = do
_ -> Nothing
where
trimSpaces :: String -> String
trimSpaces = dropWhileEnd isSpace . dropWhile isSpace
trimSpaces = L.dropWhileEnd isSpace . dropWhile isSpace
-- | Assuming the input consists of a series of tokens from a language
-- pragma, return the set of enabled extensions.

View File

@ -164,7 +164,7 @@ p_instDecl style = \case
p_derivDecl :: DerivDecl GhcPs -> R ()
p_derivDecl = \case
d@DerivDecl {..} -> p_standaloneDerivDecl d
d@DerivDecl {} -> p_standaloneDerivDecl d
XDerivDecl x -> noExtCon x
-- | Determine if these declarations should be grouped together.

View File

@ -11,7 +11,7 @@ module Ormolu.Printer.Operators
where
import Data.Function (on)
import Data.List
import qualified Data.List as L
import Data.Maybe (fromMaybe, mapMaybe)
import Data.Ord (Down (Down), comparing)
import GHC
@ -105,7 +105,7 @@ buildFixityMap ::
buildFixityMap getOpName opTree =
concatMap (\(i, ns) -> map (\(n, _) -> (n, fixity i InfixL)) ns)
. zip [0 ..]
. groupBy (doubleWithinEps 0.00001 `on` snd)
. L.groupBy (doubleWithinEps 0.00001 `on` snd)
. (overrides ++)
. modeScores
$ score opTree
@ -143,22 +143,22 @@ buildFixityMap getOpName opTree =
-- Pick the most common score per 'RdrName'.
modeScores :: [(RdrName, Double)] -> [(RdrName, Double)]
modeScores =
sortOn snd
L.sortOn snd
. mapMaybe
( \case
[] -> Nothing
xs@((n, _) : _) -> Just (n, mode $ map snd xs)
)
. groupBy ((==) `on` fst)
. sort
. L.groupBy ((==) `on` fst)
. L.sort
-- Return the most common number, leaning to the smaller
-- one in case of a tie.
mode :: [Double] -> Double
mode =
head
. minimumBy (comparing (Down . length))
. groupBy (doubleWithinEps 0.0001)
. sort
. L.minimumBy (comparing (Down . length))
. L.groupBy (doubleWithinEps 0.0001)
. L.sort
-- The start column of the rightmost operator.
maxCol = go opTree
where