diff --git a/.github/workflows/cabal.yml b/.github/workflows/cabal.yml deleted file mode 100644 index e4189b06..00000000 --- a/.github/workflows/cabal.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: Cabal - -on: ['pull_request', 'push'] - -jobs: - build: - name: Build on ${{ matrix.os }} GHC ${{ matrix.ghc }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest, macOS-latest] - ghc: ["9.4", "9.6", "9.8"] - fail-fast: false - - steps: - - uses: actions/checkout@v2 - - - uses: haskell/actions/setup@v2 - name: Setup Haskell Cabal - with: - ghc-version: ${{ matrix.ghc }} - - - uses: actions/cache@v2 - name: Cache ~/.cabal - with: - path: ~/.cabal - key: "${{ runner.os }}-${{ matrix.ghc }}-v9-${{ hashFiles('stylish-haskell.cabal') }}" - - - name: Build - run: cabal build - id: build - - - name: Test - run: cabal test - diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4f1bb149..11f1421b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,49 +9,34 @@ jobs: strategy: matrix: os: [ubuntu-latest, macOS-latest] - stack: ["2.15.7"] + ghc: ["9.4", "9.6", "9.8"] steps: - - name: Get the version - id: get_version - run: 'echo ::set-output name=version::${GITHUB_REF#refs/tags/}' - - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: haskell-actions/setup@v2 - name: Setup Haskell Stack + id: setup with: - enable-stack: true - stack-version: ${{ matrix.stack }} - stack-no-global: true + ghc-version: ${{ matrix.ghc }} - - uses: actions/cache@v2 - name: Cache ~/.stack + - uses: actions/cache@v3 with: - path: ~/.stack - key: "${{ runner.os }}-v9-${{ hashFiles('stylish-haskell.cabal', 'stack.yaml', 'stack.yaml.lock') }}" - - - name: Add ~/.local/bin to PATH - run: echo "$HOME/.local/bin" >> $GITHUB_PATH + path: ${{ steps.setup.outputs.cabal-store }} + key: ${{ runner.os }}-${{ matrix.ghc }}-v1-${{ hashFiles('*.cabal') }} + restore-keys: | + ${{ runner.os }}-${{ matrix.ghc }}-v1- - - name: Build - run: make build - id: build + - run: make build + - run: make test - - name: Test - run: make test - - - name: Build artifact - if: startsWith(github.ref, 'refs/tags') + - if: startsWith(github.ref, 'refs/tags') && matrix.ghc == '9.6' run: make artifact - env: - PATAT_TAG: ${{ steps.get_version.outputs.version }} - - uses: actions/upload-artifact@v2 - if: startsWith(github.ref, 'refs/tags') + - uses: actions/upload-artifact@v4 + if: startsWith(github.ref, 'refs/tags') && matrix.ghc == '9.6' with: path: artifacts/* - name: artifacts + name: artifacts-${{ runner.os }} release: name: Release @@ -60,41 +45,15 @@ jobs: if: startsWith(github.ref, 'refs/tags') steps: - - name: Get the version - id: get_version - run: 'echo ::set-output name=version::${GITHUB_REF#refs/tags/}' - - uses: actions/download-artifact@v4 with: - name: artifacts - - - name: Display structure of downloaded files - run: ls -R + pattern: artifacts-* - - uses: actions/create-release@v1 - id: create_release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ steps.get_version.outputs.version }} - release_name: ${{ steps.get_version.outputs.version }} - - - name: Upload Linux Asset - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./stylish-haskell-${{ steps.get_version.outputs.version }}-linux-x86_64.tar.gz - asset_name: stylish-haskell-${{ steps.get_version.outputs.version }}-linux-x86_64.tar.gz - asset_content_type: application/gzip + - run: ls -R + - run: 'sha256sum artifacts-*/*' - - name: Upload MacOS Asset - uses: actions/upload-release-asset@v1 + - uses: softprops/action-gh-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./stylish-haskell-${{ steps.get_version.outputs.version }}-darwin-x86_64.zip - asset_name: stylish-haskell-${{ steps.get_version.outputs.version }}-darwin-x86_64.zip - asset_content_type: application/zip + files: 'artifacts-*/stylish-haskell-*' diff --git a/CHANGELOG b/CHANGELOG index f5874e1a..ab34e4da 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,8 @@ # CHANGELOG +- UNRELEASED + * Bump `Cabal` lower bound to 3.14 + - 0.14.6.0 (2024-01-19) * #471 Support GHC 9.8 (by Michael Peyton Jones) * #440 Fix dissappearing `DEPRECATED` pragma on module (by Lev Dvorkin) diff --git a/Makefile b/Makefile index bd77d0bf..065a2374 100644 --- a/Makefile +++ b/Makefile @@ -27,8 +27,6 @@ COMPRESS_BIN_DEPS=$(UPX_BINARY) COMPRESS_BIN=upx endif -STACK=stack - # Default target. .PHONY: build build: $(STYLISH_BINARY) @@ -49,7 +47,7 @@ $(STYLISH_PACKAGE).$(ARCHIVE): $(STYLISH_BINARY) $(COMPRESS_BIN_DEPS) $(ARCHIVE_CREATE) $(STYLISH_PACKAGE).$(ARCHIVE) $(STYLISH_PACKAGE) $(STYLISH_BINARY): - $(STACK) build --copy-bins + cabal install --installdir="$(dir $(STYLISH_BINARY))" # UPX is used to compress the resulting binary. We currently don't use this on # Mac OS. @@ -62,4 +60,4 @@ $(UPX_BINARY): .PHONY: test test: - stack build --test + cabal test diff --git a/lib/Language/Haskell/Stylish/Config/Cabal.hs b/lib/Language/Haskell/Stylish/Config/Cabal.hs index fdd97b52..4ca2b8b8 100644 --- a/lib/Language/Haskell/Stylish/Config/Cabal.hs +++ b/lib/Language/Haskell/Stylish/Config/Cabal.hs @@ -7,7 +7,6 @@ module Language.Haskell.Stylish.Config.Cabal -------------------------------------------------------------------------------- import Control.Monad (unless) import qualified Data.ByteString.Char8 as BS -import Data.Either (isRight) import Data.Foldable (traverse_) import Data.List (nub) import Data.Maybe (maybeToList) @@ -15,6 +14,7 @@ import qualified Distribution.PackageDescription as Cabal import qualified Distribution.PackageDescription.Parsec as Cabal import qualified Distribution.Parsec as Cabal import qualified Distribution.Simple.Utils as Cabal +import qualified Distribution.Utils.Path as Cabal import qualified Distribution.Verbosity as Cabal import qualified Language.Haskell.Extension as Language import Language.Haskell.Stylish.Verbose @@ -23,8 +23,8 @@ import System.Directory (doesFileExist, -------------------------------------------------------------------------------- +import GHC.Data.Maybe (mapMaybe) import Language.Haskell.Stylish.Config.Internal -import GHC.Data.Maybe (mapMaybe) -------------------------------------------------------------------------------- @@ -36,18 +36,25 @@ findLanguageExtensions verbose = -------------------------------------------------------------------------------- -- | Find the closest .cabal file, possibly going up the directory structure. +-- TODO: use ConfigSearchStrategy here, too findCabalFile :: Verbose -> IO (Maybe FilePath) findCabalFile verbose = do - potentialProjectRoots <- ancestors <$> getCurrentDirectory - potentialCabalFile <- filter isRight <$> - traverse Cabal.findPackageDesc potentialProjectRoots - case potentialCabalFile of - [Right cabalFile] -> return (Just cabalFile) - _ -> do - verbose $ ".cabal file not found, directories searched: " <> - show potentialProjectRoots - verbose $ "Stylish Haskell will work basing on LANGUAGE pragmas in source files." - return Nothing + cwd <- getCurrentDirectory + go [] $ ancestors cwd + where + go :: [FilePath] -> [FilePath] -> IO (Maybe FilePath) + go searched [] = do + verbose $ ".cabal file not found, directories searched: " <> + show searched + verbose $ "Stylish Haskell will work basing on LANGUAGE pragmas in source files." + return Nothing + go searched (p : ps) = do + let projectRoot = Just $ Cabal.makeSymbolicPath p + potentialCabalFile <- Cabal.findPackageDesc projectRoot + case potentialCabalFile of + Right cabalFile -> pure $ Just $ + Cabal.interpretSymbolicPath projectRoot cabalFile + _ -> go (p : searched) ps -------------------------------------------------------------------------------- diff --git a/stack.yaml b/stack.yaml deleted file mode 100644 index 9df11098..00000000 --- a/stack.yaml +++ /dev/null @@ -1,11 +0,0 @@ -resolver: nightly-2024-01-05 - -extra-deps: - - ghc-lib-parser-9.8.1.20231121 - - ghc-lib-parser-ex-9.8.0.0 - - test-framework-0.8.2.0 - - test-framework-hunit-0.3.0.2 - - ansi-wl-pprint-0.6.9 - -save-hackage-creds: false -compiler: ghc-9.8.1 diff --git a/stack.yaml.lock b/stack.yaml.lock deleted file mode 100644 index a2331573..00000000 --- a/stack.yaml.lock +++ /dev/null @@ -1,47 +0,0 @@ -# This file was autogenerated by Stack. -# You should not edit this file by hand. -# For more information, please see the documentation at: -# https://docs.haskellstack.org/en/stable/lock_files - -packages: -- completed: - hackage: ghc-lib-parser-9.6.2.20230523@sha256:160fc11671ce69e756d67f42a75c564863f59b81782a3d23efc27a845d61041b,15694 - pantry-tree: - sha256: 99328c298629fa921985d3de081354625463b659ca7122a1971e548d7051c68a - size: 33893 - original: - hackage: ghc-lib-parser-9.6.2.20230523 -- completed: - hackage: ghc-lib-parser-ex-9.6.0.0@sha256:52e6ffb031669183ebfcff373a5cf0d89eb7621151d3822d80b5a2cce9123871,3493 - pantry-tree: - sha256: 46525028b1594a7e3464620bb72158a64d181c556796855907c4e26b6bacf20d - size: 1955 - original: - hackage: ghc-lib-parser-ex-9.6.0.0 -- completed: - hackage: test-framework-0.8.2.0@sha256:d62395d54bb2a0e2fe2dacd55f55678bc87a769103cca6295ead59720f92158f,6550 - pantry-tree: - sha256: 3977a161a7105e8b4d5685df546eb00960c660afc5a0d295794e47d33c52222d - size: 2050 - original: - hackage: test-framework-0.8.2.0 -- completed: - hackage: test-framework-hunit-0.3.0.2@sha256:7fd007e9cb082cd64a2213a6d36acf057f7d6df6b5343a088e81b2b3a9a23545,1487 - pantry-tree: - sha256: 355897b03e0320296f207350f8c8aba4071b673021aef726bac27e3ad0bbb2cc - size: 239 - original: - hackage: test-framework-hunit-0.3.0.2 -- completed: - hackage: ansi-wl-pprint-0.6.9@sha256:fb737bc96e2aef34ad595d54ced7a73f648c521ebcb00fe0679aff45ccd49212,2448 - pantry-tree: - sha256: ebb02b32915c04146b193949c3c48d9e8200c152f38947e8d23ca25b0997e188 - size: 472 - original: - hackage: ansi-wl-pprint-0.6.9 -snapshots: -- completed: - sha256: f040c40c0c7bceb931bb2fd36361e2580a2a78dabee350f18d0af32e2e7182c6 - size: 504175 - url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/nightly/2023/6/23.yaml - original: nightly-2023-06-23 diff --git a/stylish-haskell.cabal b/stylish-haskell.cabal index f5fa5ff2..0edd396b 100644 --- a/stylish-haskell.cabal +++ b/stylish-haskell.cabal @@ -37,7 +37,7 @@ Common depends aeson >= 0.6 && < 2.3, base >= 4.8 && < 5, bytestring >= 0.9 && < 0.13, - Cabal >= 3.4 && < 4.0, + Cabal >= 3.14 && < 4.0, containers >= 0.3 && < 0.7, directory >= 1.2.3 && < 1.4, filepath >= 1.1 && < 1.5,