Skip to content

Save screenshots to Maven build output directory#3819

Open
basilevs wants to merge 1 commit into
eclipse-platform:masterfrom
basilevs:surefire_screenshot
Open

Save screenshots to Maven build output directory#3819
basilevs wants to merge 1 commit into
eclipse-platform:masterfrom
basilevs:surefire_screenshot

Conversation

@basilevs
Copy link
Copy Markdown
Contributor

@basilevs basilevs commented May 13, 2026

Partial fix for eclipse-platform/eclipse.platform.swt#3303.

SWT does not use Platform, so existing heuristics do not work in GitHub Actions.

Once this more sensible screenshot location is set, SWT GHA workflows can be updated to archive screenshots to artifacts. Before the change they have been thrown away and could not be inspected.

@basilevs basilevs force-pushed the surefire_screenshot branch from 0b25779 to c5aabc8 Compare May 13, 2026 22:21
@basilevs
Copy link
Copy Markdown
Contributor Author

@merks @HeikoKlare could you suggest a better heuristic or another way to work with CI screenshots in SWT?

@merks
Copy link
Copy Markdown
Contributor

merks commented May 14, 2026

I have no knowledge in this area. Maybe @HannesWell has a good idea.

@HeikoKlare
Copy link
Copy Markdown
Contributor

It sounds reasonable to have a properly defined place for storing the screenshots so that they can be archived during GHA runs. I remember that I did some tweaks when analyzing an issue only occurring in GHA runs for which I required screenshots. So having a general solution for this would be great. Thank you for putting effort into this.

I wonder if we couldn't just define a proper value for the existing system property junitReportOutput in the Maven build. Doing that in the parent might only require it to be properly defined/parameterized once.
In case we only want a specific folder to be used in GHA runs, as we align the GHA workflow configuration with specific code for defining the output folder, we may also simply guard this behavior with the GHA context, like we do in some utilities such as: https://github.com/eclipse-platform/eclipse.platform.swt/blob/f33b79ee65f5cedfa8f7ac4e1bf93994a904a445/tests/org.eclipse.swt.tests/JUnit%20Tests/org/eclipse/swt/tests/junit/SwtTestUtil.java#L121-L123

Regarind the proposed change: Unless the Eclipse platform is present and the system property for the output folder is specified, the results will now always be written into the surefire target repository (if existing). Is that what we want to happen? For example, when executing the tests locally in the IDE, do we want to have the screenshots placed in a Maven-build-specific folder? In case I have execute a local Maven build at some earlier point in time, that folder will be present and used.

Maybe @akurtakov can also help here, as he guarded the screenshot output folder extraction with the Platform being present recently:

@basilevs
Copy link
Copy Markdown
Contributor Author

existing system property junitReportOutput

Is not it an application argument and not a system property?

@HeikoKlare
Copy link
Copy Markdown
Contributor

Is not it an application argument and not a system property?

You're right. Then we maybe want to check for a GHA environment and then define a dedicated folder that is also used for artifact upload?

@basilevs basilevs force-pushed the surefire_screenshot branch from c5aabc8 to c9bbda8 Compare May 14, 2026 11:19
@basilevs
Copy link
Copy Markdown
Contributor Author

basilevs commented May 14, 2026

@HeikoKlare

You're right. Then we maybe want to check for a GHA environment and then define a dedicated folder that is also used for artifact upload?

The decision should be based on whether Maven is in use, not on which environment it is running on.
I've added a dedicated property and a suitable default via parent pom in the latest revision. Is it better?

As some projects reuse aggregator's workflow, and most use it's parent POM, the maintenance effort per-project should be minimal.

@basilevs basilevs changed the title Save screenshot to Surefire directory if any Save screenshots to Maven build output directory May 14, 2026
Copy link
Copy Markdown
Member

@HannesWell HannesWell left a comment

Choose a reason for hiding this comment

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

Generally I think this is fine.
Do you know if the screenshots are also saved for I-build tests and if some according adaption is needed then? I'm not aware of it, but might have missed it.

Comment thread eclipse-platform-parent/pom.xml Outdated
<printApiMessages>false</printApiMessages>
<failOnJavadocErrors>false</failOnJavadocErrors>
<compileLogDir>${project.build.directory}/compilelogs</compileLogDir>
<eclipse.screenshot_directory>${project.build.directory}/screenshots</eclipse.screenshot_directory>
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.

Wouldn't the property be better named surefire.screenshot_directory (and be placed next to the other surefire related properties)?

Suggested change
<eclipse.screenshot_directory>${project.build.directory}/screenshots</eclipse.screenshot_directory>
<surefire.screenshot_directory>${project.build.directory}/screenshots</surefire.screenshot_directory>

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.

The JVM system property is naturally usable outside of surefire. For example, it could be configured via launch configuration. This makes naming it surefire specific confusing.

Maven property was named to exactly match the JVM system property to help with identification and search.

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.

Applied anyway.

@basilevs
Copy link
Copy Markdown
Contributor Author

basilevs commented May 14, 2026

Do you know if the screenshots are also saved for I-build tests

I did fix screenshots for platform.ui a few years back. Those relied on Platform to be present. I'm not sure if that fix applies to I-build.

@basilevs basilevs force-pushed the surefire_screenshot branch from c9bbda8 to 1e5e3cc Compare May 14, 2026 17:50
@basilevs basilevs requested a review from HannesWell May 15, 2026 06:40
@HeikoKlare
Copy link
Copy Markdown
Contributor

In general, the approach also looks fine for me now.
But I have to admit that I am a bit lost with the different configurations and how they are described in the code.

You mention this older PR that states to ensure that test screenshots are provided in the GH workflow artifacts:

That one did not affect I-Builds but just GH workflows and introduced archiving of screenshots placed here:

${{ github.workspace }}//results//*.png

I ran local Maven builds and explicitly made some tests fail. The produced screenshots are placed in the temp folder. So I wonder if this configuration is still valid?

Also note that there is further documentation (and outdated code relying on Gerrit) in the Screenshots.getResultsDirectory() method. I also think we should clean up the code in Screenshots.getResultsDirectory() and Screenshots.getJunitReportOutput() to clarify our current understanding of it. The Gerrit-related code can probably be removed. the getJunitReportOutput() is specific to the system argument that is used in Ant-based I-Builds and there will be the new configuration option based on a system property currently used by Maven (which is currently placed in `getJunitReportOutput() which in my opinion is misleading). When they are all not present, we will fall back to using the temp folder.

@basilevs
Copy link
Copy Markdown
Contributor Author

basilevs commented May 15, 2026

I ran local Maven builds and explicitly made some tests fail. The produced screenshots are placed in the temp folder. So I wonder if this configuration is still valid?

I can't find how Ant tests (which store data in results/*) are launched in CI, so I can't answer that. Maven tests do not use the relevant command line argument.

Also note that there is further documentation (and outdated code relying on Gerrit) in the Screenshots.getResultsDirectory() method. I also think we should clean up the code in Screenshots.getResultsDirectory() and Screenshots.getJunitReportOutput() to clarify our current understanding of it. The Gerrit-related code can probably be removed.

Do you suggest to cleanup Gerrit code as part of this unrelated feature? While I can certainly do so, I have no means to reliably test it (without committer level access to all involved CI infra) and would like to avoid mixing concerns.

the getJunitReportOutput() is specific to the system argument that is used in Ant-based I-Builds and there will be the new configuration option based on a system property currently used by Maven (which is currently placed in `getJunitReportOutput() which in my opinion is misleading).

I see no indication that org.eclipse.test.Screenshots.getJunitReportOutput() is or should be limited to Ant. Indeed, all tests run using JUnit in both Ant and Maven. IMO, it using Ant specific argument is an implementation detail. I can move the new code out to getResultsDirectory(), but I do not believe this would improve clarity in any way.

@HeikoKlare
Copy link
Copy Markdown
Contributor

I can't find how Ant tests (which store data in results/*) are launched in CI, so I can't answer that. Maven tests do not use the relevant command line argument.

Why do you assume Ant tests to store data in "result/*"? From what I see, the configuration is only used in a GH workflow, so used by GHA runs. The GHA runs use Maven to execute tests and the Maven execution does not seem to place the screenshots at any reasonable place currently. The Ant tests set the junitReportOutput property in the according Ant scripts:

<arg value="-junitReportOutput" />
<arg path="${junit-report-output}" />

Do you suggest to cleanup Gerrit code as part of this unrelated feature? While I can certainly do so, I have no means to reliably test it (without committer level access to all involved CI infra) and would like to avoid mixing concerns.

I just suggest to follow boy scout rule and clean up the current implementation of how the path for storing the screenshots is defined instead of adding further cases at a "random" position. In addition:

I see no indication that org.eclipse.test.Screenshots.getJunitReportOutput() is or should be limited to Ant. Indeed, all tests run using JUnit in both Ant and Maven. IMO, it using Ant specific argument is an implementation detail. I can move the new code out to getResultsDirectory(), but I do not believe this would improve clarity in any way.

The method is about processing the junitReportOutput argument (which is why it is named like that). This argument is currently only used when executing the tests via Ant. I just proposed to make the understanding that we gained in this discussion explicit in the code to avoid that we meet again in few months and have to extract all the semantics out of some grown code again.

That's why I propose to streamline the implementation by removing what is obsolete and cleaning up what needs to remaind or is added:

  • Make the getResultsDirectory() implementation operate based on precedence:
    • If present, use the junitReportOutput argument (like done with the existing `getJunitReportOutput() already, maybe add a note that this is currently used by Ant-based test execution)
    • Otherwise if present, use the added sytem property eclipse.screenshot_directory for the screenshots (maybe add a note that this is currently used by Maven-based test execution)
    • Otherwise fall back to using temp dir
  • Remove the Gerrit-related implementation, as it's unused
  • Remove the obsolete "results/*" entry in the GH workflow

If you want, I can also provide a preparatory PR removing the obsolete code/configuration so that you can then add your new configuration on top.

@basilevs
Copy link
Copy Markdown
Contributor Author

basilevs commented May 15, 2026

Why do you assume Ant tests to store data in "result/*"?

<property
name="junit-report-output"
value="${eclipse-home}/results" />
<mkdir dir="${junit-report-output}" />

The method is about processing the junitReportOutput argument (which is why it is named like that). This argument is currently only used when executing the tests via Ant.

The argument is named this way, because it manages JUnit output. Arguably, method name matches the argument, because they serve the same purpose, not because method implementation depends on argument. It does not matter though, I'll move stuff around to unblock.

That's why I propose to streamline the implementation by removing what is obsolete and cleaning up what needs to remaind or is added:

I will apply these changes as requested, but am unable to test that.

If you want, I can also provide a preparatory PR removing the obsolete code/configuration so that you can then add your new configuration on top.

I'll do the change, but it would be nice to somehow run all related CI's on it. I'm not sure if it even possible (given all sub-projects have their own configurations, some reusing buildMaven.yml and some not)

@basilevs basilevs force-pushed the surefire_screenshot branch 2 times, most recently from a197d37 to e2aaa3d Compare May 15, 2026 13:40
@basilevs
Copy link
Copy Markdown
Contributor Author

basilevs commented May 15, 2026

@HeikoKlare I've applied all suggestions.

* Remove the obsolete "results/*" entry in the GH workflow

When I was doing the old PR, I assumed that Maven somehow started Ant tests for platform.ui project. This does not seem to be the case anymore, but I can't verify that. A few of recent failed builds in platform.ui do not produce screenshots at all (no message about AWT screenshot in console). Do you happen to know what is going on there?

BTW:
Following aggregator submodules use buildMaven.yml:

  • eclipse.pde
  • eclipse.platform.ui
  • eclipse.platform
  • equinox.p2

Surprisingly not a lot of them. Still, we can't be sure, that projects out of aggregator would not break.

Copy link
Copy Markdown
Contributor

@HeikoKlare HeikoKlare left a comment

Choose a reason for hiding this comment

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

I've applied all suggestions.

Thank you! It looks fine to me and I am sure this will help us in the future to better understand the code. @HannesWell what do you think about the changes?

When I was doing the old PR, I assumed that Maven somehow started Ant tests for platform.ui project. This does not seem to be the case anymore, but I can't verify that. A few of recent failed builds in platform.ui do not produce screenshots at all (no message about AWT screenshot in console). Do you happen to know what is going on there?

I have researched in history for a while now, trying to understand why/how this could have ever worked (using the "target/results" directory), but I have no clue yet. To the best of my knowledge, the GH workflows always used pure Maven (with surefire for test execution) and Ant was only used for I-Build tests. Maybe there was a different configuration at some point in time (in particular the Screenshots class was heavily modified and moved around) that made this work. Are you sure that the artifacts upload has ever worked?

I also wondered where screenshots are actually taken. I assumed that the ScreenshotOnFailure/Screenshots.onFailure() rules is used by many UI tests in Platform UI, but that's not the case. Some usages have silently been removed during JUnit 5 migration, such as the one in PartRenderingEngineTests via eclipse-platform/eclipse.platform.ui#3636.
@vogella do you know if there were more usages of this JUnit 4 rule that have been removed during JUnit 5 migration?

BTW: Following aggregator subprojects projects use buildMaven.yml:

  • eclipse.pde
  • eclipse.platform.ui
  • eclipse.platform
  • equinox.p2

Surprisingly not a lot of them. Still, we can't be sure, that projects out of aggregator would not break.

Projects out of aggregator are not supposed to use those workflows. But anyway, where do you see a chance that anything could break? The change in the workflow descriptions just affects an included folder in artifacts upload, so the worst I can expect is that some PNGs are not uploaded as expected?

Comment on lines +156 to +157
@Deprecated
public static boolean isRunByGerritHudsonJob() {
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.

This plugin is not public API, so we don't need to deprecate this but can just remove it.

Copy link
Copy Markdown
Contributor Author

@basilevs basilevs May 15, 2026

Choose a reason for hiding this comment

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

For non-public API, it is used a lot:

Screenshot 2026-05-15 at 18 14 18

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.

Sorry, my comment was a bit imprecise: the plugin is not part of the SDK but only used internally for tests inside the SDK. And within the SDK, there are no further consumers of this method:
image

eclipse-platform/eclipse.platform.swt#3303

As screenshots are effectively a build artifact, save them in build
output directory (target/ by default).

SWT does not use Platform, so existing heuristics have not worked in
GitHub Actions, abandoning screenshots in /tmp without archiving into
artifacts.

The change breaks existing Gerrit jobs by removing public method
`Screenshots.isRunByGerritHudsonJob()`, but as Gerrit is no longer used,
this should be fine.
@basilevs basilevs force-pushed the surefire_screenshot branch from e2aaa3d to c897f17 Compare May 15, 2026 14:19
@basilevs
Copy link
Copy Markdown
Contributor Author

basilevs commented May 15, 2026

Projects out of aggregator are not supposed to use those workflows. But anyway, where do you see a chance that anything could break? The change in the workflow descriptions just affects an included folder in artifacts upload, so the worst I can expect is that some PNGs are not uploaded as expected?

Well, given this is a second time I'm fixing these screenshots archival I would not wish for anyone to do this yet again.

@HeikoKlare
Copy link
Copy Markdown
Contributor

Well, given this is a second time I'm fixing these screenshots archival I would not wish for anyone to do this yet again.

I have to admit that I still don't get which risk we need to consider here. The archival is already broken (and probably never worked), so what do you think might become worse with this PR?

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.

4 participants