Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/github_actions/actions/cache-4
Browse files Browse the repository at this point in the history
  • Loading branch information
geekosaur authored Sep 3, 2024
2 parents b50e349 + 39b6924 commit 2a397fe
Show file tree
Hide file tree
Showing 172 changed files with 1,228 additions and 973 deletions.
26 changes: 26 additions & 0 deletions .github/mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,32 @@ pull_request_rules:
- label=merge+no rebase
- '#approved-reviews-by>=2'

# label when Mergify is ready but waiting for the above
- actions:
label:
add:
- ready and waiting
name: Waiting out merge delay (used by bot)
conditions:
- base=master
- -draft
- -closed
- or:
- label=merge me
- label=squash+merge me
- label=merge+no rebase
- '#approved-reviews-by>=2'
- '#changes-requested-reviews-by=0'
# oy
# lifted these from branch protection imports
- check-success=fourmolu
- check-success=hlint
- check-success=Meta checks
- check-success=Doctest Cabal
- check-success=Validate post job
- check-success=Bootstrap post job
- 'check-success=docs/readthedocs.org:cabal'

# rebase+merge strategy
- actions:
queue:
Expand Down
82 changes: 82 additions & 0 deletions .github/workflows/check-sdist.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Check sdist

# See: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#concurrency.
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true

on:
push:
paths-ignore:
- "doc/**"
- "**/README.md"
- "CONTRIBUTING.md"
branches:
- master
pull_request:
paths-ignore:
- "doc/**"
- "**/README.md"
- "CONTRIBUTING.md"
release:
types:
- created

jobs:

# Dogfood the generated sdist, to avoid bugs like https://github.com/haskell/cabal/issues/9833
# No caching, since the point is to verify they can be installed "from scratch"
# Don't run on master or a PR targeting master, because there's never an installable Cabal
dogfood-sdists:
name: Dogfood sdist on ${{ matrix.os }} ghc-${{ matrix.ghc }}
if: github.ref != 'refs/heads/master' && github.base_ref != 'master'
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
# this should be kept up to date with the list in validate.yml, but should be the
# *first* compiler release so we validate against what is hopefully the first
# release of a corresponding Cabal and friends. it can also be short since it's
# highly unlikely that we are releasing really old branches.
ghc:
[
"9.10.1",
"9.8.1",
"9.6.1",
"9.4.1",
]

steps:

- uses: haskell-actions/setup@v2
id: setup-haskell
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: latest

- uses: actions/checkout@v4

- name: Make sdist
run: cabal sdist cabal-install

- name: Install from sdist
run: |
# skip if a suitable Cabal isn't in this ghc's bootlibs, since that's the case
# that causes failures for users (otherwise cabal-install will install a matching
# version itself)
# we only want to test cabal-install, to ensure that it works with existing Cabals
# (don't look at this too closely)
sdist="$(ls dist-newstyle/sdist/cabal-install-*.tar.gz | sed -n '\,^dist-newstyle/sdist/cabal-install-[0-9.]*\.tar\.gz$,{;p;q;}')"
# extract the cabal-install major version
ver="$(echo "$sdist" | sed -n 's,^dist-newstyle/sdist/cabal-install-\([0-9][0-9]*\.[0-9][0-9]*\)\.[0-9.]*$,\1,p')"
# dunno if this will ever be extended to freebsd, but grep -q is a gnu-ism
if ghc-pkg --global --simple-output list Cabal | grep "^Cabal-$cbl\\." >/dev/null; then
# sigh, someone broke installing from tarballs
rm -rf cabal*.project Cabal Cabal-syntax cabal-install-solver cabal-install
tar xfz "$sdist"
cd "cabal-install-$cbl"*
cabal install
else
echo No matching bootlib Cabal version to test against.
exit 0
fi
7 changes: 6 additions & 1 deletion .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ jobs:
outputs:
GHC_FOR_RELEASE: ${{ format('["{0}"]', env.GHC_FOR_RELEASE) }}
strategy:
fail-fast: false
matrix:
sys:
- { os: windows-latest, shell: "C:/msys64/usr/bin/bash.exe -e {0}" }
Expand All @@ -78,6 +79,11 @@ jobs:
"8.8.4",
]
exclude:
# Throws fatal "cabal-tests.exe: fd:8: hGetLine: end of file" exception
# even with --io-manager=native
- sys:
{ os: windows-latest, shell: "C:/msys64/usr/bin/bash.exe -e {0}" }
ghc: "9.0.2"
# corrupts GHA cache or the fabric of reality itself, see https://github.com/haskell/cabal/issues/8356
- sys:
{ os: windows-latest, shell: "C:/msys64/usr/bin/bash.exe -e {0}" }
Expand Down Expand Up @@ -210,7 +216,6 @@ jobs:
run: sh validate.sh $FLAGS -s cli-tests

- name: Validate cli-suite
if: runner.os != 'Windows'
run: sh validate.sh $FLAGS -s cli-suite

- name: Validate solver-benchmarks-tests
Expand Down
5 changes: 3 additions & 2 deletions Cabal-QuickCheck/src/Test/QuickCheck/Instances/Cabal.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE FlexibleInstances #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Test.QuickCheck.Instances.Cabal () where

Expand All @@ -18,7 +19,7 @@ import Distribution.Compat.NonEmptySet (NonEmptySet)
import Distribution.Compiler
import Distribution.FieldGrammar.Newtypes
import Distribution.ModuleName
import Distribution.Simple.Compiler (DebugInfoLevel (..), OptimisationLevel (..), PackageDB (..), ProfDetailLevel (..), knownProfDetailLevels)
import Distribution.Simple.Compiler
import Distribution.Simple.Flag (Flag (..))
import Distribution.Simple.InstallDirs
import Distribution.Simple.Setup (HaddockTarget (..), TestShowDetails (..), DumpBuildInfo)
Expand Down Expand Up @@ -476,7 +477,7 @@ instance Arbitrary TestShowDetails where
-- PackageDB
-------------------------------------------------------------------------------

instance Arbitrary PackageDB where
instance Arbitrary (PackageDBX FilePath) where
arbitrary = oneof [ pure GlobalPackageDB
, pure UserPackageDB
, SpecificPackageDB <$> arbitraryShortPath
Expand Down
54 changes: 43 additions & 11 deletions Cabal-syntax/src/Distribution/Utils/Path.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,17 @@ module Distribution.Utils.Path
, Tix
, Tmp
, Response
, PkgConf

-- * Symbolic paths
, RelativePath
, SymbolicPath
, AbsolutePath (..)
, SymbolicPathX -- NB: constructor not exposed, to retain type safety.

-- ** Symbolic path API
, getSymbolicPath
, getAbsolutePath
, sameDirectory
, makeRelativePathEx
, makeSymbolicPath
Expand All @@ -47,6 +50,7 @@ module Distribution.Utils.Path
, relativeSymbolicPath
, symbolicPathRelative_maybe
, interpretSymbolicPath
, interpretSymbolicPathAbsolute

-- ** General filepath API
, (</>)
Expand All @@ -59,7 +63,7 @@ module Distribution.Utils.Path
-- ** Working directory handling
, interpretSymbolicPathCWD
, absoluteWorkingDir
, tryMakeRelativeToWorkingDir
, tryMakeRelative

-- ** Module names
, moduleNameSymbolicPath
Expand Down Expand Up @@ -214,6 +218,11 @@ type RelativePath = SymbolicPathX 'OnlyRelative
-- until we interpret them (using e.g. 'interpretSymbolicPath').
type SymbolicPath = SymbolicPathX 'AllowAbsolute

newtype AbsolutePath (to :: FileOrDir) = AbsolutePath (forall from. SymbolicPath from to)

unsafeMakeAbsolutePath :: FilePath -> AbsolutePath to
unsafeMakeAbsolutePath fp = AbsolutePath (makeSymbolicPath fp)

instance Binary (SymbolicPathX allowAbsolute from to)
instance
(Typeable allowAbsolute, Typeable from, Typeable to)
Expand Down Expand Up @@ -289,7 +298,7 @@ moduleNameSymbolicPath modNm = SymbolicPath $ ModuleName.toFilePath modNm
-- (because the program might expect certain paths to be relative).
--
-- See Note [Symbolic paths] in Distribution.Utils.Path.
interpretSymbolicPath :: Maybe (SymbolicPath CWD (Dir Pkg)) -> SymbolicPathX allowAbsolute Pkg to -> FilePath
interpretSymbolicPath :: Maybe (SymbolicPath CWD (Dir from)) -> SymbolicPathX allowAbsolute from to -> FilePath
interpretSymbolicPath mbWorkDir (SymbolicPath p) =
-- Note that this properly handles an absolute symbolic path,
-- because if @q@ is absolute, then @p </> q = q@.
Expand All @@ -316,9 +325,15 @@ interpretSymbolicPath mbWorkDir (SymbolicPath p) =
-- appropriate to use 'interpretSymbolicPathCWD' to provide its arguments.
--
-- See Note [Symbolic paths] in Distribution.Utils.Path.
interpretSymbolicPathCWD :: SymbolicPathX allowAbsolute Pkg to -> FilePath
interpretSymbolicPathCWD :: SymbolicPathX allowAbsolute from to -> FilePath
interpretSymbolicPathCWD (SymbolicPath p) = p

getAbsolutePath :: AbsolutePath to -> FilePath
getAbsolutePath (AbsolutePath p) = getSymbolicPath p

interpretSymbolicPathAbsolute :: AbsolutePath (Dir Pkg) -> SymbolicPathX allowAbsolute Pkg to -> FilePath
interpretSymbolicPathAbsolute (AbsolutePath p) sym = interpretSymbolicPath (Just p) sym

-- | Change what a symbolic path is pointing to.
coerceSymbolicPath :: SymbolicPathX allowAbsolute from to1 -> SymbolicPathX allowAbsolute from to2
coerceSymbolicPath = coerce
Expand All @@ -342,17 +357,19 @@ symbolicPathRelative_maybe (SymbolicPath fp) =
else Just $ SymbolicPath fp

-- | Absolute path to the current working directory.
absoluteWorkingDir :: Maybe (SymbolicPath CWD to) -> IO FilePath
absoluteWorkingDir Nothing = Directory.getCurrentDirectory
absoluteWorkingDir (Just wd) = Directory.makeAbsolute $ getSymbolicPath wd
absoluteWorkingDir :: Maybe (SymbolicPath CWD to) -> IO (AbsolutePath to)
absoluteWorkingDir Nothing = unsafeMakeAbsolutePath <$> Directory.getCurrentDirectory
absoluteWorkingDir (Just wd) = unsafeMakeAbsolutePath <$> Directory.makeAbsolute (getSymbolicPath wd)

-- | Try to make a path relative to the current working directory.
-- | Try to make a symbolic path relative.
--
-- This function does nothing if the path is already relative.
--
-- NB: this function may fail to make the path relative.
tryMakeRelativeToWorkingDir :: Maybe (SymbolicPath CWD (Dir dir)) -> SymbolicPath dir to -> IO (SymbolicPath dir to)
tryMakeRelativeToWorkingDir mbWorkDir (SymbolicPath fp) = do
wd <- absoluteWorkingDir mbWorkDir
return $ SymbolicPath (FilePath.makeRelative wd fp)
tryMakeRelative :: Maybe (SymbolicPath CWD (Dir dir)) -> SymbolicPath dir to -> IO (SymbolicPath dir to)
tryMakeRelative mbWorkDir (SymbolicPath fp) = do
AbsolutePath wd <- absoluteWorkingDir mbWorkDir
return $ SymbolicPath (FilePath.makeRelative (getSymbolicPath wd) fp)

-------------------------------------------------------------------------------

Expand Down Expand Up @@ -422,6 +439,16 @@ instance
where
SymbolicPath p1 </> SymbolicPath p2 = SymbolicPath (p1 </> p2)

instance
(b1 ~ 'Dir b2, c2 ~ c3, midAbsolute ~ OnlyRelative)
=> PathLike
(AbsolutePath b1)
(SymbolicPathX midAbsolute b2 c2)
(AbsolutePath c3)
where
AbsolutePath (SymbolicPath p1) </> SymbolicPath p2 =
unsafeMakeAbsolutePath (p1 </> p2)

--------------------------------------------------------------------------------
-- Abstract directory locations.

Expand Down Expand Up @@ -499,3 +526,8 @@ data Tmp
--
-- See Note [Symbolic paths] in Distribution.Utils.Path.
data Response

-- | Abstract directory: directory for pkg-config files.
--
-- See Note [Symbolic paths] in Distribution.Utils.Path.
data PkgConf
23 changes: 19 additions & 4 deletions Cabal-tests/lib/Test/Utils/TempTestDir.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

module Test.Utils.TempTestDir
( withTestDir
, withTestDir'
, removeDirectoryRecursiveHack
) where

import Distribution.Compat.Internal.TempFile (createTempDirectory)
import Distribution.Simple.Utils (warn)
import Distribution.Simple.Utils (warn, TempFileOptions (..), defaultTempFileOptions)
import Distribution.Verbosity

import Control.Concurrent (threadDelay)
Expand All @@ -23,12 +24,26 @@ import qualified System.Info (os)
-- | Much like 'withTemporaryDirectory' but with a number of hacks to make
-- sure on windows that we can clean up the directory at the end.
withTestDir :: (MonadIO m, MonadMask m) => Verbosity -> String -> (FilePath -> m a) -> m a
withTestDir verbosity template action = do
systmpdir <- liftIO getTemporaryDirectory
withTestDir verbosity template action = withTestDir' verbosity defaultTempFileOptions template action

withTestDir' :: (MonadIO m, MonadMask m) => Verbosity -> TempFileOptions -> String -> (FilePath -> m a) -> m a
withTestDir' verbosity tempFileOpts template action = do
systmpdir <-
-- MacOS returns /var/folders/... which is a symlink (/var -> /private/var),
-- so the test-suite struggles to make the build cwd-agnostic in particular
-- for the ShowBuildInfo tests. This canonicalizePath call makes it
-- /private/var/folders/... which will work.
liftIO $ canonicalizePath =<< getTemporaryDirectory
bracket
( do { tmpRelDir <- liftIO $ createTempDirectory systmpdir template
; return $ systmpdir </> tmpRelDir } )
(liftIO . removeDirectoryRecursiveHack verbosity)
(liftIO
-- This ensures that the temp files are not deleted at the end of the test.
-- It replicates the behavior of @withTempDirectoryEx@.
. when (not (optKeepTempFiles tempFileOpts))
-- This is the bit that helps with Windows deleting all files.
. removeDirectoryRecursiveHack verbosity
)
action

-- | On Windows, file locks held by programs we run (in this case VCSs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ md5CheckGenericPackageDescription proxy = md5Check proxy

md5CheckLocalBuildInfo :: Proxy LocalBuildInfo -> Assertion
md5CheckLocalBuildInfo proxy = md5Check proxy
0xb0a61f1d93717a92b2b4ecbe0bc3abd4
0x94827844fdb1afedee525061749fb16f
Loading

0 comments on commit 2a397fe

Please sign in to comment.