Skip to content

Fix CI for Emmy#67

Merged
avivace merged 2 commits intogbdev:mainfrom
vulcandth:emmy-fix
Mar 21, 2026
Merged

Fix CI for Emmy#67
avivace merged 2 commits intogbdev:mainfrom
vulcandth:emmy-fix

Conversation

@vulcandth
Copy link
Contributor

This pull request refactors and improves the Emmy emulator integration by restructuring browser automation logic for better reliability and maintainability. The changes introduce helper methods for managing the Selenium WebDriver session, waiting for elements, and ensuring the emulator's settings are open before interaction. This makes the setup and ROM loading process more robust and less error-prone.

Browser session management improvements:

  • Added _close_driver and _reset_session methods to handle WebDriver lifecycle, ensuring proper cleanup and reliable session restarts. (emulators/emmy.py)
  • Updated undoSetup to use the new _close_driver method for consistent shutdown. (emulators/emmy.py)

Web interaction and reliability enhancements:

  • Introduced helper methods _wait, _find_now, and _wait_for_id to standardize waiting for elements and interactions, reducing flakiness in browser automation. (emulators/emmy.py)
  • Added _ensure_settings_open to reliably open and verify the emulator settings panel before proceeding with further actions. (emulators/emmy.py)
  • Refactored setup and startProcess to use the new session and element-waiting logic, improving robustness when selecting system modes and uploading ROMs. (emulators/emmy.py) [1] [2]

The Emmy Selenium runner was assuming the DMG/CGB mode buttons were immediately available after opening the site. In CI, the React UI can still be mounting the Settings drawer content when the test harness tries to click those controls, which caused intermittent NoSuchElementException failures for dmg-mode and cgb-mode.

Add explicit WebDriver waits for document readiness, element presence, and clickability. Introduce helper methods that reopen the Settings drawer only when necessary and wait for the mode buttons to appear before using them. Also wait for the ROM file input before uploading test ROMs so startup is synchronized with the live Emmy UI.
Emmy was reusing one Selenium browser session across the full test suite, which let a failed or incompatible ROM leave the page in a dirty state for later tests. That made some otherwise passing tests fail depending on execution order.

Add session reset helpers that reload the Emmy page before each run, rebuild the normal UI state, and safely recreate Chrome when a simple page reset is not enough. Also centralize driver cleanup so setup and teardown handle broken sessions more reliably.
@avivace avivace merged commit cd52819 into gbdev:main Mar 21, 2026
1 check passed
@vulcandth vulcandth deleted the emmy-fix branch March 21, 2026 12:18
vulcandth added a commit to vulcandth/GBEmulatorShootout that referenced this pull request Mar 21, 2026
* Fix CI for Emmy (gbdev#67)

* Fix Emmy CI startup timing for mode selection

The Emmy Selenium runner was assuming the DMG/CGB mode buttons were immediately available after opening the site. In CI, the React UI can still be mounting the Settings drawer content when the test harness tries to click those controls, which caused intermittent NoSuchElementException failures for dmg-mode and cgb-mode.

Add explicit WebDriver waits for document readiness, element presence, and clickability. Introduce helper methods that reopen the Settings drawer only when necessary and wait for the mode buttons to appear before using them. Also wait for the ROM file input before uploading test ROMs so startup is synchronized with the live Emmy UI.

* Reset Emmy browser state between test runs

Emmy was reusing one Selenium browser session across the full test suite, which let a failed or incompatible ROM leave the page in a dirty state for later tests. That made some otherwise passing tests fail depending on execution order.

Add session reset helpers that reload the Emmy page before each run, rebuild the normal UI state, and safely recreate Chrome when a simple page reset is not enough. Also centralize driver cleanup so setup and teardown handle broken sessions more reliably.

* Move pages build inputs to main branch

Add a main-branch copy of build.py based on the gh-pages version with only the CLI/path plumbing needed for CI.

Update deploy-pages.yml so deploy-pages checks out main, installs the core Python dependencies, dumps emulators.json and tests.json from main.py on each run, copies those manifests into gh-pages, builds pages/index.html from the gh-pages copies plus persisted emulator result JSON, and removes only pages/build.py before committing.

This keeps gh-pages as published artifacts while allowing new tests, emulators, and page-build changes to be made from main.

* Fix deploy-pages manifest generation

Refactor main.py so --dump-emulators-json and --dump-tests-json use static emulator metadata instead of importing emulator backends. This avoids runtime-only dependencies such as selenium when deploy-pages regenerates emulators.json and tests.json.

Add a direct workflow_dispatch entrypoint to deploy-pages.yml and skip the artifact download step for manual runs. That allows the Deploy Pages workflow to be triggered by hand to rebuild gh-pages from the current manifests and persisted results without first running an emulator workflow.
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