Skip to content

Add source location URL to CI test failures.#311

Merged
zainab-ali merged 5 commits into
typelevel:mainfrom
zainab-ali:source-code-url
Apr 29, 2026
Merged

Add source location URL to CI test failures.#311
zainab-ali merged 5 commits into
typelevel:mainfrom
zainab-ali:source-code-url

Conversation

@zainab-ali
Copy link
Copy Markdown
Collaborator

@zainab-ali zainab-ali commented Apr 22, 2026

This resolves #310 .

Source locations in GitHub Actions are displayed as navigable URLs. This can be configured for other CI providers using the WEAVER_SOURCE_URL environment variable.

Example

You can find an example in our own GitHub Actions logs
image

Public API changes

While this is a breaking API change, most users aren't affected by it.

  • The Test constructor requires an implicit Env. Most users writing custom test functions will be using IO, so will have this already.
  • EffectCompat now requires an Env. This affects anyone implementing custom effect types.

@zainab-ali zainab-ali marked this pull request as ready for review April 22, 2026 15:27
Comment thread modules/core/shared/src/main/scala/weaver/Test.scala
Comment thread modules/core/shared/src/main/scala/weaver/Result.scala Outdated
Comment thread modules/core/shared/src/main/scala/weaver/Result.scala
Comment thread modules/core/shared/src/main/scala/weaver/Test.scala
Comment thread modules/framework-cats/shared/src/test/scala/Meta.scala Outdated
G: Concurrent[F],
C: Clock[F]): F[TestOutcome] = {
C: Clock[F],
E: Env[F]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm not sure it's necessary for the change to impact these layers of the framework. You could centralise the querying of the environment in the formatter (in an unsafe fashion), and apply the github-specific rendering there.

I appreciate that reading the environment does not fall strictly in the pure-FP paradigm that Typelevel ougth to strive for, but the sbt-test-interface that weaver implements forces some compromise onto us. I'm happy to deviate a little bit out of the CE idioms if it minimises the impact / the amount of things the information needs to be threaded through. Additionally, the set of environment variables is pretty much immutable during the lifetime of a program.

Copy link
Copy Markdown
Collaborator Author

@zainab-ali zainab-ali Apr 27, 2026

Choose a reason for hiding this comment

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

I'd be happy to remove it with querying within the formatter, but it would be good if we could still test the code path.

In particular, our DogFoodTests should render the same message when running locally to in CI. We do this currently by overriding the Env here. It alsp allows us to test the codepath for the WEAVER_SOURCE_URL, as currently done here.

One alternative is to pass the suite's isCI boolean value through to Test and Result. The same information would need to be threaded through, so the code wouldn't necessarily be cleaner.

Another approach, if possible, would be for us to set WEAVER_SOURCE_URL within our own SBT build environment variables. We wouldn't be able to test the WEAVER_SOURCE_URL codepath, but the DogFoodTests would render the same output. I'll experiment with this.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The environment variable in SBT works for running DogFoodTests agnostic to CI.

Note that we need to have a different implementation for JS that uses process.env. @Baccata , what do you think of this approach?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yup, that's great imho 👍

@zainab-ali zainab-ali force-pushed the source-code-url branch 4 times, most recently from 20ce5f8 to e6ea5fe Compare April 27, 2026 15:46
Comment thread .scalafmt.conf
newlines.implicitParamListModifierPrefer = before
newlines.sometimesBeforeColonInMethodReturnType = false

assumeStandardLibraryStripMargin = true
Copy link
Copy Markdown
Collaborator Author

@zainab-ali zainab-ali Apr 27, 2026

Choose a reason for hiding this comment

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

This helps with the assertInlineSnapshot tests - updated tests now include stripMargin, but they're not aligned without scalafmt.

EDIT: I've moved it to PR #313 to make this diff easier.

Comment thread modules/framework-cats/shared/src/test/scala/DogFoodTests.scala
[error] <a href="https://github.com/typelevel/weaver-test/tree/4390ba8e91faa6e9ed2e0d112271d9c8e80d7034/modules/framework-cats/shared/src/test/scala/ExpectationsTests.scala#L107">https://github.com/typelevel/weaver-test/tree/4390ba8e91faa6e9ed2e0d112271d9c8e80d7034/modules/framework-cats/shared/src/test/scala/ExpectationsTests.scala#L107</a>
[error] expect.eql(1, 2)
[error] ^"""
</pre></div>
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This displays clickable links, so is better than a screenshot:

Image

Unfortunately we can't get correct source locations by running a test, as mdoc doesn't calculate source locations correctly.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

That's absolutely fine

Copy link
Copy Markdown
Collaborator

@Baccata Baccata left a comment

Choose a reason for hiding this comment

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

Great idea, and great work !

@zainab-ali zainab-ali merged commit 353a395 into typelevel:main Apr 29, 2026
13 checks passed
@zainab-ali zainab-ali deleted the source-code-url branch April 29, 2026 17:51
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.

Display source code URL in CI test failures

3 participants