Skip to content

Commit

Permalink
[kowainik#454][kowainik#340] Move to Cabal 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
gdziadkiewicz committed Oct 14, 2020
1 parent b4342aa commit 4c6fb6d
Show file tree
Hide file tree
Showing 18 changed files with 81 additions and 71 deletions.
29 changes: 17 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ on:

jobs:
build:
name: ghc ${{ matrix.ghc }}
runs-on: ubuntu-16.04
name: ${{ matrix.os }} / ghc ${{ matrix.ghc }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-16.04]
cabal: ["3.0"]
ghc:
- "8.4.4"
Expand All @@ -23,48 +24,52 @@ jobs:
- uses: actions/checkout@v2
if: github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.ref == 'refs/heads/master'

- uses: actions/setup-haskell@v1
- uses: actions/setup-haskell@v1.1.1
name: Setup Haskell
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: ${{ matrix.cabal }}

- name: Freeze
run: |
cabal freeze
- uses: actions/cache@v1
name: Cache ~/.cabal/store
with:
path: ~/.cabal/store
key: ${{ runner.os }}-${{ matrix.ghc }}-cabal
path: ${{ steps.setup-haskell-cabal.outputs.cabal-store }}
key: ${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze') }}

- name: Build
run: |
cabal v2-update
cabal v2-build all --enable-tests --enable-benchmarks
cabal configure --enable-tests --enable-benchmarks --test-show-details=direct
cabal build all
- name: Unit and property tests
run: |
cabal v2-test all --enable-tests --test-show-details=direct
cabal test all
- 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
cabal build all
- name: Build 'cabal-full'
run: |
cd "summoner-cli/examples/cabal-full/"
echo "packages: ." > cabal.project
cabal v2-build all
cabal build all
- name: Build 'stack-full'
run: |
cd "summoner-cli/examples/stack-full/"
echo "packages: ." > cabal.project
cabal v2-build all
cabal build all
- name: Build 'full-batteries'
run: |
cd "summoner-cli/examples/full-batteries/"
echo "packages: ." > cabal.project
cabal v2-build all
cabal build all
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ To start using Summoner make sure that you have the following tools installed on

We also have minimal version requirements for build tools:

* [Cabal ⩾ 2.4](https://www.haskell.org/cabal/)
* [Stack ⩾ 2.1.3](http://haskellstack.org)
* [Cabal ⩾ 3.0](https://www.haskell.org/cabal/)
* [Stack ⩾ 2.3.3](http://haskellstack.org)

However, it is always recommended to use the newest versions of build tools.

Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ cache:

environment:
STACK_ROOT: C:\sr
STACK_VERSION: 2.1.1
STACK_VERSION: 2.3.3

matrix:
- STACK_YAML: stack.yaml
Expand Down
10 changes: 5 additions & 5 deletions summoner-cli/examples/cabal-full/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
cabal: ["2.4"]
cabal: ["3.0"]
ghc:
- "8.4.4"
- "8.6.5"
Expand Down Expand Up @@ -46,7 +46,7 @@ jobs:

- name: Freeze
run: |
cabal v2-freeze
cabal freeze
- uses: actions/cache@v1
name: Cache ~/.cabal/store
Expand All @@ -56,10 +56,10 @@ jobs:

- name: Build
run: |
cabal v2-configure --enable-tests --enable-benchmarks
cabal v2-build all
cabal configure --enable-tests --enable-benchmarks --test-show-details=direct
cabal build all
- name: Test
run: |
cabal v2-test all
cabal test all
10 changes: 5 additions & 5 deletions summoner-cli/examples/cabal-full/.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ language: haskell
git:
depth: 5

cabal: "2.4"
cabal: "3.0"

cache:
directories:
Expand All @@ -20,12 +20,12 @@ install:
# HLint check
- curl -sSL https://raw.github.com/ndmitchell/neil/master/misc/travis.sh | sh -s -- hlint .

- cabal v2-update
- cabal v2-configure --enable-tests --enable-benchmarks
- cabal v2-build all
- cabal update
- cabal configure --enable-tests --enable-benchmarks --test-show-details=direct
- cabal build all

script:
- cabal v2-test all
- cabal test all

notifications:
email: false
9 changes: 5 additions & 4 deletions summoner-cli/examples/cabal-full/appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,16 @@ environment:

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 cabal --version 3.0.0.0
- choco install -y ghc --version 8.10.1
- refreshenv

before_build:
- cabal --version
- ghc --version
- cabal %CABOPTS% v2-update
- cabal %CABOPTS% update

build_script:
- cabal %CABOPTS% v2-build --enable-tests
- cabal %CABOPTS% v2-test --enable-tests --test-show-details=direct
- cabal %CABOPTS% configure --enable-tests --enable-benchmarks --test-show-details=direct
- cabal %CABOPTS% build all
- cabal %CABOPTS% test all
2 changes: 1 addition & 1 deletion summoner-cli/examples/cabal-full/cabal-full.cabal
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cabal-version: 2.4
cabal-version: 3.0
name: cabal-full
version: 0.0.0.0
synopsis: Cabal-only example with all integrations
Expand Down
2 changes: 1 addition & 1 deletion summoner-cli/examples/cabal-minimal/cabal-minimal.cabal
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cabal-version: 2.4
cabal-version: 3.0
name: cabal-minimal
version: 0.0.0.0
synopsis: Minimal cabal-only test project
Expand Down
10 changes: 5 additions & 5 deletions summoner-cli/examples/full-batteries/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
cabal: ["2.4"]
cabal: ["3.0"]
ghc:
- "8.0.2"
- "8.2.2"
Expand Down Expand Up @@ -56,7 +56,7 @@ jobs:

- name: Freeze
run: |
cabal v2-freeze
cabal freeze
- uses: actions/cache@v1
name: Cache ~/.cabal/store
Expand All @@ -66,12 +66,12 @@ jobs:

- name: Build
run: |
cabal v2-configure --enable-tests --enable-benchmarks
cabal v2-build all
cabal configure --enable-tests --enable-benchmarks --test-show-details=direct
cabal build all
- name: Test
run: |
cabal v2-test all
cabal test all
stack:
name: stack / ghc ${{ matrix.ghc }}
Expand Down
10 changes: 5 additions & 5 deletions summoner-cli/examples/full-batteries/.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ language: haskell
git:
depth: 5

cabal: "2.4"
cabal: "3.0"

cache:
directories:
Expand Down Expand Up @@ -55,9 +55,9 @@ install:

- |
if [ -z "$STACK_YAML" ]; then
cabal v2-update
cabal v2-configure --enable-tests --enable-benchmarks
cabal v2-build all
cabal update
cabal configure --enable-tests --enable-benchmarks --test-show-details=direct
cabal build all
else
curl -sSL https://get.haskellstack.org/ | sh
stack --version
Expand All @@ -67,7 +67,7 @@ install:
script:
- |
if [ -z "$STACK_YAML" ]; then
cabal v2-test all
cabal test all
else
stack test --system-ghc
fi
Expand Down
9 changes: 5 additions & 4 deletions summoner-cli/examples/full-batteries/appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,16 @@ environment:

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 cabal --version 3.0.0.0
- choco install -y ghc --version 8.10.1
- refreshenv

before_build:
- cabal --version
- ghc --version
- cabal %CABOPTS% v2-update
- cabal %CABOPTS% update

build_script:
- cabal %CABOPTS% v2-build --enable-tests
- cabal %CABOPTS% v2-test --enable-tests --test-show-details=direct
- cabal %CABOPTS% configure --enable-tests --enable-benchmarks --test-show-details=direct
- cabal %CABOPTS% build all
- cabal %CABOPTS% test all
2 changes: 1 addition & 1 deletion summoner-cli/examples/full-batteries/full-batteries.cabal
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cabal-version: 2.4
cabal-version: 3.0
name: full-batteries
version: 0.0.0.0
synopsis: Full-featured test project
Expand Down
2 changes: 1 addition & 1 deletion summoner-cli/examples/stack-full/.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ language: haskell
git:
depth: 5

cabal: "2.4"
cabal: "3.0"

cache:
directories:
Expand Down
2 changes: 1 addition & 1 deletion summoner-cli/examples/stack-full/stack-full.cabal
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cabal-version: 2.4
cabal-version: 3.0
name: stack-full
version: 0.0.0.0
synopsis: Stack-only example with all integrations
Expand Down
2 changes: 1 addition & 1 deletion summoner-cli/src/Summoner/Default.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ defaultGHC = maxBound

-- | Default version of the Cabal.
defaultCabal :: Text
defaultCabal = "2.4"
defaultCabal = "3.0"

-- | Default version of the Stack.
defaultStack :: Text
Expand Down
43 changes: 23 additions & 20 deletions summoner-cli/src/Summoner/Template/GitHub.hs
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,7 @@ gitHubFiles Settings{..} = concat
, " ghc:"
]
<> map (indent 10 <>) ghActionsVersions
<>
[ " exclude:"]
<> map (indent 10 <>) ghActionsExcludes
<> ghActionsExcludes
<>
[ ""
, " steps:"
Expand All @@ -155,7 +153,7 @@ gitHubFiles Settings{..} = concat
, ""
, " - name: Freeze"
, " run: |"
, " cabal v2-freeze"
, " cabal freeze"
, ""
, " - uses: actions/cache@v1"
, " name: Cache ~/.cabal/store"
Expand Down Expand Up @@ -218,15 +216,21 @@ gitHubFiles Settings{..} = concat
settingsTestedVersions

ghActionsExcludes :: [Text]
ghActionsExcludes = do
ghActionsExcludes =
let latestVersion = viaNonEmpty last $ sort settingsTestedVersions
versionsToExclude = filter (\version -> pure version /= latestVersion) settingsTestedVersions
osesToExclude = ["macOS-latest", "windows-latest"]
os <- osesToExclude
version <- versionsToExclude
[ "- os: " <> os
, " ghc: " <> showGhcVer version
]
excludes = do
os <- osesToExclude
version <- versionsToExclude
[ "- os: " <> os
, " ghc: " <> (showGhcVer version)
]
in case excludes of
[] -> []
xs ->
" exclude:"
: map (indent 10 <>) xs

-- create travis.yml template
travisYml :: Text
Expand Down Expand Up @@ -358,18 +362,16 @@ gitHubFiles Settings{..} = concat
]

cabalUpdate :: Text
cabalUpdate = "cabal v2-update"
cabalUpdate = "cabal update"

cabalConfigure :: Text
cabalConfigure = "cabal v2-configure --enable-tests --enable-benchmarks"
cabalConfigure = "cabal configure --enable-tests --enable-benchmarks --test-show-details=direct"

cabalBuild :: Text
cabalBuild = "cabal v2-build all"
cabalBuild = "cabal build all"

cabalTest :: Text
cabalTest = if settingsTest
then "cabal v2-test all"
else "echo 'No tests'"
cabalTest = "cabal test all"

stackBuild :: Text
stackBuild = "stack build --system-ghc --test --bench --no-run-tests --no-run-benchmarks --ghc-options=-Werror"
Expand Down Expand Up @@ -419,18 +421,19 @@ gitHubFiles Settings{..} = concat
, ""
, "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 cabal --version 3.0.0.0"
, " - choco install -y ghc --version " <> defGhc
, " - refreshenv"
, ""
, "before_build:"
, " - cabal --version"
, " - ghc --version"
, " - cabal %CABOPTS% v2-update"
, " - cabal %CABOPTS% update"
, ""
, "build_script:"
, " - cabal %CABOPTS% v2-build --enable-tests"
, " - cabal %CABOPTS% v2-test --enable-tests --test-show-details=direct"
, " - cabal %CABOPTS% configure --enable-tests --enable-benchmarks --test-show-details=direct"
, " - cabal %CABOPTS% build all"
, " - cabal %CABOPTS% test all"
]

-- create appveyor.yml template
Expand Down
Loading

0 comments on commit 4c6fb6d

Please sign in to comment.