Skip to content

Try windows #229

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,28 @@ matrix:
- compiler: "ghc-8.4.4"
addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.4,ghc-8.4.4], sources: [hvr-ghc]}}
os: osx
- compiler: "ghc-8.4.4"
addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.4,ghc-8.4.4], sources: [hvr-ghc]}}
os: windows

allow_failures:
- compiler: "ghc-head"

before_install:
- HC=/opt/ghc/bin/${CC}
- HCVER=$(echo "$TRAVIS_COMPILER" | sed 's/ghc-//')
- echo $HCVER
- HCPKG=${HC/ghc/ghc-pkg}
- unset CC
- CABAL=/opt/ghc/bin/cabal
- CABALHOME=$HOME/.cabal
- if [ "$TRAVIS_OS_NAME" = "windows" ]; then CABALHOME=$APPDATA/cabal; fi
- export PATH="$CABALHOME/bin:$PATH"
- ROOTDIR=$(pwd)
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then brew update; brew upgrade python@3; curl https://haskell.futurice.com/haskell-on-macos.py | python3 - --make-dirs --install-dir=$HOME/.ghc-install --cabal-alias=head install cabal-install-head ${TRAVIS_COMPILER}; fi
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then HC=$HOME/.ghc-install/ghc/bin/$TRAVIS_COMPILER; HCPKG=${HC/ghc/ghc-pkg}; CABAL=$HOME/.ghc-install/ghc/bin/cabal; fi
- if [ "$TRAVIS_OS_NAME" = "windows" ]; then choco install -y cabal --version 2.4.1.0; choco install -y ghc --version ${HCVER} ; fi
- if [ "$TRAVIS_OS_NAME" = "windows" ]; then HC=/c/ProgramData/chocolatey/lib/ghc/tools/$TRAVIS_COMPILER/bin/ghc.exe; CABAL=/c/ProgramData/chocolatey/lib/cabal/tools/cabal-2.4.1.0/cabal.exe; fi
- HCNUMVER=$(( $(${HC} --numeric-version|sed -E 's/([0-9]+)\.([0-9]+)\.([0-9]+).*/\1 * 10000 + \2 * 100 + \3/') ))
- echo $HCNUMVER

Expand All @@ -70,6 +78,7 @@ install:
- TEST=--enable-tests
- BENCH=--enable-benchmarks
- GHCHEAD=${GHCHEAD-false}
- if [ "$TRAVIS_OS_NAME" = "windows" ]; then export CABALHOME=$APPDATA/cabal; else export CABALHOME=$HOME/.cabal; fi
- travis_retry ${CABAL} update -v
- sed -i.bak 's/^jobs:/-- jobs:/' $CABALHOME/config
- rm -fv cabal.project cabal.project.local
Expand All @@ -94,8 +103,6 @@ install:
${CABAL} new-update head.hackage -v
fi
- grep -Ev -- '^\s*--' $CABALHOME/config | grep -Ev '^\s*$'
- ${CABAL} new-install -w ${HC} -j2 doctest --constraint='doctest ==0.16.*'
- if [ $HCNUMVER -eq 80603 ] ; then ${CABAL} new-install -w ${HC} -j2 hlint --constraint='hlint ==2.1.*' ; fi
- rm -f cabal.project
- touch cabal.project
- "printf 'packages: \".\"\\n' >> cabal.project"
Expand Down Expand Up @@ -147,13 +154,6 @@ script:
- ${CABAL} new-build -w ${HC} ${TEST} ${BENCH} all
- if [ "x$TEST" = "x--enable-tests" ]; then ${CABAL} new-test -w ${HC} ${TEST} ${BENCH} all; fi

# doctest
- (cd haskell-ci-* && doctest --fast -XDeriveFoldable -XDeriveFunctor -XDeriveGeneric -XDeriveTraversable src)

# hlint
- if [ $HCNUMVER -eq 80603 ] ; then (cd haskell-ci-* && hlint -h ${ROOTDIR}/.hlint.yaml -XDeriveFoldable -XDeriveFunctor -XDeriveGeneric -XDeriveTraversable src) ; fi
- if [ $HCNUMVER -eq 80603 ] ; then (cd haskell-ci-* && hlint -h ${ROOTDIR}/.hlint.yaml cli) ; fi

# cabal check
- (cd haskell-ci-* && ${CABAL} check)

Expand Down
7 changes: 5 additions & 2 deletions cabal.haskell-ci
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,21 @@ branches: master
folds: constraint-sets

-- Run HLint (needs GHC-8.2.2 job)
hlint: True
hlint: False
hlint-yaml: .hlint.yaml
-- hlint-version: ==2.0.*

-- Run doctest (on GHC-8.0+ which support .ghc.environment)
doctest: True
doctest: False
doctest-options: --fast
-- doctest-version: ==0.13.*

-- macOS job
osx: 8.4.4

-- windows job
windows: 8.4.4

-- Constraint sets
-- Package will be build with different constraints.
-- This is useful to check compatibility with older versions of dependencies.
Expand Down
3 changes: 3 additions & 0 deletions fixtures/cabal.project.copy-fields.all.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ matrix:

before_install:
- HC=/opt/ghc/bin/${CC}
- HCVER=$(echo "$TRAVIS_COMPILER" | sed 's/ghc-//')
- echo $HCVER
- HCPKG=${HC/ghc/ghc-pkg}
- unset CC
- CABAL=/opt/ghc/bin/cabal
Expand All @@ -82,6 +84,7 @@ install:
- TEST=--enable-tests
- BENCH=--enable-benchmarks
- GHCHEAD=${GHCHEAD-false}
- if [ "$TRAVIS_OS_NAME" = "windows" ]; then export CABALHOME=$APPDATA/cabal; else export CABALHOME=$HOME/.cabal; fi
- travis_retry ${CABAL} update -v
- sed -i.bak 's/^jobs:/-- jobs:/' $CABALHOME/config
- rm -fv cabal.project cabal.project.local
Expand Down
3 changes: 3 additions & 0 deletions fixtures/cabal.project.copy-fields.none.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ matrix:

before_install:
- HC=/opt/ghc/bin/${CC}
- HCVER=$(echo "$TRAVIS_COMPILER" | sed 's/ghc-//')
- echo $HCVER
- HCPKG=${HC/ghc/ghc-pkg}
- unset CC
- CABAL=/opt/ghc/bin/cabal
Expand All @@ -82,6 +84,7 @@ install:
- TEST=--enable-tests
- BENCH=--enable-benchmarks
- GHCHEAD=${GHCHEAD-false}
- if [ "$TRAVIS_OS_NAME" = "windows" ]; then export CABALHOME=$APPDATA/cabal; else export CABALHOME=$HOME/.cabal; fi
- travis_retry ${CABAL} update -v
- sed -i.bak 's/^jobs:/-- jobs:/' $CABALHOME/config
- rm -fv cabal.project cabal.project.local
Expand Down
3 changes: 3 additions & 0 deletions fixtures/cabal.project.copy-fields.some.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ matrix:

before_install:
- HC=/opt/ghc/bin/${CC}
- HCVER=$(echo "$TRAVIS_COMPILER" | sed 's/ghc-//')
- echo $HCVER
- HCPKG=${HC/ghc/ghc-pkg}
- unset CC
- CABAL=/opt/ghc/bin/cabal
Expand All @@ -82,6 +84,7 @@ install:
- TEST=--enable-tests
- BENCH=--enable-benchmarks
- GHCHEAD=${GHCHEAD-false}
- if [ "$TRAVIS_OS_NAME" = "windows" ]; then export CABALHOME=$APPDATA/cabal; else export CABALHOME=$HOME/.cabal; fi
- travis_retry ${CABAL} update -v
- sed -i.bak 's/^jobs:/-- jobs:/' $CABALHOME/config
- rm -fv cabal.project cabal.project.local
Expand Down
3 changes: 3 additions & 0 deletions fixtures/cabal.project.empty-line.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ matrix:

before_install:
- HC=/opt/ghc/bin/${CC}
- HCVER=$(echo "$TRAVIS_COMPILER" | sed 's/ghc-//')
- echo $HCVER
- HCPKG=${HC/ghc/ghc-pkg}
- unset CC
- CABAL=/opt/ghc/bin/cabal
Expand All @@ -88,6 +90,7 @@ install:
- TEST=--enable-tests
- BENCH=--enable-benchmarks
- GHCHEAD=${GHCHEAD-false}
- if [ "$TRAVIS_OS_NAME" = "windows" ]; then export CABALHOME=$APPDATA/cabal; else export CABALHOME=$HOME/.cabal; fi
- travis_retry ${CABAL} update -v
- sed -i.bak 's/^jobs:/-- jobs:/' $CABALHOME/config
- rm -fv cabal.project cabal.project.local
Expand Down
3 changes: 3 additions & 0 deletions fixtures/cabal.project.messy.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ matrix:

before_install:
- HC=/opt/ghc/bin/${CC}
- HCVER=$(echo "$TRAVIS_COMPILER" | sed 's/ghc-//')
- echo $HCVER
- HCPKG=${HC/ghc/ghc-pkg}
- unset CC
- CABAL=/opt/ghc/bin/cabal
Expand All @@ -88,6 +90,7 @@ install:
- TEST=--enable-tests
- BENCH=--enable-benchmarks
- GHCHEAD=${GHCHEAD-false}
- if [ "$TRAVIS_OS_NAME" = "windows" ]; then export CABALHOME=$APPDATA/cabal; else export CABALHOME=$HOME/.cabal; fi
- travis_retry ${CABAL} update -v
- sed -i.bak 's/^jobs:/-- jobs:/' $CABALHOME/config
- rm -fv cabal.project cabal.project.local
Expand Down
1 change: 1 addition & 0 deletions fixtures/haskell-ci.cabal.stderr
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*INFO* Generating Travis-CI config for testing for GHC versions: head 8.0.2 8.2.2 8.4.4 8.6.3
*INFO* Also OSX jobs for: 8.4.4
*INFO* Also Windows jobs for: 8.4.4
2 changes: 1 addition & 1 deletion haskell-ci.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ test-suite golden
main-is: Tests.hs
hs-source-dirs: test
build-depends:
, ansi-terminal ^>=0.8.0.2
, ansi-terminal ^>=0.9
, base
, bytestring
, Diff ^>=0.3.4
Expand Down
67 changes: 51 additions & 16 deletions src/HaskellCI.hs
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,9 @@ configFromCabalFile cfg opts cabalFile = do

filterLastMajor = map maximum . groupBy ((==) `on` ghcMajVer)

data OS = Linux | MacOS | Windows
deriving (Eq, Show)

genTravisFromConfigs
:: Monad m
=> [String]
Expand All @@ -329,11 +332,28 @@ genTravisFromConfigs argv opts isCabalProject config prj@Project { prjPackages =
putStrLnInfo $
"Generating Travis-CI config for testing for GHC versions: " ++ ghcVersions

unless (null $ cfgOsx config) $ do
unless (null $ cfgOsx config) $ do
let ghcOsxVersions :: String
ghcOsxVersions = showVersions $ S.map Just osxVersions

let ghcOmittedOsxVersions :: String
ghcOmittedOsxVersions = showVersions $ S.map Just omittedOsxVersions

putStrLnInfo $ "Also OSX jobs for: " ++ ghcOsxVersions
unless (S.null omittedOsxVersions) $
putStrLnWarn $ "Not all GHC versions specified with --osx are generated: " ++ ghcOmittedOsxVersions

unless (null $ cfgWindows config) $ do
let ghcWindowsVersions :: String
ghcWindowsVersions = showVersions $ S.map Just windowsVersions

let ghcOmittedWindowsVersions :: String
ghcOmittedWindowsVersions = showVersions $ S.map Just omittedWindowsVersions

putStrLnInfo $ "Also Windows jobs for: " ++ ghcWindowsVersions
unless (S.null omittedWindowsVersions) $
putStrLnWarn $ "Not all GHC versions specified with --windows are generated: " ++ ghcOmittedWindowsVersions

---------------------------------------------------------------------------
-- travis.yml generation starts here

Expand Down Expand Up @@ -421,8 +441,8 @@ genTravisFromConfigs argv opts isCabalProject config prj@Project { prjPackages =

let colls = [ (collToGhcVer cid,cid) | cid <- reverse $ optCollections opts ]

let tellJob :: Monad m => Bool -> Maybe Version -> YamlWriter m ()
tellJob osx gv = do
let tellJob :: Monad m => OS -> Maybe Version -> YamlWriter m ()
tellJob os gv = do
let cvs = dispGhcVersion $ gv >> cfgCabalInstallVersion config
gvs = dispGhcVersion gv

Expand All @@ -440,14 +460,18 @@ genTravisFromConfigs argv opts isCabalProject config prj@Project { prjPackages =
, Just $ " addons: {apt: {packages: [ghc-ppa-tools,cabal-install-" <> cvs <> ",ghc-" <> gvs <> xpkgs' <> "], sources: [hvr-ghc]}}"
]

when osx $ tellStrLnsRaw
when (os == MacOS) $ tellStrLns
[ " os: osx"
]
when (os == Windows) $ tellStrLns
[ " os: windows"
]

-- newer GHC first, -head last (which is great).
-- Alpha release would go first though.
F.forM_ (reverse $ S.toList versions) $ tellJob False
F.forM_ (reverse $ S.toList osxVersions) $ tellJob True . Just
F.forM_ (reverse $ S.toList versions) $ tellJob Linux
F.forM_ (reverse $ S.toList osxVersions) $ tellJob MacOS . Just
F.forM_ (reverse $ S.toList windowsVersions) $ tellJob Windows . Just

let allowFailures = headGhcVers `S.union` S.map Just (S.filter (`C.withinRange` cfgAllowFailures config) versions')
unless (S.null allowFailures) $ do
Expand All @@ -462,11 +486,16 @@ genTravisFromConfigs argv opts isCabalProject config prj@Project { prjPackages =
[ ""
, "before_install:"
, sh "HC=/opt/ghc/bin/${CC}"
, sh "HCVER=$(echo \"$TRAVIS_COMPILER\" | sed 's/ghc-//')"
, sh "echo $HCVER"
, sh' [2034,2039] "HCPKG=${HC/ghc/ghc-pkg}" -- SC2039. In POSIX sh, string replacement is undefined.
, sh "unset CC"
-- cabal
, sh "CABAL=/opt/ghc/bin/cabal"
, sh "CABALHOME=$HOME/.cabal"
, if null windowsVersions
then RowSkip
else sh "if [ \"$TRAVIS_OS_NAME\" = \"windows\" ]; then CABALHOME=$APPDATA/cabal; fi"
-- PATH
, sh "export PATH=\"$CABALHOME/bin:$PATH\""
-- rootdir is useful for manual script additions
Expand All @@ -475,11 +504,17 @@ genTravisFromConfigs argv opts isCabalProject config prj@Project { prjPackages =

-- macOS installing
let haskellOnMacos = "https://haskell.futurice.com/haskell-on-macos.py"
unless (null (cfgOsx config)) $ tellStrLns
unless (null osxVersions) $ tellStrLns
[ sh $ "if [ \"$TRAVIS_OS_NAME\" = \"osx\" ]; then brew update; brew upgrade python@3; curl " ++ haskellOnMacos ++ " | python3 - --make-dirs --install-dir=$HOME/.ghc-install --cabal-alias=head install cabal-install-head ${TRAVIS_COMPILER}; fi"
, sh' [2034,2039] "if [ \"$TRAVIS_OS_NAME\" = \"osx\" ]; then HC=$HOME/.ghc-install/ghc/bin/$TRAVIS_COMPILER; HCPKG=${HC/ghc/ghc-pkg}; CABAL=$HOME/.ghc-install/ghc/bin/cabal; fi"
]

-- Windows installing
unless (null windowsVersions) $ tellStrLns
[ sh $ "if [ \"$TRAVIS_OS_NAME\" = \"windows\" ]; then choco install -y cabal --version 2.4.1.0; choco install -y ghc --version ${HCVER} ; fi"
, sh $ "if [ \"$TRAVIS_OS_NAME\" = \"windows\" ]; then HC=/c/ProgramData/chocolatey/lib/ghc/tools/$TRAVIS_COMPILER/bin/ghc.exe; CABAL=/c/ProgramData/chocolatey/lib/cabal/tools/cabal-2.4.1.0/cabal.exe; fi"
]

-- HCNUMVER, numeric HC version, e.g. ghc 7.8.4 is 70804 and 7.10.3 is 71003
tellStrLns
[ sh $ "HCNUMVER=$(( $(${HC} --numeric-version|sed -E 's/([0-9]+)\\.([0-9]+)\\.([0-9]+).*/\\1 * 10000 + \\2 * 100 + \\3/') ))"
Expand Down Expand Up @@ -556,7 +591,8 @@ genTravisFromConfigs argv opts isCabalProject config prj@Project { prjPackages =
| isAnyVersion (cfgDoctestVersion doctestConfig) = ""
| otherwise = " --constraint='doctest " ++ display (cfgDoctestVersion doctestConfig) ++ "'"
when (cfgDoctestEnabled doctestConfig) $ tellStrLns
[ shForJob versions' doctestJobVersionRange $ "${CABAL} new-install -w ${HC} -j2 doctest" ++ doctestVersionConstraint
[ shForJob versions' doctestJobVersionRange $
"(cd / && ${CABAL} new-install -w ${HC} -j2 doctest" ++ doctestVersionConstraint ++ ")"
]

-- Install hlint
Expand All @@ -565,7 +601,7 @@ genTravisFromConfigs argv opts isCabalProject config prj@Project { prjPackages =
| otherwise = " --constraint='hlint " ++ display (cfgHLintVersion hlintConfig) ++ "'"
when (cfgHLintEnabled hlintConfig) $ tellStrLns
[ shForJob versions' (hlintJobVersionRange versions (cfgHLintJob hlintConfig)) $
"${CABAL} new-install -w ${HC} -j2 hlint" ++ hlintVersionConstraint
"(cd / && ${CABAL} new-install -w ${HC} -j2 hlint" ++ hlintVersionConstraint ++ ")"
]

-- create cabal.project file
Expand Down Expand Up @@ -908,10 +944,13 @@ genTravisFromConfigs argv opts isCabalProject config prj@Project { prjPackages =
showVersions :: Set (Maybe Version) -> String
showVersions = unwords . map dispGhcVersion . S.toList

-- specified ersions
-- specified versions
osxVersions' :: Set Version
osxVersions' = cfgOsx config

windowsVersions' :: Set Version
windowsVersions' = cfgWindows config

versions :: Set (Maybe Version)
versions
| cfgGhcHead config = S.insert Nothing $ S.map Just versions'
Expand All @@ -923,12 +962,8 @@ genTravisFromConfigs argv opts isCabalProject config prj@Project { prjPackages =
osxVersions, omittedOsxVersions :: Set Version
(osxVersions, omittedOsxVersions) = S.partition (`S.member` versions') osxVersions'

ghcOsxVersions :: String
ghcOsxVersions = showVersions $ S.map Just osxVersions

ghcOmittedOsxVersions :: String
ghcOmittedOsxVersions = showVersions $ S.map Just omittedOsxVersions

windowsVersions, omittedWindowsVersions :: Set Version
(windowsVersions, omittedWindowsVersions) = S.partition (`S.member` versions') windowsVersions'

collToGhcVer :: String -> Version
collToGhcVer cid = case simpleParse cid of
Expand Down
4 changes: 4 additions & 0 deletions src/HaskellCI/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ data Config = Config
, cfgAllowFailures :: !VersionRange
, cfgLastInSeries :: !Bool
, cfgOsx :: S.Set Version
, cfgWindows :: S.Set Version
, cfgApt :: S.Set String
, cfgDoctest :: !DoctestConfig
, cfgHLint :: !HLintConfig
Expand Down Expand Up @@ -121,6 +122,7 @@ emptyConfig = Config
, cfgAllowFailures = noVersion
, cfgLastInSeries = False
, cfgOsx = S.empty
, cfgWindows = S.empty
, cfgApt = S.empty
, cfgRawProject = []
}
Expand Down Expand Up @@ -183,6 +185,8 @@ configGrammar = Config
^^^ help "[Discouraged] Assume there are only GHCs last in major series: 8.2.* will match only 8.2.2"
<*> C.monoidalFieldAla "osx" (alaSet C.NoCommaFSep) #cfgOsx
^^^ metahelp "JOB" "Jobs to additionally build with OSX"
<*> C.monoidalFieldAla "windows" (alaSet C.NoCommaFSep) #cfgWindows
^^^ metahelp "JOB" "Jobs to additionally build with Windows"
<*> C.monoidalFieldAla "apt" (alaSet' C.NoCommaFSep C.Token') #cfgApt
^^^ metahelp "PKG" "Additional apt packages to install"
<*> C.blurFieldGrammar #cfgDoctest doctestConfigGrammar
Expand Down