Skip to content

Commit cdff43e

Browse files
authored
Fix CI/CD
Bump Cabal dependency lower bound to 3.14
1 parent 12c9118 commit cdff43e

File tree

8 files changed

+45
-171
lines changed

8 files changed

+45
-171
lines changed

.github/workflows/cabal.yml

-35
This file was deleted.

.github/workflows/ci.yml

+20-61
Original file line numberDiff line numberDiff line change
@@ -9,49 +9,34 @@ jobs:
99
strategy:
1010
matrix:
1111
os: [ubuntu-latest, macOS-latest]
12-
stack: ["2.15.7"]
12+
ghc: ["9.4", "9.6", "9.8"]
1313

1414
steps:
15-
- name: Get the version
16-
id: get_version
17-
run: 'echo ::set-output name=version::${GITHUB_REF#refs/tags/}'
18-
19-
- uses: actions/checkout@v2
15+
- uses: actions/checkout@v4
2016

2117
- uses: haskell-actions/setup@v2
22-
name: Setup Haskell Stack
18+
id: setup
2319
with:
24-
enable-stack: true
25-
stack-version: ${{ matrix.stack }}
26-
stack-no-global: true
20+
ghc-version: ${{ matrix.ghc }}
2721

28-
- uses: actions/cache@v2
29-
name: Cache ~/.stack
22+
- uses: actions/cache@v3
3023
with:
31-
path: ~/.stack
32-
key: "${{ runner.os }}-v9-${{ hashFiles('stylish-haskell.cabal', 'stack.yaml', 'stack.yaml.lock') }}"
33-
34-
- name: Add ~/.local/bin to PATH
35-
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
24+
path: ${{ steps.setup.outputs.cabal-store }}
25+
key: ${{ runner.os }}-${{ matrix.ghc }}-v1-${{ hashFiles('*.cabal') }}
26+
restore-keys: |
27+
${{ runner.os }}-${{ matrix.ghc }}-v1-
3628
37-
- name: Build
38-
run: make build
39-
id: build
29+
- run: make build
30+
- run: make test
4031

41-
- name: Test
42-
run: make test
43-
44-
- name: Build artifact
45-
if: startsWith(github.ref, 'refs/tags')
32+
- if: startsWith(github.ref, 'refs/tags') && matrix.ghc == '9.6'
4633
run: make artifact
47-
env:
48-
PATAT_TAG: ${{ steps.get_version.outputs.version }}
4934

50-
- uses: actions/upload-artifact@v2
51-
if: startsWith(github.ref, 'refs/tags')
35+
- uses: actions/upload-artifact@v4
36+
if: startsWith(github.ref, 'refs/tags') && matrix.ghc == '9.6'
5237
with:
5338
path: artifacts/*
54-
name: artifacts
39+
name: artifacts-${{ runner.os }}
5540

5641
release:
5742
name: Release
@@ -60,41 +45,15 @@ jobs:
6045
if: startsWith(github.ref, 'refs/tags')
6146

6247
steps:
63-
- name: Get the version
64-
id: get_version
65-
run: 'echo ::set-output name=version::${GITHUB_REF#refs/tags/}'
66-
6748
- uses: actions/download-artifact@v4
6849
with:
69-
name: artifacts
70-
71-
- name: Display structure of downloaded files
72-
run: ls -R
50+
pattern: artifacts-*
7351

74-
- uses: actions/create-release@v1
75-
id: create_release
76-
env:
77-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
78-
with:
79-
tag_name: ${{ steps.get_version.outputs.version }}
80-
release_name: ${{ steps.get_version.outputs.version }}
81-
82-
- name: Upload Linux Asset
83-
uses: actions/upload-release-asset@v1
84-
env:
85-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
86-
with:
87-
upload_url: ${{ steps.create_release.outputs.upload_url }}
88-
asset_path: ./stylish-haskell-${{ steps.get_version.outputs.version }}-linux-x86_64.tar.gz
89-
asset_name: stylish-haskell-${{ steps.get_version.outputs.version }}-linux-x86_64.tar.gz
90-
asset_content_type: application/gzip
52+
- run: ls -R
53+
- run: 'sha256sum artifacts-*/*'
9154

92-
- name: Upload MacOS Asset
93-
uses: actions/upload-release-asset@v1
55+
- uses: softprops/action-gh-release@v1
9456
env:
9557
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9658
with:
97-
upload_url: ${{ steps.create_release.outputs.upload_url }}
98-
asset_path: ./stylish-haskell-${{ steps.get_version.outputs.version }}-darwin-x86_64.zip
99-
asset_name: stylish-haskell-${{ steps.get_version.outputs.version }}-darwin-x86_64.zip
100-
asset_content_type: application/zip
59+
files: 'artifacts-*/stylish-haskell-*'

CHANGELOG

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# CHANGELOG
22

3+
- UNRELEASED
4+
* Bump `Cabal` lower bound to 3.14
5+
36
- 0.14.6.0 (2024-01-19)
47
* #471 Support GHC 9.8 (by Michael Peyton Jones)
58
* #440 Fix dissappearing `DEPRECATED` pragma on module (by Lev Dvorkin)

Makefile

+2-4
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ COMPRESS_BIN_DEPS=$(UPX_BINARY)
2727
COMPRESS_BIN=upx
2828
endif
2929

30-
STACK=stack
31-
3230
# Default target.
3331
.PHONY: build
3432
build: $(STYLISH_BINARY)
@@ -49,7 +47,7 @@ $(STYLISH_PACKAGE).$(ARCHIVE): $(STYLISH_BINARY) $(COMPRESS_BIN_DEPS)
4947
$(ARCHIVE_CREATE) $(STYLISH_PACKAGE).$(ARCHIVE) $(STYLISH_PACKAGE)
5048

5149
$(STYLISH_BINARY):
52-
$(STACK) build --copy-bins
50+
cabal install --installdir="$(dir $(STYLISH_BINARY))"
5351

5452
# UPX is used to compress the resulting binary. We currently don't use this on
5553
# Mac OS.
@@ -62,4 +60,4 @@ $(UPX_BINARY):
6260

6361
.PHONY: test
6462
test:
65-
stack build --test
63+
cabal test

lib/Language/Haskell/Stylish/Config/Cabal.hs

+19-12
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ module Language.Haskell.Stylish.Config.Cabal
77
--------------------------------------------------------------------------------
88
import Control.Monad (unless)
99
import qualified Data.ByteString.Char8 as BS
10-
import Data.Either (isRight)
1110
import Data.Foldable (traverse_)
1211
import Data.List (nub)
1312
import Data.Maybe (maybeToList)
1413
import qualified Distribution.PackageDescription as Cabal
1514
import qualified Distribution.PackageDescription.Parsec as Cabal
1615
import qualified Distribution.Parsec as Cabal
1716
import qualified Distribution.Simple.Utils as Cabal
17+
import qualified Distribution.Utils.Path as Cabal
1818
import qualified Distribution.Verbosity as Cabal
1919
import qualified Language.Haskell.Extension as Language
2020
import Language.Haskell.Stylish.Verbose
@@ -23,8 +23,8 @@ import System.Directory (doesFileExist,
2323

2424

2525
--------------------------------------------------------------------------------
26+
import GHC.Data.Maybe (mapMaybe)
2627
import Language.Haskell.Stylish.Config.Internal
27-
import GHC.Data.Maybe (mapMaybe)
2828

2929

3030
--------------------------------------------------------------------------------
@@ -36,18 +36,25 @@ findLanguageExtensions verbose =
3636

3737
--------------------------------------------------------------------------------
3838
-- | Find the closest .cabal file, possibly going up the directory structure.
39+
-- TODO: use ConfigSearchStrategy here, too
3940
findCabalFile :: Verbose -> IO (Maybe FilePath)
4041
findCabalFile verbose = do
41-
potentialProjectRoots <- ancestors <$> getCurrentDirectory
42-
potentialCabalFile <- filter isRight <$>
43-
traverse Cabal.findPackageDesc potentialProjectRoots
44-
case potentialCabalFile of
45-
[Right cabalFile] -> return (Just cabalFile)
46-
_ -> do
47-
verbose $ ".cabal file not found, directories searched: " <>
48-
show potentialProjectRoots
49-
verbose $ "Stylish Haskell will work basing on LANGUAGE pragmas in source files."
50-
return Nothing
42+
cwd <- getCurrentDirectory
43+
go [] $ ancestors cwd
44+
where
45+
go :: [FilePath] -> [FilePath] -> IO (Maybe FilePath)
46+
go searched [] = do
47+
verbose $ ".cabal file not found, directories searched: " <>
48+
show searched
49+
verbose $ "Stylish Haskell will work basing on LANGUAGE pragmas in source files."
50+
return Nothing
51+
go searched (p : ps) = do
52+
let projectRoot = Just $ Cabal.makeSymbolicPath p
53+
potentialCabalFile <- Cabal.findPackageDesc projectRoot
54+
case potentialCabalFile of
55+
Right cabalFile -> pure $ Just $
56+
Cabal.interpretSymbolicPath projectRoot cabalFile
57+
_ -> go (p : searched) ps
5158

5259

5360
--------------------------------------------------------------------------------

stack.yaml

-11
This file was deleted.

stack.yaml.lock

-47
This file was deleted.

stylish-haskell.cabal

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Common depends
3737
aeson >= 0.6 && < 2.3,
3838
base >= 4.8 && < 5,
3939
bytestring >= 0.9 && < 0.13,
40-
Cabal >= 3.4 && < 4.0,
40+
Cabal >= 3.14 && < 4.0,
4141
containers >= 0.3 && < 0.7,
4242
directory >= 1.2.3 && < 1.4,
4343
filepath >= 1.1 && < 1.5,

0 commit comments

Comments
 (0)