diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..b652b5a --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,111 @@ + +name: CI + +# Trigger the workflow on push or pull request, but only for the main branch +on: + pull_request: + push: + branches: [master] + +jobs: + cabal: + name: ${{ matrix.os }} / ghc ${{ matrix.ghc }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macOS-latest, windows-latest] + cabal: ["3.2"] + ghc: + - "8.6.5" + - "8.8.4" + - "8.10.2" + # exclude: + # - os: macOS-latest + # ghc: 8.8.4 + # - os: macOS-latest + # ghc: 8.6.5 + # - os: windows-latest + # ghc: 8.10.2 + # - os: windows-latest + # ghc: 8.6.5 + + steps: + - uses: actions/checkout@v2 + if: github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.ref == 'refs/heads/main' + + - uses: actions/setup-haskell@v1.1.4 + id: setup-haskell-cabal + name: Setup Haskell + with: + ghc-version: ${{ matrix.ghc }} + cabal-version: ${{ matrix.cabal }} + + - name: Configure + run: | + cabal configure --enable-tests --enable-benchmarks --test-show-details=direct + + - name: Freeze + run: | + cabal freeze + + - uses: actions/cache@v2.1.3 + name: Cache ~/.cabal/store + with: + path: ${{ steps.setup-haskell-cabal.outputs.cabal-store }} + key: ${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze') }} + + - name: Install dependencies + run: | + cabal build all --only-dependencies + + - name: Build + run: | + cabal build all + + - name: Test + run: | + cabal test path:test + + # - name: Test + # run: | + # cabal test path:validity-test + + stack: + name: stack / ghc ${{ matrix.ghc }} + runs-on: ubuntu-latest + strategy: + matrix: + stack: ["2.3.1"] + ghc: ["8.8.4"] + + steps: + - uses: actions/checkout@v2 + if: github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.ref == 'refs/heads/main' + + - uses: actions/setup-haskell@v1.1.4 + name: Setup Haskell Stack + with: + ghc-version: ${{ matrix.ghc }} + stack-version: ${{ matrix.stack }} + + - uses: actions/cache@v2.1.3 + name: Cache ~/.stack + with: + path: ~/.stack + key: ${{ runner.os }}-${{ matrix.ghc }}-stack + + - name: Install dependencies + run: | + stack build --system-ghc --test --bench --no-run-tests --no-run-benchmarks --only-dependencies + + - name: Build + run: | + stack build --system-ghc --test --bench --no-run-tests --no-run-benchmarks + + - name: Test + run: | + stack test --system-ghc :test + + # - name: Test + # run: | + # stack test --system-ghc :validity-test diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index c511ee9..0000000 --- a/.travis.yml +++ /dev/null @@ -1,57 +0,0 @@ -language: c - -sudo: false - -cache: - directories: - - ~/.cabal/packages - - ~/.cabal/store - - ~/.stack - -addons: - apt: - packages: - - libgmp-dev - -matrix: - include: - - env: TYPE=cabal CABALVER=3.0 GHCVER=8.6.5 - addons: {apt: {packages: [cabal-install-3.0,ghc-8.6.5], sources: [hvr-ghc]}} - - env: CABALVER=3.0 GHCVER=8.8.3 - addons: {apt: {packages: [cabal-install-3.0,ghc-8.8.3], sources: [hvr-ghc]}} - - env: TYPE=cabal CABALVER=3.0 GHCVER=8.10.1 - addons: {apt: {packages: [cabal-install-3.0,ghc-8.10.1], sources: [hvr-ghc]}} - - env: TYPE=stack ARGS="--stack-yaml stack.yaml" - -before_install: - - export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH - -install: - - echo "$(ghc --version) [$(ghc --print-project-git-commit-id 2> /dev/null || echo '?')]" - - mkdir -pv ~/.local/bin - - case "$TYPE" in - cabal) travis_retry cabal new-update ;; - stack) travis_retry curl -L https://www.stackage.org/stack/linux-x86_64 | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack' ;; - esac - -script: - - | - set -ex # Error out after first failure and print each command before executing - case "$TYPE" in - cabal) - cabal new-build --enable-tests --enable-benchmarks --flags=dev - cabal new-test --enable-tests --enable-benchmarks --flags=dev - cabal new-haddock - cabal new-sdist - ;; - stack) - stack --version - stack --no-terminal --install-ghc $ARGS test - ;; - esac - set +ex # Stop printing each command - -notifications: - email: - on_success: never - on_failure: always diff --git a/README.md b/README.md index e8cd3e7..dc13018 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # Path -[![Travis Build Status](https://travis-ci.org/commercialhaskell/path.svg)](https://travis-ci.org/commercialhaskell/path) -[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/commercialhaskell/path?svg=true)](https://ci.appveyor.com/project/chrisdone/path) +![CI](https://github.com/commercialhaskell/path/workflows/CI/badge.svg?branch=master) [![Hackage](https://img.shields.io/hackage/v/path.svg)](https://hackage.haskell.org/package/path) [![Stackage LTS](http://stackage.org/package/path/badge/lts)](http://stackage.org/lts/package/path) [![Stackage Nightly](http://stackage.org/package/path/badge/nightly)](http://stackage.org/nightly/package/path) diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index c5ab1df..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,21 +0,0 @@ -# Disable standard build process with MSBuild -build: off - -# In case of unreliable builds try disabling caching. -cache: -- "c:\\sr" - -clone_folder: "c:\\stack" -environment: - global: - STACK_ROOT: "c:\\sr" - -install: -- curl -sSL -ostack.zip https://get.haskellstack.org/stable/windows-x86_64.zip -- 7z x stack.zip stack.exe - -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 --haddock --no-haddock-deps --bench --test :test diff --git a/path.cabal b/path.cabal index 9eee174..78bff3b 100644 --- a/path.cabal +++ b/path.cabal @@ -10,7 +10,7 @@ copyright: 2015–2018 FP Complete category: System, Filesystem build-type: Simple cabal-version: 1.18 -tested-with: GHC==8.6.5, GHC==8.8.3, GHC==8.10.1 +tested-with: GHC==8.6.5, GHC==8.8.4, GHC==8.10.1 extra-source-files: README.md , CHANGELOG , src/Path/Include.hs @@ -56,7 +56,6 @@ test-suite test , Windows , Common.Posix , Common.Windows - , TH hs-source-dirs: test build-depends: aeson , base >= 4.12 && < 5 diff --git a/test/Common/Include.hs b/test/Common/Include.hs index 023b8d4..64b5969 100644 --- a/test/Common/Include.hs +++ b/test/Common/Include.hs @@ -2,6 +2,8 @@ -- PLATFORM_NAME = Posix | Windows -- IS_WINDOWS = False | True +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE TemplateHaskell #-} -- | Test functions that are common to Posix and Windows @@ -9,10 +11,39 @@ module Common.PLATFORM_NAME (extensionOperations) where import Control.Monad +import qualified Language.Haskell.TH.Syntax as TH +import Path.Internal.PLATFORM_NAME import Path.PLATFORM_NAME import System.FilePath.PLATFORM_NAME (pathSeparator) import Test.Hspec +class Foo a b where + foo :: Path a b -> FilePath + foo = toFilePath + +instance Foo Abs Dir +instance Foo Abs File +instance Foo Rel Dir +instance Foo Rel File + +qqRelDir :: FilePath +qqRelDir = foo [reldir|foo/|] + +qqRelFile :: FilePath +qqRelFile = foo [relfile|foo|] + +thRelDir :: FilePath +thRelDir = foo $(mkRelDir "foo/") + +thRelFile :: FilePath +thRelFile = foo $(mkRelFile "foo") + +liftRelDir :: FilePath +liftRelDir = foo $(TH.lift (Path "foo/" :: Path Rel Dir)) + +liftRelFile :: FilePath +liftRelFile = foo $(TH.lift (Path "foo" :: Path Rel File)) + validExtensionsSpec :: String -> Path b File -> Path b File -> Spec validExtensionsSpec ext file fext = do let f = show $ toFilePath file diff --git a/test/Common/Posix.hs b/test/Common/Posix.hs index 25e35e1..a7217d5 100644 --- a/test/Common/Posix.hs +++ b/test/Common/Posix.hs @@ -1,4 +1,24 @@ {-# LANGUAGE CPP #-} +{-# LANGUAGE QuasiQuotes #-} + #define PLATFORM_NAME Posix #define IS_WINDOWS False #include "Include.hs" + +qqAbsDir :: FilePath +qqAbsDir = foo [absdir|/foo/|] + +qqAbsFile :: FilePath +qqAbsFile = foo [absdir|/foo|] + +thAbsDir :: FilePath +thAbsDir = foo $(mkAbsDir "/foo/") + +thAbsFile :: FilePath +thAbsFile = foo $(mkAbsFile "/foo") + +liftAbsDir :: FilePath +liftAbsDir = foo $(TH.lift (Path "/foo/" :: Path Abs Dir)) + +liftAbsFile :: FilePath +liftAbsFile = foo $(TH.lift (Path "/foo" :: Path Abs File)) diff --git a/test/Common/Windows.hs b/test/Common/Windows.hs index a8b5cbb..2d72f5b 100644 --- a/test/Common/Windows.hs +++ b/test/Common/Windows.hs @@ -1,4 +1,24 @@ {-# LANGUAGE CPP #-} +{-# LANGUAGE QuasiQuotes #-} #define PLATFORM_NAME Windows #define IS_WINDOWS True #include "Include.hs" + +qqAbsDir :: FilePath +qqAbsDir = foo [absdir|C:\foo\|] + +qqAbsFile :: FilePath +qqAbsFile = foo [absdir|C:\foo|] + +thAbsDir :: FilePath +thAbsDir = foo $(mkAbsDir "C:\\foo\\") + +thAbsFile :: FilePath +thAbsFile = foo $(mkAbsFile "C:\\foo") + +liftAbsDir :: FilePath +liftAbsDir = foo $(TH.lift (Path "C:\\foo\\" :: Path Abs Dir)) + +liftAbsFile :: FilePath +liftAbsFile = foo $(TH.lift (Path "C:\\foo" :: Path Abs File)) + diff --git a/test/TH.hs b/test/TH.hs deleted file mode 100644 index 7913913..0000000 --- a/test/TH.hs +++ /dev/null @@ -1,58 +0,0 @@ -{-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE QuasiQuotes #-} -{-# LANGUAGE TemplateHaskell #-} - -module TH where - -import qualified Language.Haskell.TH.Syntax as TH -import Path.Posix -import Path.Internal.Posix - - - -class Foo a b where - foo :: Path a b -> FilePath - foo = toFilePath - -instance Foo Abs Dir -instance Foo Abs File -instance Foo Rel Dir -instance Foo Rel File - - - -qqAbsDir :: FilePath -qqAbsDir = foo [absdir|/foo/|] - -qqAbsFile :: FilePath -qqAbsFile = foo [absfile|/foo|] - -qqRelDir :: FilePath -qqRelDir = foo [reldir|foo/|] - -qqRelFile :: FilePath -qqRelFile = foo [relfile|foo|] - -thAbsDir :: FilePath -thAbsDir = foo $(mkAbsDir "/foo/") - -thAbsFile :: FilePath -thAbsFile = foo $(mkAbsFile "/foo") - -thRelDir :: FilePath -thRelDir = foo $(mkRelDir "foo/") - -thRelFile :: FilePath -thRelFile = foo $(mkRelFile "foo") - -liftAbsDir :: FilePath -liftAbsDir = foo $(TH.lift (Path "/foo/" :: Path Abs Dir)) - -liftAbsFile :: FilePath -liftAbsFile = foo $(TH.lift (Path "/foo" :: Path Abs File)) - -liftRelDir :: FilePath -liftRelDir = foo $(TH.lift (Path "foo/" :: Path Rel Dir)) - -liftRelFile :: FilePath -liftRelFile = foo $(TH.lift (Path "foo" :: Path Rel File))