Skip to content

BuildReports: Add test report log - #1417

Merged
ysangkok merged 6 commits into
masterfrom
test-report-log
Sep 7, 2026
Merged

BuildReports: Add test report log#1417
ysangkok merged 6 commits into
masterfrom
test-report-log

Conversation

@ysangkok

@ysangkok ysangkok commented Jul 17, 2025

Copy link
Copy Markdown
Member

The test report log contains the actual output emitted by the test-suite
in a given Cabal package.

The test log only contains the logs of the build of the test.

Fixes #1397.

Demo

image

These were the logs as emitted by cabal run exe:hackage-build -- build testpkg -v:

Downloading
http://localhost:8080/package/testpkg-0.4.0.1/testpkg-0.4.0.1.tar.gz
Unpacking to testpkg-0.4.0.1/
Building testpkg-0.4.0.1
cabal
--config-file=/home/janus/flipstone/hackage-server/build-cache/cabal-config
v1-install --enable-documentation
--htmldir=/home/janus/flipstone/hackage-server/build-cache/tmp-install/haddocks/$pkgid-docs
--disable-optimization --ghc-option -O0 --disable-library-for-ghci
--package-db=clear --package-db=global
--package-db=/home/janus/flipstone/hackage-server/build-cache/tmp-install/packages.db
--reinstall --force-reinstalls
--haddock-html-location=/package/$pkg-$version/docs
--haddock-contents-location=/package/$pkg-$version --haddock-hyperlink-source
--prefix=/home/janus/flipstone/hackage-server/build-cache/tmp-install
--build-summary=/home/janus/flipstone/hackage-server/build-cache/tmp-install/reports/$pkgid.report
--report-planning-failure --haddock-html --haddock-hoogle
--haddock-option=--quickjump testpkg-0.4.0.1
Build results for testpkg-0.4.0.1:
/home/janus/flipstone/hackage-server/build-cache/results/testpkg-0.4.0.1.report
/home/janus/flipstone/hackage-server/build-cache/results/testpkg-0.4.0.1-docs.tar.gz
/home/janus/flipstone/hackage-server/build-cache/results/testpkg-0.4.0.1.log
Testing testpkg-0.4.0.1
cabal
--config-file=/home/janus/flipstone/hackage-server/build-cache/cabal-config
v2-test all --enable-coverage
--test-log=/home/janus/flipstone/hackage-server/build-cache/tmp-install/reports/testpkg-0.4.0.1.test
--test-show-details=never --disable-optimization
Test results for testpkg-0.4.0.1:
/home/janus/flipstone/hackage-server/build-cache/results/testpkg-0.4.0.1.test

Cabal file fragment:

test-suite simple
    main-is: Main.hs
    hs-source-dirs: test
    type: exitcode-stdio-1.0
    build-depends: base >=4 && <5
    default-language: Haskell2010

Main.hs (of test-suite) contents:

main = putStrLn "this is printed from custom test suite"

@gbaz

gbaz commented Jul 17, 2025

Copy link
Copy Markdown
Contributor

this looks good to me. @bgamari i think we'll need to deploy the builder and the main hackage in sync for this... when you get time, take a look and then we can coordinate?

@ysangkok

ysangkok commented Aug 6, 2025

Copy link
Copy Markdown
Member Author

I tried testing the migration locally, and I am getting an error with Acid.Core "too few bytes". So there must be some problem with this PR, or maybe it is exposing an existing issue... I will report back if I find out what the problem is. I think I'll try to write a unit test for this.

@ysangkok

ysangkok commented Aug 8, 2025

Copy link
Copy Markdown
Member Author

I've done some migration testsusing the following REPL code:

ghci> :set -XScopedTypeVariables 
ghci> :m +Distribution.Server.Features.BuildReports.BuildReports Data.Acid.Core Data.SafeCopy Data.Map Test.QuickCheck Data.Either
ghci> b :: PkgBuildReports_v4  <- generate arbitrary
ghci> isRight (serialiserDecode safeCopySerialiser (serialiserEncode safeCopySerialiser b) :: Either String PkgBuildReports)
True

I still haven't discovered any issues...

@ysangkok

Copy link
Copy Markdown
Member Author

@gbaz Do you have any ideas for how to advance this? I'd be curious to know if you can reproduce my issue with your local instance.

@sol sol left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I understand --test-show-details=always is a much easier (one line) fix that does not require a data migration.

@sol sol left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I understand --test-show-details=always is a much easier (one line) fix that does not require a data migration.

ysangkok and others added 6 commits September 7, 2026 10:16
The test report log contains the actual output emitted by the test-suite
in a given Cabal package.

The test log only contains the logs of the *build* of the test.
Revert changes to existing events used in makeAcidic.
They need to be kept for compatibility with old data.
@mergify

mergify Bot commented Sep 7, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@ysangkok

ysangkok commented Sep 7, 2026

Copy link
Copy Markdown
Member Author

This approach is superior since it doesn't conflate test build logs with test output logs. I have rebased this and I fixed the issue it had: It was changing the meaning of existing events in State.hs that were used with makeAcidic. I have adjusted the code to instead make a new event. Also a few other fixes.

I will merge this in a few hours after pondering and verifying .

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Backups lose the new logs, and packages with multiple test suites upload only one suite’s output.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds test-suite runtime logs to build reports, separate from test build logs.

Changes:

  • Captures, uploads, stores, and serves test report logs.
  • Adds state migrations and supporting instances.
  • Displays logs in report HTML.
File summaries
File Description
src/Distribution/Server/Framework/ResponseContentTypes.hs Adds plain-text response type.
src/Distribution/Server/Framework/MemSize.hs Supports five-element tuples.
src/Distribution/Server/Framework/BlobStorage.hs Adds Arbitrary support for blob IDs.
src/Distribution/Server/Features/Security/MD5.hs Adds Arbitrary support for MD5 digests.
src/Distribution/Server/Features/Html.hs Renders test report logs.
src/Distribution/Server/Features/BuildReports/State.hs Extends persisted report operations.
src/Distribution/Server/Features/BuildReports/BuildReports.hs Stores logs and migrates existing state.
src/Distribution/Server/Features/BuildReports/BuildReport.hs Extends upload JSON payloads.
src/Distribution/Server/Features/BuildReports/Backup.hs Updates backup tuple handling.
src/Distribution/Server/Features/BuildReports.hs Adds upload, query, and serving integration.
exes/BuildClient.hs Captures and uploads test output.
datafiles/templates/Html/report.html.st Displays test report output and raw link.
Review details
  • Files reviewed: 12/12 changed files
  • Comments generated: 2
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +98 to 99
reportToExport prefix reportId (report, mlog, _, _, _) = BackupByteString (getPath ".txt") (packUTF8 $ Report.show report) :
case mlog of Nothing -> []; Just (BuildLog blobId) -> [blobToBackup (getPath ".log") blobId]

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This follows the existing pattern, you can see other members are already not backed up.

Comment thread exes/BuildClient.hs


testPackage :: Verbosity -> BuildOpts -> DocInfo -> IO (Maybe String, Maybe FilePath, Maybe FilePath)
testPackage :: Verbosity -> BuildOpts -> DocInfo -> IO (Maybe String, Maybe FilePath, Maybe FilePath, Maybe FilePath)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect. Later suites do not overwrite earlier output. All the suites reach Hackage.

@ysangkok
ysangkok merged commit 79df1dc into master Sep 7, 2026
15 checks passed
@ysangkok
ysangkok deleted the test-report-log branch September 7, 2026 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Issues with test runner configuration

4 participants