hackage-server icon indicating copy to clipboard operation
hackage-server copied to clipboard

Is there a way for a package to detect that it's building on hackage?

Open ivanperez-keera opened this issue 6 months ago • 19 comments

We have a package (https://github.com/Copilot-Language/copilot/tree/master/copilot-bluespec) that cannot be tested on hackage because bsc (bluespec) is not included.

We could disable tests by default, but I'm wondering if there's a way to disable tests on hackage only, and keep them enabled by default otherwise.

ivanperez-keera avatar Jul 08 '25 22:07 ivanperez-keera

Hackage doesn't build tests, or at least doesn't run themm does it?

phadej avatar Jul 10 '25 20:07 phadej

Hackage does build and run tests. This can be disabled per-package on hackage: https://hackage.haskell.org/package/copilot-bluespec/maintain

This is however not an ideal situation, as it has to be done for each version. A PR to hackage to allow disabling tests across all versions (including yet-to-be-uploaded) would be welcome.

gbaz avatar Jul 10 '25 20:07 gbaz

One can update Hackage configutation to install bluespec by submitting a PR to https://github.com/haskell-infra/hackage-doc-builder-config

Bodigrim avatar Jul 10 '25 20:07 Bodigrim

Tagging @RyanGlScott .

ivanperez-keera avatar Jul 11 '25 05:07 ivanperez-keera

Hackage does build and run tests.

Interesting. I find that somewhat surprising. I'd prefer running tests to be opt-in, I don't find it useful at all.

I don't want my docs building failing because of test issues (mostly missing compile or run time dependencies)

phadej avatar Jul 11 '25 11:07 phadej

Addition: test runner should use --test-show-details=direct or always. Hiding the test output is no point in CI

Running 1 test suites...
Test suite smoke: RUNNING...
Test suite smoke: PASS

is useless, especially as that suite probably says that it's skipped (because no external runtime dependency is found), but I cannot be sure as output is omitted.

phadej avatar Jul 11 '25 11:07 phadej

I don't want my docs building failing because of test issues (mostly missing compile or run time dependencies)

I think it's independent: docs will be built just fine even if tests fail.

Addition: test runner should use --test-show-details=direct or always.

I raised this recently in https://github.com/haskell/hackage-server/issues/1397.

Bodigrim avatar Jul 13 '25 12:07 Bodigrim

Returning to the original question of how to fix the Hackage tests for copilot-bluespec: I wouldn't mind opening a PR on the hackage-doc-builder-config to add bluespec to the list of packages in build-depends.nix. That being said, I have a question about the scope of build-depends.nix. The top of that file says:

# Packages available to packages built using the Hackage Haddock builder

The key phrase there is "Haddock builder". Is it acceptable to add packages there solely for the sake of running tests? (copilot-bluespec uses bsc in its test suite, but otherwise its Haddocks build without issue.)

RyanGlScott avatar Jul 14 '25 10:07 RyanGlScott

@RyanGlScott I don't know that the current setting to disable tests would help us otherwise.

Currently copilot-bluespec is set to not run tests:

Image

However, it still shows that building the tests failed:

Image

Apparently, a re-build (which I tried to trigger last week) does not help.

ivanperez-keera avatar Jul 14 '25 13:07 ivanperez-keera

Is it acceptable to add packages there solely for the sake of running tests?

Any updates on this question?

ivanperez-keera avatar Sep 17 '25 23:09 ivanperez-keera

Hackage does build and run tests. This can be disabled per-package on hackage: https://hackage.haskell.org/package/copilot-bluespec/maintain

This is however not an ideal situation, as it has to be done for each version. A PR to hackage to allow disabling tests across all versions (including yet-to-be-uploaded) would be welcome.

I published a few packages on hackage recently with external dependencies, one even used z3 in tests. I didn't do anything to disable test and don't remember any issue with failing test. So Hackage just stores the uploaded archive. Is building test a special Hackage feature available on request?

yaitskov avatar Nov 15 '25 13:11 yaitskov

@yaitskov if you upload Haddocks yourself, Hackage recognizes it as a hint not to build the package (or run tests). This is somewhat coincidental: the builder was originally just to build docs and later extended also to run tests, but the old logic "don't bother to build if an author has already provided Haddocks" remains.

Bodigrim avatar Nov 15 '25 14:11 Bodigrim

Gentle ping.

ivanperez-keera avatar Nov 21 '25 17:11 ivanperez-keera

Adding packages to the nix config for running tests as well as building haddocks should be fine, within reason, imho.

gbaz avatar Nov 21 '25 17:11 gbaz

Adding packages to the nix config for running tests as well as building haddocks should be fine, within reason, imho.

Could a hackage-server use nix files from the project?

I nixified the copilot in my fork.

yaitskov avatar Nov 21 '25 20:11 yaitskov

That's not the intention. Rather, the nix config for hackage-builder is to provide third party non-haskell binaries that are necessary for building (and testing as well) packages uploaded to hackage.

gbaz avatar Nov 21 '25 20:11 gbaz

That's not the intention. Rather, the nix config for hackage-builder is to provide third party non-haskell binaries that are necessary for building (and testing as well) packages uploaded to hackage.

aha I missed the point that ci works with a archive not a git, but technically as a hack cabal can include a few nix files as extras. The nix config is classic, just master, no flakes, no nix.conf tuning like in cardano-ledger.

then the whole class of such issues wouldn't exist.

yaitskov avatar Nov 21 '25 20:11 yaitskov

I wouldn't mind opening a PR on the hackage-doc-builder-config to add bluespec to the list of packages in build-depends.nix.

I think that'd be a good idea.

ivanperez-keera avatar Dec 04 '25 12:12 ivanperez-keera

What does the Nix config has to do with the initial topic of this issue:

Is there a way for a package to detect that it's building on hackage?

I think it'd be good to address this issue regardless of what is there in the Nix config.

ulysses4ever avatar Dec 04 '25 15:12 ulysses4ever