Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions .github/workflows/screenshot-test-comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ jobs:

// Find the ScreenshotTests job
let screenshotTestRun = null;
let workflowRunId = null;
for (const run of runs.data.workflow_runs) {
if (run.name === 'Build jMonkeyEngine') {
workflowRunId = run.id;
const jobs = await github.rest.actions.listJobsForWorkflowRun({
owner,
repo,
Expand All @@ -73,9 +75,25 @@ jobs:
return;
}

core.setOutput('run_url', `https://github.com/${owner}/${repo}/actions/runs/${workflowRunId}`);

// Check if the job failed
if (screenshotTestRun.conclusion === 'failure') {
core.setOutput('failed', 'true');
// Now check if the changed images artifact exists
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner,
repo,
run_id: workflowRunId
});

const artifact = artifacts.data.artifacts.find(a => a.name === 'screenshot-test-report');
if (artifact) {
core.setOutput('failed', 'true');
core.setOutput('artifact_url', `https://github.com/${owner}/${repo}/actions/runs/${workflowRunId}/artifacts/${artifact.id}`);
} else {
console.log('Job failed but no changed images were generated.');
core.setOutput('failed', 'false');
}
} else {
core.setOutput('failed', 'false');
}
Expand All @@ -98,7 +116,8 @@ jobs:
The purpose of these tests is to ensure that changes introduced in this PR don't break visual features. They are visual unit tests.

📄 **Where to find the report:**
- Go to the (failed run) > Summary > Artifacts > screenshot-test-report
- **[Direct Download: screenshot-test-report](${{ steps.check-status.outputs.artifact_url }})**
- Alternatively, go to the [failed run summary](${{ steps.check-status.outputs.run_url }}) > Artifacts > screenshot-test-report
- Download the zip and open jme3-screenshot-tests/build/reports/ScreenshotDiffReport.html

⚠️ **If you didn't expect to change anything visual:**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package org.jmonkeyengine.screenshottests.testframework;

import com.jme3.app.Application;
import com.jme3.app.state.AbstractAppState;
import com.jme3.app.state.AppStateManager;
import com.jme3.renderer.Renderer;
import com.jme3.system.JmeSystem;
import com.jme3.texture.FrameBuffer;
import com.jme3.texture.Texture2D;
import com.jme3.util.BufferUtils;

import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.file.Path;
import java.util.Optional;

public class OffScreenshotAppState extends AbstractAppState{

private Texture2D renderTexture;
private Renderer renderer;
private FrameBuffer frameBuffer;
private Optional<Path> capture = Optional.empty();

private ByteBuffer outBuf;

public void takeScreenshot(Path pathToSaveTo) {
capture = Optional.of(pathToSaveTo);
}

public OffScreenshotAppState(Texture2D renderTexture, FrameBuffer frameBuffer) {
this.renderTexture = renderTexture;
this.frameBuffer = frameBuffer;
}

@Override
public void initialize(AppStateManager stateManager, Application app) {
super.initialize(stateManager, app);
renderer = app.getRenderManager().getRenderer();
outBuf = BufferUtils.createByteBuffer(renderTexture.getImage().getWidth() * renderTexture.getImage().getHeight() * 4);
}

@Override
public void postRender() {
super.postRender();
if (capture.isPresent()) {

renderer.readFrameBuffer(frameBuffer, outBuf);
try {
FileOutputStream fileOutBuf = new FileOutputStream(capture.get().toFile());
JmeSystem.writeImageFile(fileOutBuf, "png",outBuf, renderTexture.getImage().getWidth(), renderTexture.getImage().getHeight());
}catch (IOException e) {
throw new RuntimeException(e);
}
capture = Optional.empty();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
*/
public enum PixelSamenessDegree{
SAME(1, null),
NEGLIGIBLY_DIFFERENT(1, ColorRGBA.Green),
NEGLIGIBLY_DIFFERENT(3, ColorRGBA.Green),
SUBTLY_DIFFERENT(10, ColorRGBA.Blue),

MEDIUMLY_DIFFERENT(20, ColorRGBA.Yellow),
Expand Down
Loading
Loading