Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ jobs:
run: |
cd tests

# The two macOS runners share a home, and two stack builds recaching one snapshot's
# package db deadlock against each other.
export STACK_ROOT="$HOME/.stack-$RUNNER_NAME"
export NIX_PATH=nixpkgs=$(nix run .#nixpkgsPath)

export PATH=$(nix build --no-link .#stack --json | jq -r '.[0].outputs.out')/bin:$PATH
Expand All @@ -164,10 +167,15 @@ jobs:
echo "Got TEST_ROOT: $TEST_ROOT"
echo TEST_ROOT="$TEST_ROOT" >> $GITHUB_ENV

# The two macOS runners share a home, and two stack builds recaching one snapshot's
# package db deadlock against each other.
export STACK_ROOT="$HOME/.stack-$RUNNER_NAME"
export NIX_PATH=nixpkgs=$(nix run .#nixpkgsPath)
export PATH=$(nix build --no-link .#stack --json | jq -r '.[0].outputs.out')/bin:$PATH
export PATH=$(nix build --no-link .#direnv --json | jq -r '.[0].outputs.out')/bin:$PATH

stack run --nix --no-nix-pure -- \
direnv allow
direnv exec . stack run --nix --no-nix-pure -- \
--print \
--fixed-root "$TEST_ROOT" \
--markdown-summary "$GITHUB_STEP_SUMMARY" \
Expand Down
18 changes: 4 additions & 14 deletions tests/app/Spec/Tests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

module Spec.Tests where

import Control.Concurrent.QSem
import Control.Monad
import Control.Monad.Catch
import Control.Monad.IO.Class
Expand All @@ -28,13 +27,11 @@ tests =
introduceJupyterRunner $
introduceJustBubblewrap $
introduceBootstrapNixpkgs $
introduce' (defaultNodeOptions { nodeOptionsCreateFolder = False }) "Introduce parallel semaphore" parallelSemaphore getQSem (const $ return ()) $
withParallelLanesFromArgs getParallelism $
$(getSpecFromFolder $ defaultGetSpecFromFolderOptions {
getSpecCombiner = 'describeParallel
, getSpecIndividualSpecHooks = 'withParallelSemaphore
, getSpecIndividualSpecHooks = 'takeParallelLane
})
where
getQSem = getCommandLineOptions >>= liftIO . newQSem . getParallelism


-- * Parallelism stuff
Expand All @@ -43,19 +40,12 @@ getParallelism :: CommandLineOptions SpecialOptions -> Int
getParallelism = optTestParallelism . optUserOptions

describeParallel :: (
MonadBaseControl IO m, MonadIO m, MonadMask m, HasParallelSemaphore context
MonadBaseControl IO m, MonadIO m, MonadMask m
) => String -> SpecFree context m () -> SpecFree context m ()
describeParallel s = (describe' (defaultNodeOptions { nodeOptionsRecordTime = False
, nodeOptionsVisibilityThreshold = 50 })) s
. (parallel' (defaultNodeOptions { nodeOptionsRecordTime = False
, nodeOptionsVisibilityThreshold = 125
, nodeOptionsCreateFolder = False }))

withParallelSemaphore :: forall context m. (
MonadBaseControl IO m, MonadIO m, MonadMask m, HasParallelSemaphore context
) => FilePath -> SpecFree context m () -> SpecFree context m ()
withParallelSemaphore _ = around' (defaultNodeOptions { nodeOptionsRecordTime = False
, nodeOptionsVisibilityThreshold = 125
, nodeOptionsCreateFolder = False }) "claim semaphore" $ \action -> do
s <- getContext parallelSemaphore
bracket_ (liftIO $ waitQSem s) (liftIO $ signalQSem s) (void action)

6 changes: 4 additions & 2 deletions tests/src/TestLib/TH.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ import UnliftIO.Exception

findGitRoot :: FilePath -> IO (Maybe FilePath)
findGitRoot dir = do
let gitDir = dir </> ".git"
doesDirectoryExist gitDir >>= \case
let gitPath = dir </> ".git"
-- In a worktree or submodule checkout, .git is a file pointing at the real gitdir.
isRoot <- (||) <$> doesDirectoryExist gitPath <*> doesFileExist gitPath
case isRoot of
True -> return (Just dir)
False -> do
let parent = takeDirectory dir
Expand Down
7 changes: 7 additions & 0 deletions tests/stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ nix:
system-ghc: true

extra-deps:
- git: https://github.com/codedownio/sandwich.git
# master branch
commit: 71f7ac9754fe6bf6a6856cb0b774c356bb8ed02d
subdirs:
- sandwich
- sandwich-contexts

- git: https://github.com/codedownio/lsp.git
# upgrade-monads-newest-jan2026 branch
commit: c723f4a4fb99661c76b1356f8a839a0e266b0f32
Expand Down
26 changes: 26 additions & 0 deletions tests/stack.yaml.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,32 @@
# https://docs.haskellstack.org/en/stable/topics/lock_files

packages:
- completed:
commit: 71f7ac9754fe6bf6a6856cb0b774c356bb8ed02d
git: https://github.com/codedownio/sandwich.git
name: sandwich
pantry-tree:
sha256: a025fad1cfe3429e13a06e040846e9c0baee29178750ac2e9911542e83ae315d
size: 7057
subdir: sandwich
version: 0.3.1.0
original:
commit: 71f7ac9754fe6bf6a6856cb0b774c356bb8ed02d
git: https://github.com/codedownio/sandwich.git
subdir: sandwich
- completed:
commit: 71f7ac9754fe6bf6a6856cb0b774c356bb8ed02d
git: https://github.com/codedownio/sandwich.git
name: sandwich-contexts
pantry-tree:
sha256: 40d6a71d61001e81690af04a504a69e4be0a328f413ac239a8c1f3ed19a3bfae
size: 1849
subdir: sandwich-contexts
version: 0.3.0.4
original:
commit: 71f7ac9754fe6bf6a6856cb0b774c356bb8ed02d
git: https://github.com/codedownio/sandwich.git
subdir: sandwich-contexts
- completed:
commit: c723f4a4fb99661c76b1356f8a839a0e266b0f32
git: https://github.com/codedownio/lsp.git
Expand Down