Skip to content

Add PR preview screenshot workflow - #65

Merged
adam133 merged 3 commits into
mainfrom
copilot/add-github-actions-screenshot-workflow
Mar 23, 2026
Merged

Add PR preview screenshot workflow#65
adam133 merged 3 commits into
mainfrom
copilot/add-github-actions-screenshot-workflow

Conversation

Copilot AI commented Mar 23, 2026

Copy link
Copy Markdown
Contributor

Each PR now automatically captures a 1920×1080 screenshot of the default map location in Unity play mode and posts a direct artifact download link as a PR comment.

Workflow (.github/workflows/pr-preview.yml)

  • Triggers on PRs to main
  • Runs only SceneScreenshotTests via game-ci/unity-test-runner@v4 (play mode, filtered by class name)
  • Uploads Screenshots/pr-preview.png as a 14-day artifact
  • Posts a PR comment with the artifact-url output as the download link; falls back to a run link if capture failed

Play-mode test (Assets/Tests/PlayMode/SceneScreenshotTests.cs)

  • Loads ProofOfConcept scene (bundled Ames, Iowa data)
  • Bypasses the interactive startup menu by advancing GameManager to LoadingMap immediately after scene load — MapSceneBuilder.WaitForMenuThenBuild unblocks on the state change
  • Waits up to 4 min for GameState.Racing (level fully built) with an explicit null-guard on GameManager.Instance
  • Renders via Camera.Render()RenderTextureTexture2D.ReadPixels() → PNG — works in headless batch mode without a display
  • Saves to <project root>/Screenshots/pr-preview.png where the workflow artifact step picks it up
  • [Timeout(300000)] guards the full 5-minute budget
Original prompt

add a pr GitHub actions workflow that loads the default location in play mode, takes a screenshot, then uploads it to the pull request with a direct link to download the image. should make it easier to review pull requests.


📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.

- Add .github/workflows/pr-preview.yml: triggers on PRs to main, runs a
  dedicated Unity play-mode test, uploads the PNG as a GitHub Actions
  artifact (14-day retention), and posts a PR comment with a direct
  download link via actions/github-script

- Add Assets/Tests/PlayMode/SceneScreenshotTests.cs: loads the bundled
  ProofOfConcept scene, bypasses the startup menu by advancing the
  GameManager state, waits up to 4 minutes for the map build pipeline to
  reach GameState.Racing, then captures a 1920x1080 PNG using
  Camera.Render() + RenderTexture (works in headless/batch mode)

- Add Assets/Tests/PlayMode/SceneScreenshotTests.cs.meta: Unity metadata

Co-authored-by: adam133 <20442729+adam133@users.noreply.github.com>
Agent-Logs-Url: https://github.com/adam133/vectorroad/sessions/15e71ff2-beeb-4983-9c4b-dca9a8b4341a
@github-actions
github-actions Bot requested a review from adam133 March 23, 2026 01:34
Copilot AI changed the title [WIP] Add GitHub actions workflow for screenshot in play mode Add PR preview screenshot workflow Mar 23, 2026
@github-actions

Copy link
Copy Markdown

📸 PR Preview Screenshot

A screenshot of the default location in play mode was captured for this PR.

⬇️ Download Screenshot

Rendered at workflow run

@adam133

adam133 commented Mar 23, 2026

Copy link
Copy Markdown
Owner

@copilot got an error in the workflow:

✅ playmode-results.xml - 38/38 - Passed in 9.993s

Analyze result:
✅ PR Preview Screenshot - 38/38 - Passed in 9.993s
Posting results for 4e97a53
Error: Resource not accessible by integration

Also, the screenshot is just terrain - make sure it's taken after the car has been set to a road.

… screenshot

- Add `issues: write` permission to pr-preview.yml so that
  actions/github-script can post PR comments via the Issues API
  (github.rest.issues.createComment requires this permission)

- Add `yield return new WaitForSeconds(3f)` after GameState.Racing so
  that physics has time to settle the vehicle onto the road surface and
  ChaseCam's SmoothDamp has time to move from its initial position to
  behind the vehicle before the screenshot is captured

Co-authored-by: adam133 <20442729+adam133@users.noreply.github.com>
Agent-Logs-Url: https://github.com/adam133/vectorroad/sessions/5bceafe7-9ab6-4c42-977f-a4d9b35085dc

Copilot AI commented Mar 23, 2026

Copy link
Copy Markdown
Contributor Author

@copilot got an error in the workflow:

✅ playmode-results.xml - 38/38 - Passed in 9.993s...

Fixed in c9f3cc1:

  1. Permissions error — added issues: write to the workflow job permissions. github.rest.issues.createComment uses the Issues API, which requires this permission (separate from pull-requests: write).

  2. Screenshot showing only terrain — added yield return new WaitForSeconds(3f) after GameState.Racing is reached. Without it the screenshot was taken immediately as SetState(Racing) fired, before the vehicle had time to drop from its spawn height onto the road surface and before ChaseCam's SmoothDamp could move the camera from its initial position to behind the car.

@adam133
adam133 marked this pull request as ready for review March 23, 2026 02:05
@github-actions

Copy link
Copy Markdown

📸 PR Preview Screenshot

A screenshot of the default location in play mode was captured for this PR.

⬇️ Download Screenshot

Rendered at workflow run

@adam133
adam133 merged commit a83bf8d into main Mar 23, 2026
12 of 13 checks passed
@adam133
adam133 deleted the copilot/add-github-actions-screenshot-workflow branch March 23, 2026 02:12
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.

2 participants