Skip to content

Commit

Permalink
[#281] Add example Cabal and Stack projects (#422)
Browse files Browse the repository at this point in the history
* [#281] Add example Cabal and Stack projects

Resolves #281

* Patch formatting

* Update tests on CI

* Add extra-source-files

* Fix stack test on CI
  • Loading branch information
chshersh authored Feb 24, 2020
1 parent 5074253 commit e666c66
Show file tree
Hide file tree
Showing 63 changed files with 909 additions and 134 deletions.
22 changes: 12 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
name: CI

# Trigger the workflow on push or pull request, but only for the master branch
on:
# Trigger the workflow on push or pull request,
# but only for the master branch
push:
branches:
- master
pull_request:
push:
branches: [master]

jobs:
build:
name: ghc ${{ matrix.ghc }}
runs-on: ubuntu-16.04
strategy:
matrix:
ghc: ["8.2.2", "8.4.4", "8.6.5", "8.8.2"]
cabal: ["3.0"]
cabal: ["2.4"]
ghc:
- "8.2.2"
- "8.4.4"
- "8.6.5"
- "8.8.2"

steps:
- uses: actions/checkout@v2
Expand All @@ -35,9 +37,9 @@ jobs:

- name: Build
run: |
cabal new-update
cabal new-build all --enable-tests --enable-benchmarks --write-ghc-environment-files=always
cabal v2-update
cabal v2-build all --enable-tests --enable-benchmarks
- name: Test
run: |
cabal new-test all --enable-tests
cabal v2-test all --enable-tests
14 changes: 11 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,25 @@ script:
cabal v2-test all --enable-tests
echo "Testing that generated projects are built with cabal..."
cd "$TRAVIS_BUILD_DIR/summoner-cli/test/golden/smallProject/"
cd "$TRAVIS_BUILD_DIR/summoner-cli/examples/cabal-minimal/"
echo "packages: ." > cabal.project
cabal v2-build all
cd "$TRAVIS_BUILD_DIR/summoner-cli/test/golden/fullProject/"
cd "$TRAVIS_BUILD_DIR/summoner-cli/examples/cabal-full/"
echo "packages: ." > cabal.project
cabal v2-build all
cd "$TRAVIS_BUILD_DIR/summoner-cli/examples/stack-full/"
echo "packages: ." > cabal.project
cabal v2-build all
cd "$TRAVIS_BUILD_DIR/summoner-cli/examples/full-batteries/"
echo "packages: ." > cabal.project
cabal v2-build all
else
stack test --system-ghc --no-terminal
echo "Testing that generated projects are built with stack..."
cd "$TRAVIS_BUILD_DIR/summoner-cli/test/golden/fullProject/"
cd "$TRAVIS_BUILD_DIR/summoner-cli/examples/stack-full/"
stack build --system-ghc --test --bench
cd "$TRAVIS_BUILD_DIR/summoner-cli/examples/full-batteries/"
stack build --system-ghc --test --bench
fi
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ The changelog is available [on GitHub][2].
Implement `summon config` command. This command will generate the
default TOML configuration file with helpful comments.
(by [@chshersh](https://github.com/chshersh))
* [#281](https://github.com/kowainik/summoner/issues/281):
Add more example projects and golden tests for various scaffolding
configurations.
(by [@chshersh](https://github.com/chshersh))
* [#361](https://github.com/kowainik/summoner/issues/361):
Always put all default warnings in `ghc-options` inside common
stanza under cabal conditionals on the `GHC` version. Now they look
Expand Down
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,20 @@ By the way, Summoner operates as either CLI or TUI application, so you can choos

You can also see complete examples in the following folder:

* [`summon-cli/tests/golden`: Examples of scaffolded projects](https://github.com/kowainik/summoner/tree/master/summoner-cli/test/golden)

Directory `smallProject` contains an example of the straightforward package,
and `fullProject` shows a generated project with more advanced structure and more features.
* [`summon-cli/examples/`: Examples of scaffolded projects](https://github.com/kowainik/summoner/tree/master/summoner-cli/examples/)

The directory contains the following examples:

* [`cabal-minimal`](https://github.com/kowainik/summoner/tree/master/summoner-cli/examples/cabal-minimal):
minimal Haskell project with the Cabal-only support, default
settings and all of the integrations disabled.
* [`cabal-full`](https://github.com/kowainik/summoner/tree/master/summoner-cli/examples/cabal-full):
Cabal-only project with all integrations enabled.
* [`stack-full`](https://github.com/kowainik/summoner/tree/master/summoner-cli/examples/stack-full):
Stack-only project with all integrations enabled.
* [`full-batteries`](https://github.com/kowainik/summoner/tree/master/summoner-cli/examples/full-batteries):
All batteries-included project which supports both build tools and
shows every Summoner feature.

## Features [](#structure)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
name: CI

# Trigger the workflow on push or pull request, but only for the master branch
on:
# Trigger the workflow on push or pull request,
# but only for the master branch
push:
branches:
- master
pull_request:
push:
branches: [master]

jobs:
build:
name: ghc ${{ matrix.ghc }}
runs-on: ubuntu-16.04
strategy:
matrix:
ghc: ["8.0.2", "8.2.2", "8.4.4", "8.6.5", "8.8.2"]
cabal: ["2.4"]
ghc:
- "8.4.4"
- "8.6.5"
- "8.8.2"

steps:
- uses: actions/checkout@v2
Expand Down
54 changes: 54 additions & 0 deletions summoner-cli/examples/cabal-full/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
### Haskell
dist
dist-*
cabal-dev
*.o
*.hi
*.chi
*.chs.h
*.dyn_o
*.dyn_hi
*.prof
*.aux
*.hp
*.eventlog
.virtualenv
.hsenv
.hpc
.cabal-sandbox/
cabal.sandbox.config
cabal.config
cabal.project.local
.ghc.environment.*
.HTF/
# Stack
.stack-work/
stack.yaml.lock

### IDE/support
# Vim
[._]*.s[a-v][a-z]
[._]*.sw[a-p]
[._]s[a-v][a-z]
[._]sw[a-p]
*~
tags

# IntellijIDEA
.idea/
.ideaHaskellLib/
*.iml

# Atom
.haskell-ghc-mod.json

# VS
.vscode/

# Emacs
*#
.dir-locals.el
TAGS

# other
.DS_Store
32 changes: 32 additions & 0 deletions summoner-cli/examples/cabal-full/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
sudo: true
language: haskell

git:
depth: 5

cabal: "2.4"

cache:
directories:
- "$HOME/.cabal/store"


matrix:
include:
- ghc: 8.4.4
- ghc: 8.6.5
- ghc: 8.8.2


install:
# HLint check
- curl -sSL https://raw.github.com/ndmitchell/neil/master/misc/travis.sh | sh -s -- hlint .

- cabal v2-update
- cabal v2-build --enable-tests --enable-benchmarks

script:
- cabal v2-test --enable-tests

notifications:
email: false
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Changelog

`fullProject` uses [PVP Versioning][1].
`cabal-full` uses [PVP Versioning][1].
The changelog is available [on GitHub][2].

## 0.0.0.0

* Initially created.

[1]: https://pvp.haskell.org
[2]: https://github.com/kowainik/fullProject/releases
[2]: https://github.com/kowainik/cabal-full/releases
29 changes: 29 additions & 0 deletions summoner-cli/examples/cabal-full/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
BSD 3-Clause License

Copyright (c) 2020, Kowainik
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
9 changes: 9 additions & 0 deletions summoner-cli/examples/cabal-full/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# cabal-full

[![GitHub CI](https://github.com/kowainik/cabal-full/workflows/CI/badge.svg)](https://github.com/kowainik/cabal-full/actions)
[![Build status](https://img.shields.io/travis/kowainik/cabal-full.svg?logo=travis)](https://travis-ci.org/kowainik/cabal-full)
[![Windows build status](https://ci.appveyor.com/api/projects/status/github/kowainik/cabal-full?branch=master&svg=true)](https://ci.appveyor.com/project/kowainik/cabal-full)
[![Hackage](https://img.shields.io/hackage/v/cabal-full.svg?logo=haskell)](https://hackage.haskell.org/package/cabal-full)
[![BSD-3-Clause license](https://img.shields.io/badge/license-BSD--3--Clause-blue.svg)](LICENSE)

Cabal-only example with all integrations
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Main (main) where

import FullProject (someFunc)
import CabalFull (someFunc)


main :: IO ()
Expand Down
84 changes: 84 additions & 0 deletions summoner-cli/examples/cabal-full/cabal-full.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
cabal-version: 2.4
name: cabal-full
version: 0.0.0.0
synopsis: Cabal-only example with all integrations
description: Cabal-only example with all integrations
homepage: https://github.com/kowainik/cabal-full
bug-reports: https://github.com/kowainik/cabal-full/issues
license: BSD-3-Clause
license-file: LICENSE
author: Kowainik
maintainer: Kowainik <xrom.xkov@gmail.com>
copyright: 2020 Kowainik
category: Testing
build-type: Simple
extra-doc-files: README.md
CHANGELOG.md
tested-with: GHC == 8.4.4
GHC == 8.6.5
GHC == 8.8.2

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
, relude

mixins: base hiding (Prelude)
, relude (Relude as Prelude)

ghc-options: -Wall
-Wcompat
-Widentities
-Wincomplete-uni-patterns
-Wincomplete-record-updates
if impl(ghc >= 8.0)
ghc-options: -Wredundant-constraints
if impl(ghc >= 8.2)
ghc-options: -fhide-source-paths
if impl(ghc >= 8.4)
ghc-options: -Wmissing-export-lists
-Wpartial-fields
if impl(ghc >= 8.8)
ghc-options: -Wmissing-deriving-strategies

default-language: Haskell2010
default-extensions: DeriveGeneric
TypeApplications

library
import: common-options
hs-source-dirs: src
exposed-modules: CabalFull

executable cabal-full
import: common-options
hs-source-dirs: app
main-is: Main.hs
build-depends: cabal-full
ghc-options: -threaded
-rtsopts
-with-rtsopts=-N

test-suite cabal-full-test
import: common-options
type: exitcode-stdio-1.0
hs-source-dirs: test
main-is: Spec.hs
build-depends: cabal-full
ghc-options: -threaded
-rtsopts
-with-rtsopts=-N

benchmark cabal-full-benchmark
import: common-options
type: exitcode-stdio-1.0
hs-source-dirs: benchmark
main-is: Main.hs
build-depends: gauge
, cabal-full
ghc-options: -threaded
-rtsopts
-with-rtsopts=-N
15 changes: 15 additions & 0 deletions summoner-cli/examples/cabal-full/src/CabalFull.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{- |
Copyright: (c) 2020 Kowainik
SPDX-License-Identifier: BSD-3-Clause
Maintainer: Kowainik <xrom.xkov@gmail.com>
Cabal-only example with all integrations
-}

module CabalFull
( someFunc
) where


someFunc :: IO ()
someFunc = putStrLn ("someFunc" :: String)
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Changelog

`smallProject` uses [PVP Versioning][1].
`cabal-minimal` uses [PVP Versioning][1].

## 0.0.0.0

Expand Down
Loading

0 comments on commit e666c66

Please sign in to comment.