Skip to content

Commit

Permalink
[#444] Support GHC-8.10 in generated projects (#475)
Browse files Browse the repository at this point in the history
* [#444] Support GHC-8.10 in generated projects

Resolves #444

* Test scripts with the default GHC

* Use variables in TOML template

* Build example project on CI with the newer GHC
  • Loading branch information
vrom911 authored Jun 29, 2020
1 parent a6b3c4f commit ea3fe21
Show file tree
Hide file tree
Showing 26 changed files with 70 additions and 33 deletions.
11 changes: 4 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,29 +44,26 @@ jobs:
run: |
cabal v2-test all --enable-tests --test-show-details=direct
- if: matrix.ghc == '8.8.3'
- if: matrix.ghc == '8.10.1'
name: Build 'cabal-minimal'
run: |
cd "summoner-cli/examples/cabal-minimal/"
echo "packages: ." > cabal.project
cabal v2-build all
- if: matrix.ghc != '8.10.1'
name: Build 'cabal-full'
- name: Build 'cabal-full'
run: |
cd "summoner-cli/examples/cabal-full/"
echo "packages: ." > cabal.project
cabal v2-build all
- if: matrix.ghc != '8.10.1'
name: Build 'stack-full'
- name: Build 'stack-full'
run: |
cd "summoner-cli/examples/stack-full/"
echo "packages: ." > cabal.project
cabal v2-build all
- if: matrix.ghc != '8.10.1'
name: Build 'full-batteries'
- name: Build 'full-batteries'
run: |
cd "summoner-cli/examples/full-batteries/"
echo "packages: ." > cabal.project
Expand Down
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ script:
- cd "$TRAVIS_BUILD_DIR/summoner-cli/examples/stack-full/"
- stack build --test --bench
- STACK_YAML=stack-8.6.5.yaml stack build --test --bench
# - STACK_YAML=stack-8.4.4.yaml stack build --test --bench
- STACK_YAML=stack-8.8.3.yaml stack build --test --bench

- cd "$TRAVIS_BUILD_DIR/summoner-cli/examples/full-batteries/"
- stack build --test --bench
- STACK_YAML=stack-8.6.5.yaml stack build --test --bench
# - STACK_YAML=stack-8.4.4.yaml stack build --test --bench
- STACK_YAML=stack-8.8.3.yaml stack build --test --bench

after_success:
- echo "Trying to deploy..."
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ The changelog is available [on GitHub][2].

* [#466](https://github.com/kowainik/summoner/issues/466):
Add ` --test-show-details=direct` to `cabal test` on CI.
* [#444](https://github.com/kowainik/summoner/issues/444):
Support GHC-8.10.1 in the generated projects.
Use GHC-8.10.1 by default in the generated projects.
Use `nightly-2020-06-29` for stack resolver.
* [#445](https://github.com/kowainik/summoner/issues/445):
Add `-Wunused-packages` for GHC-8.10.1.

## 2.0.1.1 — May 29, 2020

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ Features related to the structure and content of the generated projects.
-Wmissing-export-lists (GHC ⩾ 8.4)
-Wpartial-fields (GHC ⩾ 8.4)
-Wmissing-deriving-strategies (GHC ⩾ 8.8)
-Wunused-packages (GHC ⩾ 8.10)
```

Besides, the following GHC options are added to the executable, tests and benchmark stanzas:
Expand Down Expand Up @@ -476,7 +477,7 @@ Here is the list of the options that can be configured to suit your needs. If op
| `fullName` | Text | Full name. |
| `email` | Text | E-mail address. |
| `license` | License | One of: `MIT`, `BSD2`, `BSD3`, `GPL-2`, `GPL-3`, `LGPL-2.1`, `LGPL-3`, `AGPL-3`, `Apache-2.0`, `MPL-2.0`, `None`. |
| `ghcVersions` | [GHC] | `summoner` uses default `GHC-8.8.3`. However, additionally you can specify other versions. For each version `x.y.z` the `stack-x.y.z.yaml` will be created. |
| `ghcVersions` | [GHC] | `summoner` uses default `GHC-8.10.1`. However, additionally you can specify other versions. For each version `x.y.z` the `stack-x.y.z.yaml` will be created. |
| `github` | Bool | Turn on `GitHub` integration by default? |
| `gitignore` | [Text] | List of files you want added to the default `.gitignore`. (Ignored if `github = false`) |
| `noUpload` | Bool | Do not upload to GitHub, but create all GitHub related files if specified (Ignored if `github = false`) |
Expand Down
1 change: 1 addition & 0 deletions summoner-cli/examples/cabal-full/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
- "8.4.4"
- "8.6.5"
- "8.8.3"
- "8.10.1"

steps:
- uses: actions/checkout@v2
Expand Down
1 change: 1 addition & 0 deletions summoner-cli/examples/cabal-full/.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ matrix:
- ghc: 8.4.4
- ghc: 8.6.5
- ghc: 8.8.3
- ghc: 8.10.1



Expand Down
6 changes: 3 additions & 3 deletions summoner-cli/examples/cabal-full/appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ environment:
CABOPTS: --store-dir=C:\\SR

matrix:
- GHCVER: 8.8.3
- GHCVER: 8.10.1

install:
- choco source add -n mistuke -s https://www.myget.org/F/mistuke/api/v2
- choco install -y cabal --version 2.4.1.0
- choco install -y ghc --version 8.8.3
- choco install -y ghc --version 8.10.1
- refreshenv

before_build:
Expand All @@ -31,4 +31,4 @@ before_build:

build_script:
- cabal %CABOPTS% v2-build --enable-tests
- cabal %CABOPTS% v2-test --enable-tests
- cabal %CABOPTS% v2-test --enable-tests --test-show-details=direct
5 changes: 4 additions & 1 deletion summoner-cli/examples/cabal-full/cabal-full.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ extra-doc-files: README.md
tested-with: GHC == 8.4.4
GHC == 8.6.5
GHC == 8.8.3
GHC == 8.10.1

source-repository head
type: git
location: https://github.com/kowainik/cabal-full.git

common common-options
build-depends: base >= 4.11.1.0 && < 4.14
build-depends: base >= 4.11.1.0 && < 4.15
, relude

mixins: base hiding (Prelude)
Expand All @@ -43,6 +44,8 @@ common common-options
-Wpartial-fields
if impl(ghc >= 8.8)
ghc-options: -Wmissing-deriving-strategies
if impl(ghc >= 8.10)
ghc-options: -Wunused-packages

default-language: Haskell2010
default-extensions: DeriveGeneric
Expand Down
6 changes: 4 additions & 2 deletions summoner-cli/examples/cabal-minimal/cabal-minimal.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ copyright: 2020 Kowainik
build-type: Simple
extra-doc-files: README.md
CHANGELOG.md
tested-with: GHC == 8.8.3
tested-with: GHC == 8.10.1

common common-options
build-depends: base ^>= 4.13.0.0
build-depends: base ^>= 4.14.0.0

ghc-options: -Wall
-Wcompat
Expand All @@ -29,6 +29,8 @@ common common-options
-Wpartial-fields
if impl(ghc >= 8.8)
ghc-options: -Wmissing-deriving-strategies
if impl(ghc >= 8.10)
ghc-options: -Wunused-packages

default-language: Haskell2010

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
- "8.4.4"
- "8.6.5"
- "8.8.3"
- "8.10.1"

steps:
- uses: actions/checkout@v2
Expand Down
4 changes: 4 additions & 0 deletions summoner-cli/examples/full-batteries/.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ matrix:
- ghc: 8.4.4
- ghc: 8.6.5
- ghc: 8.8.3
- ghc: 8.10.1

- ghc: 8.0.2
env: STACK_YAML="$TRAVIS_BUILD_DIR/stack-8.0.2.yaml"
Expand All @@ -33,6 +34,9 @@ matrix:
env: STACK_YAML="$TRAVIS_BUILD_DIR/stack-8.6.5.yaml"

- ghc: 8.8.3
env: STACK_YAML="$TRAVIS_BUILD_DIR/stack-8.8.3.yaml"

- ghc: 8.10.1
env: STACK_YAML="$TRAVIS_BUILD_DIR/stack.yaml"

allow_failures:
Expand Down
6 changes: 3 additions & 3 deletions summoner-cli/examples/full-batteries/appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ environment:
CABOPTS: --store-dir=C:\\SR

matrix:
- GHCVER: 8.8.3
- GHCVER: 8.10.1

install:
- choco source add -n mistuke -s https://www.myget.org/F/mistuke/api/v2
- choco install -y cabal --version 2.4.1.0
- choco install -y ghc --version 8.8.3
- choco install -y ghc --version 8.10.1
- refreshenv

before_build:
Expand All @@ -31,4 +31,4 @@ before_build:

build_script:
- cabal %CABOPTS% v2-build --enable-tests
- cabal %CABOPTS% v2-test --enable-tests
- cabal %CABOPTS% v2-test --enable-tests --test-show-details=direct
3 changes: 2 additions & 1 deletion summoner-cli/examples/full-batteries/full-batteries.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ tested-with: GHC == 8.0.2
GHC == 8.4.4
GHC == 8.6.5
GHC == 8.8.3
GHC == 8.10.1

source-repository head
type: git
location: https://github.com/kowainik/full-batteries.git

common common-options
build-depends: base >= 4.9.1.0 && < 4.14
build-depends: base >= 4.9.1.0 && < 4.15
, relude

mixins: base hiding (Prelude)
Expand Down
1 change: 1 addition & 0 deletions summoner-cli/examples/full-batteries/stack-8.8.3.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
resolver: lts-15.5
2 changes: 1 addition & 1 deletion summoner-cli/examples/full-batteries/stack.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
resolver: lts-15.5
resolver: nightly-2020-06-29
3 changes: 3 additions & 0 deletions summoner-cli/examples/stack-full/.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ matrix:
env: STACK_YAML="$TRAVIS_BUILD_DIR/stack-8.6.5.yaml"

- ghc: 8.8.3
env: STACK_YAML="$TRAVIS_BUILD_DIR/stack-8.8.3.yaml"

- ghc: 8.10.1
env: STACK_YAML="$TRAVIS_BUILD_DIR/stack.yaml"

allow_failures:
Expand Down
1 change: 1 addition & 0 deletions summoner-cli/examples/stack-full/stack-8.8.3.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
resolver: lts-15.5
5 changes: 4 additions & 1 deletion summoner-cli/examples/stack-full/stack-full.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ extra-doc-files: README.md
tested-with: GHC == 8.4.4
GHC == 8.6.5
GHC == 8.8.3
GHC == 8.10.1

source-repository head
type: git
location: https://github.com/kowainik/stack-full.git

common common-options
build-depends: base >= 4.11.1.0 && < 4.14
build-depends: base >= 4.11.1.0 && < 4.15
, relude

mixins: base hiding (Prelude)
Expand All @@ -43,6 +44,8 @@ common common-options
-Wpartial-fields
if impl(ghc >= 8.8)
ghc-options: -Wmissing-deriving-strategies
if impl(ghc >= 8.10)
ghc-options: -Wunused-packages

default-language: Haskell2010
default-extensions: DeriveGeneric
Expand Down
2 changes: 1 addition & 1 deletion summoner-cli/examples/stack-full/stack.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
resolver: lts-15.5
resolver: nightly-2020-06-29
4 changes: 2 additions & 2 deletions summoner-cli/examples/summoner-default.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ license = "MIT"
# travis = true # Travis CI
# appveyor = true # AppVeyor CI

# List of additional GHC versions to support besides 8.8.3.
# List of additional GHC versions to support besides 8.10.1.
# Run the 'summon show ghc' command to see the list of all supported GHC versions.
# ghcVersions = ["8.4.4", "8.6.5"]
# ghcVersions = ["8.6.5", "8.8.3"]

# List of default-extensions in the .cabal file
# extensions = [ "ConstraintKinds"
Expand Down
8 changes: 6 additions & 2 deletions summoner-cli/src/Summoner/Default.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ module Summoner.Default
, currentYear
) where

import Relude.Extra.Enum (prev)

import Data.Time (getCurrentTime, toGregorian, utctDay)
import NeatInterpolation (text)
import System.Directory (getHomeDirectory)
Expand Down Expand Up @@ -126,7 +128,7 @@ defaultConfigFileContent = [text|

# List of additional GHC versions to support besides $defaultGhcVer.
# Run the 'summon show ghc' command to see the list of all supported GHC versions.
# ghcVersions = ["8.4.4", "8.6.5"]
# ghcVersions = ["$defaultGhcPrevPrev", "$defaultGhcPrev"]

# List of default-extensions in the .cabal file
# extensions = [ "ConstraintKinds"
Expand Down Expand Up @@ -166,5 +168,7 @@ defaultConfigFileContent = [text|
licenseName :: Text
licenseName = show defaultLicenseName

defaultGhcVer :: Text
defaultGhcVer, defaultGhcPrev, defaultGhcPrevPrev :: Text
defaultGhcVer = showGhcVer defaultGHC
defaultGhcPrev = showGhcVer $ prev defaultGHC
defaultGhcPrevPrev = showGhcVer $ prev $ prev defaultGHC
4 changes: 4 additions & 0 deletions summoner-cli/src/Summoner/GhcVer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ data GhcVer
| Ghc844
| Ghc865
| Ghc883
| Ghc8101
deriving stock (Eq, Ord, Show, Enum, Bounded)

-- | Converts 'GhcVer' into dot-separated string.
Expand All @@ -50,6 +51,7 @@ showGhcVer = \case
Ghc844 -> "8.4.4"
Ghc865 -> "8.6.5"
Ghc883 -> "8.8.3"
Ghc8101 -> "8.10.1"

{- | These are old GHC versions that are not working with default GHC versions
when using Stack.
Expand All @@ -69,6 +71,7 @@ latestLts = \case
Ghc844 -> "lts-12.26"
Ghc865 -> "lts-14.27"
Ghc883 -> "lts-15.5"
Ghc8101 -> "nightly-2020-06-29"

-- | Represents PVP versioning (4 numbers).
data Pvp = Pvp
Expand All @@ -91,6 +94,7 @@ baseVerPvp = \case
Ghc844 -> Pvp 4 11 1 0
Ghc865 -> Pvp 4 12 0 0
Ghc883 -> Pvp 4 13 0 0
Ghc8101 -> Pvp 4 14 0 0

-- | Returns corresponding @base@ version of the given GHC version.
baseVer :: GhcVer -> Text
Expand Down
3 changes: 3 additions & 0 deletions summoner-cli/src/Summoner/Template/Cabal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ cabalFile Settings{..} = File (toString settingsRepo ++ ".cabal") cabalFileConte
-Wpartial-fields
if impl(ghc >= 8.8)
ghc-options: -Wmissing-deriving-strategies
if impl(ghc >= 8.10)
ghc-options: -Wunused-packages

|]

libraryStanza :: Text
Expand Down
2 changes: 1 addition & 1 deletion summoner-cli/src/Summoner/Template/GitHub.hs
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ gitHubFiles Settings{..} = concat

build_script:
- cabal %CABOPTS% v2-build --enable-tests
- cabal %CABOPTS% v2-test --enable-tests
- cabal %CABOPTS% v2-test --enable-tests --test-show-details=direct
|]

-- create appveyor.yml template
Expand Down
10 changes: 5 additions & 5 deletions summoner-cli/test/Test/Script.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,24 @@ module Test.Script
import NeatInterpolation (text)
import Test.Hspec (Spec, describe, it, shouldBe)

import Summoner.GhcVer (GhcVer (..))
import Summoner.Default (defaultGHC)
import Summoner.Settings (Tool (..))
import Summoner.Template.Script (scriptFile)


scriptSpec :: Spec
scriptSpec = describe "script golden tests" $ do
it "correctly creates cabal script" $
scriptFile Ghc844 Cabal `shouldBe` cabalScript
scriptFile defaultGHC Cabal `shouldBe` cabalScript
it "correctly creates stack script" $
scriptFile Ghc865 Stack `shouldBe` stackScript
scriptFile defaultGHC Stack `shouldBe` stackScript

cabalScript :: Text
cabalScript = [text|
#!/usr/bin/env cabal
{- cabal:
build-depends:
, base ^>= 4.11.1.0
, base ^>= 4.14.0.0
-}

main :: IO ()
Expand All @@ -35,7 +35,7 @@ stackScript :: Text
stackScript = [text|
#!/usr/bin/env stack
{- stack
--resolver lts-14.27
--resolver nightly-2020-06-29
script
--package base
-}
Expand Down
Loading

0 comments on commit ea3fe21

Please sign in to comment.