Skip to content

Commit

Permalink
Add INTEGRATION_TEST_DIRECTORY environment to support creating test-o…
Browse files Browse the repository at this point in the history
…utput artifact in CI
  • Loading branch information
paolino committed Apr 23, 2024
1 parent 2e7d592 commit b2df380
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
10 changes: 8 additions & 2 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ steps:
- label: "Babbage integration tests (linux)"
key: linux-tests-integration-babbage
depends_on: linux-nix
command: nix shell 'nixpkgs#just' -c just babbage-integration-tests
command: |
INTEGRATION_TEST_DIRECTORY=./babbage-integration-tests-output nix shell 'nixpkgs#just' -c just babbage-integration-tests
artifact_paths:
- ./babbage-integration-tests-output/**
agents:
system: ${linux}
env:
Expand All @@ -67,7 +70,10 @@ steps:
- label: "Conway integration tests (linux)"
key: linux-tests-integration-conway
depends_on: linux-nix
command: nix shell 'nixpkgs#just' -c just conway-integration-tests
command: |
INTEGRATION_TEST_DIRECTORY=./conway-integration-tests-output nix shell 'nixpkgs#just' -c just conway-integration-tests
artifact_paths:
- ./conway-integration-tests-output/**
agents:
system: ${linux}
env:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,5 @@ test-output

## Membench uncompressed data
lib/wallet-benchmarks/data/membench-snapshot
babbage-integration-tests-output/test.log
babbage-integration-tests-output/wallet.log
27 changes: 22 additions & 5 deletions lib/integration/framework/Test/Integration/Framework/Setup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ import Cardano.Wallet.Launch.Cluster.Env
)
import Cardano.Wallet.Launch.Cluster.FileOf
( DirOf (..)
, absolutize
, mkRelDirOf
, toFilePath
)
Expand Down Expand Up @@ -162,7 +163,8 @@ import System.Directory
( createDirectory
)
import System.Environment
( setEnv
( lookupEnv
, setEnv
)
import System.Environment.Extended
( envFromText
Expand All @@ -177,10 +179,14 @@ import System.IO.Temp.Extra
)
import System.Path
( absDir
, absRel
, relDir
, relFile
, (</>)
)
import System.Path.Directory
( createDirectoryIfMissing
)
import Test.Integration.Framework.Cluster.Launch
( withLocalCluster
)
Expand Down Expand Up @@ -241,14 +247,25 @@ withTestsSetup action = do
-- Flush test output as soon as a line is printed.
-- Set UTF-8, regardless of user locale.

-- possibly retrieve a directory from the environment
-- where to report test logs, and modified configuration files
testDataDir <- do
mDir <- lookupEnv "INTEGRATION_TEST_DIRECTORY"
traverse (fmap DirOf . absolutize . absRel) mDir
withUtf8
$
-- This temporary directory will contain logs, and all other data
-- produced by the integration tests.
withSystemTempDir stdoutTextTracer "test" skipCleanup
$ \testDir -> do
let clusterDir = DirOf $ absDir testDir
withTracers clusterDir $ action clusterDir
let run = withTracers <*> action
in case
testDataDir of
Nothing ->
withSystemTempDir stdoutTextTracer "test" skipCleanup
$ run . DirOf . absDir
Just dir -> do
createDirectoryIfMissing True $ absDirOf dir
run dir
-- do not cleanup the directory if it was provided by the user

mkFaucetFunds :: Cluster.TestnetMagic -> FaucetM FaucetFunds
mkFaucetFunds testnetMagic = do
Expand Down

0 comments on commit b2df380

Please sign in to comment.