diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0bcf691a..860f1912 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,16 +20,16 @@ jobs: - "8.10.1" steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v2.3.3 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.3 name: Setup Haskell with: ghc-version: ${{ matrix.ghc }} cabal-version: ${{ matrix.cabal }} - - uses: actions/cache@v1 + - uses: actions/cache@v2.1.2 name: Cache ~/.cabal/store with: path: ~/.cabal/store diff --git a/appveyor.yml b/appveyor.yml index 1923824e..3314fbae 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -17,7 +17,7 @@ cache: environment: STACK_ROOT: C:\sr - STACK_VERSION: 2.1.1 + STACK_VERSION: 2.5.1 matrix: - STACK_YAML: stack.yaml diff --git a/summoner-cli/examples/cabal-full/.github/workflows/ci.yml b/summoner-cli/examples/cabal-full/.github/workflows/ci.yml index a2a33799..d18cc5ac 100644 --- a/summoner-cli/examples/cabal-full/.github/workflows/ci.yml +++ b/summoner-cli/examples/cabal-full/.github/workflows/ci.yml @@ -7,39 +7,58 @@ on: branches: [master] jobs: - build: - name: ghc ${{ matrix.ghc }} - runs-on: ubuntu-16.04 + cabal: + name: ${{ matrix.os }} / ghc ${{ matrix.ghc }} + runs-on: ${{ matrix.os }} strategy: matrix: + os: [ubuntu-latest, macOS-latest, windows-latest] cabal: ["2.4"] ghc: - "8.4.4" - "8.6.5" - "8.8.4" - "8.10.1" + exclude: + - os: macOS-latest + ghc: 8.8.4 + - os: macOS-latest + ghc: 8.6.5 + - os: macOS-latest + ghc: 8.4.4 + - os: windows-latest + ghc: 8.8.4 + - os: windows-latest + ghc: 8.6.5 + - os: windows-latest + ghc: 8.4.4 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v2.3.3 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.3 + id: setup-haskell-cabal name: Setup Haskell with: ghc-version: ${{ matrix.ghc }} cabal-version: ${{ matrix.cabal }} - - uses: actions/cache@v1 + - name: Freeze + run: | + cabal v2-freeze + + - uses: actions/cache@v2.1.2 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 --enable-tests --enable-benchmarks + cabal v2-configure --enable-tests --enable-benchmarks --test-show-details=direct + cabal v2-build all - name: Test run: | - cabal v2-test --enable-tests --test-show-details=direct + cabal v2-test all diff --git a/summoner-cli/examples/cabal-full/.travis.yml b/summoner-cli/examples/cabal-full/.travis.yml index 8ce49459..d7e44f54 100644 --- a/summoner-cli/examples/cabal-full/.travis.yml +++ b/summoner-cli/examples/cabal-full/.travis.yml @@ -21,10 +21,11 @@ install: - 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 + - cabal v2-configure --enable-tests --enable-benchmarks --test-show-details=direct + - cabal v2-build all script: - - cabal v2-test --enable-tests --test-show-details=direct + - cabal v2-test all notifications: email: false diff --git a/summoner-cli/examples/cabal-full/appveyor.yml b/summoner-cli/examples/cabal-full/appveyor.yml index 4f3ae376..4674d4b6 100644 --- a/summoner-cli/examples/cabal-full/appveyor.yml +++ b/summoner-cli/examples/cabal-full/appveyor.yml @@ -35,5 +35,6 @@ before_build: - cabal %CABOPTS% v2-update build_script: - - cabal %CABOPTS% v2-build --enable-tests - - cabal %CABOPTS% v2-test --enable-tests --test-show-details=direct + - cabal %CABOPTS% v2-configure --enable-tests --enable-benchmarks --test-show-details=direct + - cabal %CABOPTS% v2-build all + - cabal %CABOPTS% v2-test all diff --git a/summoner-cli/examples/full-batteries/.github/workflows/ci.yml b/summoner-cli/examples/full-batteries/.github/workflows/ci.yml index 2b3cd4c5..70097cfe 100644 --- a/summoner-cli/examples/full-batteries/.github/workflows/ci.yml +++ b/summoner-cli/examples/full-batteries/.github/workflows/ci.yml @@ -7,11 +7,12 @@ on: branches: [master] jobs: - build: - name: ghc ${{ matrix.ghc }} - runs-on: ubuntu-16.04 + cabal: + name: ${{ matrix.os }} / ghc ${{ matrix.ghc }} + runs-on: ${{ matrix.os }} strategy: matrix: + os: [ubuntu-latest, macOS-latest, windows-latest] cabal: ["2.4"] ghc: - "8.0.2" @@ -20,28 +21,92 @@ jobs: - "8.6.5" - "8.8.4" - "8.10.1" + exclude: + - os: macOS-latest + ghc: 8.8.4 + - os: macOS-latest + ghc: 8.6.5 + - os: macOS-latest + ghc: 8.4.4 + - os: macOS-latest + ghc: 8.2.2 + - os: macOS-latest + ghc: 8.0.2 + - os: windows-latest + ghc: 8.8.4 + - os: windows-latest + ghc: 8.6.5 + - os: windows-latest + ghc: 8.4.4 + - os: windows-latest + ghc: 8.2.2 + - os: windows-latest + ghc: 8.0.2 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v2.3.3 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.3 + id: setup-haskell-cabal name: Setup Haskell with: ghc-version: ${{ matrix.ghc }} cabal-version: ${{ matrix.cabal }} - - uses: actions/cache@v1 + - name: Freeze + run: | + cabal v2-freeze + + - uses: actions/cache@v2.1.2 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-configure --enable-tests --enable-benchmarks --test-show-details=direct + cabal v2-build all + + - name: Test + run: | + cabal v2-test all + + stack: + name: stack / ghc ${{ matrix.ghc }} + runs-on: ubuntu-latest + strategy: + matrix: + stack: ["2.5.1"] + ghc: + - "8.0.2" + - "8.2.2" + - "8.4.4" + - "8.6.5" + - "8.8.4" + - "8.10.1" + + steps: + - uses: actions/checkout@v2.3.3 + if: github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.ref == 'refs/heads/master' + + - uses: actions/setup-haskell@v1.1.3 + name: Setup Haskell Stack + with: + ghc-version: ${{ matrix.ghc }} + stack-version: ${{ matrix.stack }} + + - uses: actions/cache@v2.1.2 + name: Cache ~/.stack + with: + path: ~/.stack + key: ${{ runner.os }}-${{ matrix.ghc }}-stack - name: Build run: | - cabal v2-update - cabal v2-build --enable-tests --enable-benchmarks + stack build --system-ghc --test --bench --no-run-tests --no-run-benchmarks --ghc-options=-Werror - name: Test run: | - cabal v2-test --enable-tests --test-show-details=direct + stack test --system-ghc diff --git a/summoner-cli/examples/full-batteries/.travis.yml b/summoner-cli/examples/full-batteries/.travis.yml index 46775e8b..18aea03b 100644 --- a/summoner-cli/examples/full-batteries/.travis.yml +++ b/summoner-cli/examples/full-batteries/.travis.yml @@ -56,7 +56,8 @@ install: - | if [ -z "$STACK_YAML" ]; then cabal v2-update - cabal v2-build --enable-tests --enable-benchmarks + cabal v2-configure --enable-tests --enable-benchmarks --test-show-details=direct + cabal v2-build all else curl -sSL https://get.haskellstack.org/ | sh stack --version @@ -66,7 +67,7 @@ install: script: - | if [ -z "$STACK_YAML" ]; then - cabal v2-test --enable-tests --test-show-details=direct + cabal v2-test all else stack test --system-ghc fi diff --git a/summoner-cli/examples/full-batteries/appveyor.yml b/summoner-cli/examples/full-batteries/appveyor.yml index 4f3ae376..4674d4b6 100644 --- a/summoner-cli/examples/full-batteries/appveyor.yml +++ b/summoner-cli/examples/full-batteries/appveyor.yml @@ -35,5 +35,6 @@ before_build: - cabal %CABOPTS% v2-update build_script: - - cabal %CABOPTS% v2-build --enable-tests - - cabal %CABOPTS% v2-test --enable-tests --test-show-details=direct + - cabal %CABOPTS% v2-configure --enable-tests --enable-benchmarks --test-show-details=direct + - cabal %CABOPTS% v2-build all + - cabal %CABOPTS% v2-test all diff --git a/summoner-cli/examples/stack-full/.github/workflows/ci.yml b/summoner-cli/examples/stack-full/.github/workflows/ci.yml new file mode 100644 index 00000000..0518af88 --- /dev/null +++ b/summoner-cli/examples/stack-full/.github/workflows/ci.yml @@ -0,0 +1,44 @@ +name: CI + +# Trigger the workflow on push or pull request, but only for the master branch +on: + pull_request: + push: + branches: [master] + +jobs: + stack: + name: stack / ghc ${{ matrix.ghc }} + runs-on: ubuntu-latest + strategy: + matrix: + stack: ["2.5.1"] + ghc: + - "8.4.4" + - "8.6.5" + - "8.8.4" + - "8.10.1" + + steps: + - uses: actions/checkout@v2.3.3 + if: github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.ref == 'refs/heads/master' + + - uses: actions/setup-haskell@v1.1.3 + name: Setup Haskell Stack + with: + ghc-version: ${{ matrix.ghc }} + stack-version: ${{ matrix.stack }} + + - uses: actions/cache@v2.1.2 + name: Cache ~/.stack + with: + path: ~/.stack + key: ${{ runner.os }}-${{ matrix.ghc }}-stack + + - name: Build + run: | + stack build --system-ghc --test --bench --no-run-tests --no-run-benchmarks --ghc-options=-Werror + + - name: Test + run: | + stack test --system-ghc diff --git a/summoner-cli/examples/stack-full/README.md b/summoner-cli/examples/stack-full/README.md index cd34d786..8b873143 100644 --- a/summoner-cli/examples/stack-full/README.md +++ b/summoner-cli/examples/stack-full/README.md @@ -1,5 +1,6 @@ # stack-full +[![GitHub CI](https://github.com/kowainik/stack-full/workflows/CI/badge.svg)](https://github.com/kowainik/stack-full/actions) [![Build status](https://img.shields.io/travis/kowainik/stack-full.svg?logo=travis)](https://travis-ci.com/kowainik/stack-full) [![Windows build status](https://ci.appveyor.com/api/projects/status/github/kowainik/stack-full?branch=master&svg=true)](https://ci.appveyor.com/project/kowainik/stack-full) [![Hackage](https://img.shields.io/hackage/v/stack-full.svg?logo=haskell)](https://hackage.haskell.org/package/stack-full) diff --git a/summoner-cli/examples/stack-full/appveyor.yml b/summoner-cli/examples/stack-full/appveyor.yml index 9e96546d..c7223f27 100644 --- a/summoner-cli/examples/stack-full/appveyor.yml +++ b/summoner-cli/examples/stack-full/appveyor.yml @@ -10,7 +10,7 @@ branches: environment: STACK_ROOT: C:\sr - STACK_VERSION: 2.1.1 + STACK_VERSION: 2.5.1 # Workaround a gnarly bug https://github.com/haskell/cabal/issues/5386 # See: https://www.fpcomplete.com/blog/2018/06/sed-a-debugging-story diff --git a/summoner-cli/src/Summoner/Default.hs b/summoner-cli/src/Summoner/Default.hs index 4ee9bcf6..e0b80d0f 100644 --- a/summoner-cli/src/Summoner/Default.hs +++ b/summoner-cli/src/Summoner/Default.hs @@ -12,6 +12,7 @@ This module contains some default values to use. module Summoner.Default ( defaultGHC , defaultCabal + , defaultStack , defaultLicenseName , defaultOwner , defaultFullName @@ -42,6 +43,10 @@ defaultGHC = maxBound defaultCabal :: Text defaultCabal = "2.4" +-- | Default version of the Stack. +defaultStack :: Text +defaultStack = "2.5.1" + defaultLicenseName :: LicenseName defaultLicenseName = MIT diff --git a/summoner-cli/src/Summoner/Project.hs b/summoner-cli/src/Summoner/Project.hs index 643f2298..ecf0893e 100644 --- a/summoner-cli/src/Summoner/Project.hs +++ b/summoner-cli/src/Summoner/Project.hs @@ -98,7 +98,7 @@ generateProjectInteractive connectMode projectName ConfigP{..} = do (settingsGitHub && not settingsNoUpload) (YesNoPrompt "private repository" "Create as a private repository (Requires a GitHub private repo plan)?") cPrivate - settingsGhActions <- decisionIf (settingsCabal && settingsGitHub) (mkDefaultYesNoPrompt "GitHub Actions CI integration") cGhActions + settingsGhActions <- decisionIf settingsGitHub (mkDefaultYesNoPrompt "GitHub Actions CI integration") cGhActions settingsTravis <- decisionIf settingsGitHub (mkDefaultYesNoPrompt "Travis CI integration") cTravis settingsAppVeyor <- decisionIf settingsGitHub (mkDefaultYesNoPrompt "AppVeyor CI integration") cAppVey settingsIsLib <- promptDecisionToBool cLib (mkDefaultYesNoPrompt "library target") diff --git a/summoner-cli/src/Summoner/Template/GitHub.hs b/summoner-cli/src/Summoner/Template/GitHub.hs index 2d94c7c7..21557913 100644 --- a/summoner-cli/src/Summoner/Template/GitHub.hs +++ b/summoner-cli/src/Summoner/Template/GitHub.hs @@ -29,7 +29,7 @@ module Summoner.Template.GitHub import Colourista (indent) import Data.List (delete, intersect) -import Summoner.Default (defaultCabal, defaultGHC) +import Summoner.Default (defaultCabal, defaultGHC, defaultStack) import Summoner.GhcVer (GhcVer (..), oldGhcs, showGhcVer) import Summoner.Settings (Settings (..)) import Summoner.Text (quote) @@ -121,36 +121,54 @@ gitHubFiles Settings{..} = concat , " branches: [master]" , "" , "jobs:" - , " build:" - , " name: ghc ${{ matrix.ghc }}" - , " runs-on: ubuntu-16.04" + ] + <> memptyIfFalse settingsCabal ghActionsCabal + <> memptyIfFalse (settingsCabal && settingsStack) [""] + <> memptyIfFalse settingsStack ghActionsStack + + ghcActionsCheckoutVersion = "@v2.3.3" + ghcActionsSetupHaskellVersion = "@v1.1.3" + ghcActionsCacheVersion = "@v2.1.2" + + ghActionsCabal :: [Text] + ghActionsCabal = + [ " cabal:" + , " name: ${{ matrix.os }} / ghc ${{ matrix.ghc }}" + , " runs-on: ${{ matrix.os }}" , " strategy:" , " matrix:" + , " os: [ubuntu-latest, macOS-latest, windows-latest]" , " cabal: [" <> quote defaultCabal <> "]" , " ghc:" ] <> map (indent 10 <>) ghActionsVersions + <> ghActionsExcludes <> [ "" , " steps:" - , " - uses: actions/checkout@v2" + , " - uses: actions/checkout" <> ghcActionsCheckoutVersion , " if: github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.ref == 'refs/heads/master'" , "" - , " - uses: actions/setup-haskell@v1" + , " - uses: actions/setup-haskell" <> ghcActionsSetupHaskellVersion + , " id: setup-haskell-cabal" , " name: Setup Haskell" , " with:" , " ghc-version: ${{ matrix.ghc }}" , " cabal-version: ${{ matrix.cabal }}" , "" - , " - uses: actions/cache@v1" + , " - name: Freeze" + , " run: |" + , " cabal v2-freeze" + , "" + , " - uses: actions/cache" <> ghcActionsCacheVersion , " 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: |" - , " " <> cabalUpdate + , " " <> cabalConfigure , " " <> cabalBuild , "" , " - name: Test" @@ -158,12 +176,66 @@ gitHubFiles Settings{..} = concat , " " <> cabalTest ] + ghActionsStack :: [Text] + ghActionsStack = + [ " stack:" + , " name: stack / ghc ${{ matrix.ghc }}" + , " runs-on: ubuntu-latest" + , " strategy:" + , " matrix:" + , " stack: [" <> quote defaultStack <> "]" + , " ghc:" + ] + <> map (indent 10 <>) ghActionsVersions + <> + [ "" + , " steps:" + , " - uses: actions/checkout" <> ghcActionsCheckoutVersion + , " if: github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.ref == 'refs/heads/master'" + , "" + , " - uses: actions/setup-haskell" <> ghcActionsSetupHaskellVersion + , " name: Setup Haskell Stack" + , " with:" + , " ghc-version: ${{ matrix.ghc }}" + , " stack-version: ${{ matrix.stack }}" + , "" + , " - uses: actions/cache" <> ghcActionsCacheVersion + , " name: Cache ~/.stack" + , " with:" + , " path: ~/.stack" + , " key: ${{ runner.os }}-${{ matrix.ghc }}-stack" + , "" + , " - name: Build" + , " run: |" + , " " <> stackBuild + , "" + , " - name: Test" + , " run: |" + , " " <> stackTest + ] ghActionsVersions :: [Text] ghActionsVersions = map (\ghc -> "- " <> quote (showGhcVer ghc)) settingsTestedVersions + ghActionsExcludes :: [Text] + ghActionsExcludes = + let versionsToExclude = -- all but the latest version + drop 1 $ sortWith Down settingsTestedVersions + osesToExclude = ["macOS-latest", "windows-latest"] + 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 travisYml = unlines $ @@ -256,6 +328,7 @@ gitHubFiles Settings{..} = concat [ " - |" , " if [ -z " <> quote "$STACK_YAML" <> " ]; then" , " " <> cabalUpdate + , " " <> cabalConfigure , " " <> cabalBuild , " else" , " curl -sSL https://get.haskellstack.org/ | sh" @@ -275,6 +348,7 @@ gitHubFiles Settings{..} = concat installScriptCabal :: [Text] installScriptCabal = [ " - " <> cabalUpdate + , " - " <> cabalConfigure , " - " <> cabalBuild , "" , "script:" @@ -294,12 +368,15 @@ gitHubFiles Settings{..} = concat cabalUpdate :: Text cabalUpdate = "cabal v2-update" + cabalConfigure :: Text + cabalConfigure = "cabal v2-configure --enable-tests --enable-benchmarks --test-show-details=direct" + cabalBuild :: Text - cabalBuild = "cabal v2-build --enable-tests --enable-benchmarks" + cabalBuild = "cabal v2-build all" cabalTest :: Text cabalTest = if settingsTest - then "cabal v2-test --enable-tests --test-show-details=direct" + then "cabal v2-test all" else "echo 'No tests'" stackBuild :: Text @@ -360,8 +437,9 @@ gitHubFiles Settings{..} = concat , " - cabal %CABOPTS% v2-update" , "" , "build_script:" - , " - cabal %CABOPTS% v2-build --enable-tests" - , " - cabal %CABOPTS% v2-test --enable-tests --test-show-details=direct" + , " - cabal %CABOPTS% v2-configure --enable-tests --enable-benchmarks --test-show-details=direct" + , " - cabal %CABOPTS% v2-build all" + , " - cabal %CABOPTS% v2-test all" ] -- create appveyor.yml template @@ -379,7 +457,7 @@ gitHubFiles Settings{..} = concat , "" , "environment:" , " STACK_ROOT: C:\\sr" - , " STACK_VERSION: 2.1.1" + , " STACK_VERSION: " <> defaultStack , "" , " # Workaround a gnarly bug https://github.com/haskell/cabal/issues/5386" , " # See: https://www.fpcomplete.com/blog/2018/06/sed-a-debugging-story" diff --git a/summoner-cli/test/Test/Golden.hs b/summoner-cli/test/Test/Golden.hs index 81019885..4078d007 100644 --- a/summoner-cli/test/Test/Golden.hs +++ b/summoner-cli/test/Test/Golden.hs @@ -136,7 +136,7 @@ stackFull = Settings , settingsLicenseName = BSD3 , settingsLicenseText = bsd3License , settingsGitHub = True - , settingsGhActions = False + , settingsGhActions = True , settingsPrivate = False , settingsTravis = True , settingsAppVeyor = True