From 7fdcbebf4960ab8801e56fe610f698407fc47e2b Mon Sep 17 00:00:00 2001 From: Kazu Yamamoto Date: Wed, 15 Mar 2023 09:51:40 +0900 Subject: [PATCH 1/3] using doctest on CI --- Data/IP/RouteTable/Internal.hs | 3 +++ iproute.cabal | 13 ------------- test/doctests.hs | 11 ----------- 3 files changed, 3 insertions(+), 24 deletions(-) delete mode 100644 test/doctests.hs diff --git a/Data/IP/RouteTable/Internal.hs b/Data/IP/RouteTable/Internal.hs index 106a62a..dbb7924 100644 --- a/Data/IP/RouteTable/Internal.hs +++ b/Data/IP/RouteTable/Internal.hs @@ -27,6 +27,9 @@ import Data.Word import GHC.Generics (Generic, Generic1) import Prelude hiding (lookup) +-- $setup +-- >>> :set -XOverloadedStrings + ---------------------------------------------------------------- {-| diff --git a/iproute.cabal b/iproute.cabal index e97d9bd..2e52b27 100644 --- a/iproute.cabal +++ b/iproute.cabal @@ -45,19 +45,6 @@ Library if impl(ghc >= 8) Default-Extensions: Strict StrictData -Test-Suite doctest - Type: exitcode-stdio-1.0 - Default-Language: Haskell2010 - HS-Source-Dirs: test - Ghc-Options: -threaded -Wall - Main-Is: doctests.hs - Build-Depends: base >= 4.6 && < 5 - , doctest >= 0.9.3 - , appar - , byteorder - , bytestring - , network - Test-Suite spec Type: exitcode-stdio-1.0 Default-Language: Haskell2010 diff --git a/test/doctests.hs b/test/doctests.hs deleted file mode 100644 index 303ef6a..0000000 --- a/test/doctests.hs +++ /dev/null @@ -1,11 +0,0 @@ -module Main where - -import Test.DocTest - -main :: IO () -main = doctest [ "-XOverloadedStrings" - , "-package=appar" - , "-package=byteorder" - , "-package=network" - , "Data/IP.hs" - , "Data/IP/RouteTable.hs"] From aefe397eeff7e80a623c3eb4b2c200f437cefbaf Mon Sep 17 00:00:00 2001 From: Kazu Yamamoto Date: Wed, 15 Mar 2023 10:06:49 +0900 Subject: [PATCH 2/3] updating github actions --- .github/workflows/main.yml | 71 +++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 36 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6c6f648..1b04354 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,55 +1,54 @@ name: Haskell CI + on: push: - branches: - - master - pull_request: {} + branches: [ 'master', 'ci' ] + pull_request: + branches: [ 'master' ] jobs: build: runs-on: ${{ matrix.os }} + strategy: fail-fast: false matrix: - os: [ubuntu-latest, macOS-latest, windows-latest] - ghc: ['8.0', '8.2', '8.4', '8.6', '8.8', '8.10'] - exclude: - - os: windows-latest - ghc: "8.0" - - os: windows-latest - ghc: "8.2" - - os: windows-latest - ghc: "8.4" + os: [ 'ubuntu-latest', 'macOS-latest', 'windows-latest' ] + ghc: [ '8.10', '9.0', '9.2' ] + steps: - uses: actions/checkout@v3 + - uses: haskell/actions/setup@v2 - id: setup-haskell-cabal with: ghc-version: ${{ matrix.ghc }} - cabal-version: '3.2' - - name: Update cabal package database - run: | - cabal update - cabal freeze - - uses: actions/cache@v3 - name: Cache cabal stuff + cabal-version: '3.8' + + - name: Cache + uses: actions/cache@v3 + env: + cache-name: cache-cabal with: - path: | - ${{ steps.setup-haskell-cabal.outputs.cabal-store }} - dist-newstyle - key: cache-${{ matrix.os }}-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze') }} + path: ~/.cabal + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/*.cabal') }}-${{ hashFiles('**/cabal.project') }} restore-keys: | - cache-${{ matrix.os }}-${{ matrix.ghc }}- - - name: Build - run: | - cabal install hspec-discover - cabal build --disable-tests --disable-benchmarks all - - name: Test - run: | - cabal test - - name: Haddock + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + + - name: Install dependencies run: | - cabal haddock - - name: SDist + cabal update + cabal build --only-dependencies --enable-tests --disable-benchmarks + + - name: Build + run: cabal build --enable-tests --disable-benchmarks all + + - name: Run tests + run: cabal test --test-show-details=streaming + + - name: Run doctest + if: ${{ runner.os == 'Linux' }} run: | - cabal sdist all + cabal install doctest --overwrite-policy=always + cabal repl --build-depends=QuickCheck --with-ghc=doctest From cca79e76e653d1a7d31dbe0b126b75b7f45686cc Mon Sep 17 00:00:00 2001 From: Kazu Yamamoto Date: Wed, 15 Mar 2023 10:16:15 +0900 Subject: [PATCH 3/3] cabal format + hspec-discover --- iproute.cabal | 149 +++++++++++++++++++++++++++----------------------- 1 file changed, 80 insertions(+), 69 deletions(-) diff --git a/iproute.cabal b/iproute.cabal index 2e52b27..f8caf63 100644 --- a/iproute.cabal +++ b/iproute.cabal @@ -1,72 +1,83 @@ -Name: iproute -Version: 1.7.12 -Author: Kazu Yamamoto -Maintainer: Kazu Yamamoto -License: BSD3 -License-File: LICENSE -Homepage: http://www.mew.org/~kazu/proj/iproute/ -Synopsis: IP Routing Table -Description: IP Routing Table is a tree of IP ranges - to search one of them on the longest - match base. It is a kind of TRIE with one - way branching removed. Both IPv4 and IPv6 - are supported. -Category: Algorithms, Network -Cabal-Version: >= 1.10 -Build-Type: Simple -Tested-With: GHC == 7.8.4 - , GHC == 7.10.3 - , GHC == 8.0.2 - , GHC == 8.2.2 - , GHC == 8.4.4 - , GHC == 8.6.5 - , GHC == 8.8.2 +cabal-version: >=1.10 +name: iproute +version: 1.7.12 +license: BSD3 +license-file: LICENSE +maintainer: Kazu Yamamoto +author: Kazu Yamamoto +tested-with: + ghc ==7.8.4 ghc ==7.10.3 ghc ==8.0.2 ghc ==8.2.2 ghc ==8.4.4 + ghc ==8.6.5 ghc ==8.8.2 -Library - Default-Language: Haskell2010 - GHC-Options: -Wall - Exposed-Modules: Data.IP - Data.IP.Builder - Data.IP.Internal - Data.IP.RouteTable - Data.IP.RouteTable.Internal - Other-Modules: Data.IP.Addr - Data.IP.Mask - Data.IP.Op - Data.IP.Range - Build-Depends: base >= 4.9 && < 5 - , appar - , byteorder - , bytestring - , containers - , network - if impl(ghc < 8.0) - Build-Depends: semigroups >= 0.17 - if impl(ghc >= 8) - Default-Extensions: Strict StrictData +homepage: http://www.mew.org/~kazu/proj/iproute/ +synopsis: IP Routing Table +description: + IP Routing Table is a tree of IP ranges + to search one of them on the longest + match base. It is a kind of TRIE with one + way branching removed. Both IPv4 and IPv6 + are supported. -Test-Suite spec - Type: exitcode-stdio-1.0 - Default-Language: Haskell2010 - Hs-Source-Dirs: test - Ghc-Options: -Wall - Main-Is: Spec.hs - Other-Modules: RouteTableSpec - , BuilderSpec - , IPSpec - Build-Depends: base >= 4.6 && < 5 - , hspec - , QuickCheck - , appar - , byteorder - , bytestring - , containers - , network - , safe - , iproute - if impl(ghc < 8.0) - Build-Depends: semigroups >= 0.17 +category: Algorithms, Network +build-type: Simple -Source-Repository head - Type: git - Location: git://github.com/kazu-yamamoto/iproute.git +source-repository head + type: git + location: git://github.com/kazu-yamamoto/iproute.git + +library + exposed-modules: + Data.IP + Data.IP.Builder + Data.IP.Internal + Data.IP.RouteTable + Data.IP.RouteTable.Internal + + other-modules: + Data.IP.Addr + Data.IP.Mask + Data.IP.Op + Data.IP.Range + + default-language: Haskell2010 + ghc-options: -Wall + build-depends: + base >=4.9 && <5, + appar, + byteorder, + bytestring, + containers, + network + + if impl(ghc <8.0) + build-depends: semigroups >=0.17 + + if impl(ghc >=8) + default-extensions: Strict StrictData + +test-suite spec + type: exitcode-stdio-1.0 + main-is: Spec.hs + build-tool-depends: hspec-discover:hspec-discover + hs-source-dirs: test + other-modules: + RouteTableSpec + BuilderSpec + IPSpec + + default-language: Haskell2010 + ghc-options: -Wall + build-depends: + base >=4.6 && <5, + hspec, + QuickCheck, + appar, + byteorder, + bytestring, + containers, + network, + safe, + iproute + + if impl(ghc <8.0) + build-depends: semigroups >=0.17