Skip to content

Commit

Permalink
[#45] Add support for AppVeyor CI
Browse files Browse the repository at this point in the history
  • Loading branch information
chshersh committed Jan 18, 2018
1 parent eb133a1 commit eae9086
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 16 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
1.0.3
=====

* [#45](https://github.com/vrom911/hs-init/issues/45):
Support AppVeyor CI for created projects.

1.0.2
=====

Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Build status](https://secure.travis-ci.org/vrom911/hs-init.svg)](http://travis-ci.org/vrom911/hs-init)
[![MIT license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/vrom911/hs-init/blob/master/LICENSE)
[![Version 1.0.2](https://img.shields.io/badge/version-v1.0.2-fabfff.svg)](https://github.com/vrom911/hs-init/blob/master/CHANGELOG.md)
[![Version 1.0.2](https://img.shields.io/badge/version-v1.0.3-fabfff.svg)](https://github.com/vrom911/hs-init/blob/master/CHANGELOG.md)

This is tool for creating completely configured production Haskell projects.
Consider that this script is using [`Stack`](http://haskellstack.org) for
Expand Down Expand Up @@ -63,7 +63,8 @@ Available commands:
Available command options:
-g, --github Github integration
-c, --ci CI integration (Travis CI)
-c, --travis Travis CI integration
-w, --app-veyor AppVeyor CI integration
-s, --script Build script
-l, --library Library target
-e, --exec Executable target
Expand All @@ -79,11 +80,11 @@ the question will be asked during the work of the script.
For example,

```
hs-init newProject on -letgcsp off -b
hs-init newProject on -letgcspw off -b
```
will create fully functional project with library, executable file, tests,
[build script](#build-script) and create private repository on [github](https://github.com)
integrated with `Travis-CI`, but benchmarks won't be attached to this one.
integrated with `Travis-CI`, `AppVeyor-CI`, but benchmarks won't be attached to this one.

But when calling this command

Expand Down Expand Up @@ -123,6 +124,7 @@ PROJECT_NAME
├── README.md
├── Setup.hs
├── stack.yaml
├── appveyor.yml
├── .git
├── .gitignore
└── .travis.yml
Expand Down
67 changes: 55 additions & 12 deletions hs-init.hs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ generateProject repo owner description Targets{..} = do

-- Library/Executable/Tests/Benchmarks flags
github <- decisionToBool githubFlag "github integration"
ci <- ifGithub github "CI integration" ciFlag
travis <- ifGithub github "Travis CI integration" travisFlag
appVey <- ifGithub github "AppVeyor CI integration" appVeyorFlag
privat <- ifGithub github "Private repository" privateFlag
script <- decisionToBool scriptFlag "build script"
isLib <- decisionToBool isLibrary "library target"
Expand Down Expand Up @@ -211,7 +212,8 @@ instance Monoid Decision where

data Targets = Targets
{ githubFlag :: Decision
, ciFlag :: Decision
, travisFlag :: Decision
, appVeyorFlag :: Decision
, privateFlag :: Decision
, scriptFlag :: Decision
, isLibrary :: Decision
Expand All @@ -221,11 +223,12 @@ data Targets = Targets
}

instance Monoid Targets where
mempty = Targets mempty mempty mempty mempty mempty mempty mempty mempty
mempty = Targets mempty mempty mempty mempty mempty mempty mempty mempty mempty

mappend t1 t2 = Targets
{ githubFlag = combine githubFlag
, ciFlag = combine ciFlag
, travisFlag = combine travisFlag
, appVeyorFlag = combine appVeyorFlag
, privateFlag = combine privateFlag
, scriptFlag = combine scriptFlag
, isLibrary = combine isLibrary
Expand All @@ -243,7 +246,8 @@ data InitOpts = InitOpts Text -- ^ Project name
targetsP :: Decision -> Parser Targets
targetsP d = do
githubFlag <- githubP d
ciFlag <- ciP d
travisFlag <- travisP d
appVeyorFlag <- appVeyorP d
privateFlag <- privateP d
scriptFlag <- scriptP d
isLibrary <- libraryP d
Expand All @@ -258,11 +262,17 @@ githubP d = flag Idk d
<> short 'g'
<> help "GitHub integration"

ciP :: Decision -> Parser Decision
ciP d = flag Idk d
$ long "ci"
<> short 'c'
<> help "CI integration"
travisP :: Decision -> Parser Decision
travisP d = flag Idk d
$ long "travis"
<> short 'c'
<> help "Travis CI integration"

appVeyorP :: Decision -> Parser Decision
appVeyorP d = flag Idk d
$ long "app-veyor"
<> short 'w'
<> help "AppVeyor CI integration"

privateP :: Decision -> Parser Decision
privateP d = flag Idk d
Expand Down Expand Up @@ -382,7 +392,8 @@ data ProjectData = ProjectData
, license :: Text -- ^ type of license
, licenseText :: Text -- ^ license text
, github :: Bool -- ^ github repository
, ci :: Bool -- ^ CI integration
, travis :: Bool -- ^ Travis CI integration
, appVey :: Bool -- ^ AppVeyor CI integration
, script :: Bool -- ^ build script
, isLib :: Bool -- ^ is library
, isExe :: Bool -- ^ is executable
Expand Down Expand Up @@ -571,7 +582,8 @@ createStackTemplate
<> createCabalFiles
<> readme
<> emptyIfNot github gitignore
<> emptyIfNot ci travisYml
<> emptyIfNot travis travisYml
<> emptyIfNot appVey appVeyorYml
<> emptyIfNot script scriptSh
<> changelog
<> createLicense
Expand Down Expand Up @@ -750,6 +762,7 @@ createStackTemplate

[![Hackage]($hackageShield)]($hackageLink)
[![Build status](${travisShield})](${travisLink})
[![Windows build status](${appVeyorShield})](${appVeyorLink})
[![$license license](${licenseShield})](${licenseLink})
$endLine
|]
Expand All @@ -762,6 +775,10 @@ createStackTemplate
"https://secure.travis-ci.org/" <> owner <> "/" <> repo <> ".svg"
travisLink :: Text =
"https://travis-ci.org/" <> owner <> "/" <> repo
appVeyorShield :: Text =
"https://ci.appveyor.com/api/projects/status/github/" <> owner <> "/" <> repo <> "?branch=master&svg=true"
appVeyorLink :: Text =
"https://ci.appveyor.com/project/" <> owner <> "/" <> repo
licenseShield :: Text =
"https://img.shields.io/badge/license-" <> T.replace "-" "--" license <> "-blue.svg"
licenseLink :: Text =
Expand Down Expand Up @@ -884,6 +901,32 @@ createStackTemplate
$endLine
|]

-- create appveyor.yml template
appVeyorYml :: Text
appVeyorYml =
[text|
{-# START_FILE appveyor.yml #-}
build: off

before_test:
# http://help.appveyor.com/discussions/problems/6312-curl-command-not-found
- set PATH=C:\Program Files\Git\mingw64\bin;%PATH%

- curl -sS -ostack.zip -L --insecure http://www.stackage.org/stack/windows-i386
- 7z x stack.zip stack.exe

clone_folder: "c:\\stack"
environment:
global:
STACK_ROOT: "c:\\sr"

test_script:
- stack setup > nul
# The ugly echo "" hack is to avoid complaints about 0 being an invalid file
# descriptor
- echo "" | stack --no-terminal build --bench --no-run-benchmarks --test
|]

scriptSh :: Text
scriptSh =
[text|
Expand Down

0 comments on commit eae9086

Please sign in to comment.