Skip to content

Add source location URL to CI test failures.#311

Open
zainab-ali wants to merge 1 commit intotypelevel:mainfrom
zainab-ali:source-code-url
Open

Add source location URL to CI test failures.#311
zainab-ali wants to merge 1 commit intotypelevel:mainfrom
zainab-ali:source-code-url

Conversation

@zainab-ali
Copy link
Copy Markdown
Contributor

@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
} yield TestOutcome(name, end - start, res, logs)
}

def pure(name: String)(ex: () => Expectations): TestOutcome = {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We no longer call Test.pure in our own code, as we need an effect to get the source URL.

Perhaps we should deprecate it?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it doesn't hurt to keep it either, I've no strong opinion.

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.


def formatted: Option[String] = {
Some(formatDescription(reason,
sourceLocationUrl = sourceLocationUrl,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nitpick: this single named parameter looks odd, can we align it with the rest of the code?

sourceLocationUrl match {
case Some(url) =>
// Display a URL to a source location on a CI host. Line numbers are typically referenced with #L anchors.
s"${url}${l.fileRelativePath}#L${l.line}"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should the user be able to override the anchor with config/env var?

} yield TestOutcome(name, end - start, res, logs)
}

def pure(name: String)(ex: () => Expectations): TestOutcome = {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it doesn't hurt to keep it either, I've no strong opinion.

Comment on lines +364 to +367
def entries: IO[List[(String, String)]] = IO(List(
("WEAVER_SOURCE_URL",
"https://github.com/typelevel/weaver-test/blob/v0.12.0/")
))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's mention this in the documentation

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.

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