Skip to content

test: add build tests for Excel - #4

Merged
WilliamSmithEdward merged 7 commits into
WilliamSmithEdward:mainfrom
DecimalTurn:ci-tests
Aug 2, 2026
Merged

test: add build tests for Excel#4
WilliamSmithEdward merged 7 commits into
WilliamSmithEdward:mainfrom
DecimalTurn:ci-tests

Conversation

@DecimalTurn

@DecimalTurn DecimalTurn commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

As mentioned in #1, this pull request introduces a CI workflow for building and testing Excel VBA fixtures on a GitHub Windows runner.

  • Makes use of the setup-vba action that I maintain to get the runner ready to run VBA code.
  • Uses the checked out version of pyOpenVBA to build the Excel files
  • Tests them by running a macro inside the file using COM automation
  • Takes a screenshot to help with debugging issues when the build or a test fails

I think this might be useful for this project to have such CI tests to help detect errors without having to run long running tests on a local dev machine.

ci: update workflow to set PYTHONPATH and remove local installation step

Fix Excel macro test workflow: add pywin32 postinstall, improve diagnostics and error handling

ci: increase timeout for Excel macro test job from 8 to 15 minutes

Fix encoding error: use ASCII dashes instead of Unicode

Add debug logging and error handling to fixture runner

fix: remove remaining Unicode and set UTF-8 output encoding on Windows

Add pre-built module_only.xlsm and parallel test jobs (fast + full)

Fix YAML syntax error: simplify test step and add CLI arg support

fix(test): improve Excel cleanup with gc.collect() and longer wait

- Add explicit garbage collection between fixtures
- Increase wait time after xl.Quit() to 3 second
- Nullify wb and xl references after cleanup
- Prevents hangs when running multiple workbooks sequentially

test: remove module_only.xlsm and simplify workflow configuration

debug: add detailed logging to diagnose fixture runner hangs

Add comprehensive debug output at each step:
- Fixture processing start/end
- Dispatch, Open, Run, Close sequence with timestamps
- Workbook closing with error handling
- Excel.Quit() with explicit error reporting
- Cleanup phases (gc.collect, wait)
- Main loop progress with file/fixture count

All output flushed for real-time visibility in CI logs.

fix(test): diagnose and fix with_class fixture hang

- Add 5min test step timeout
- Add screenshot on failure to visualize hung state
- Reduce cleanup wait from 3s to 1s (not the bottleneck)
- Improve with_class macro robustness:
  - Add error handling for file I/O
  - Fallback to TEMP if ThisWorkbook.Path is empty
  - Handle macro execution errors gracefully
- Update run script to check TEMP dir for output files
- Upload failure screenshots as artifacts

ci: extract screenshot logic into separate ps1 file

- Create scripts/take-screenshot-on-failure.ps1 with reusable logic
- Minimize PowerShell window before capturing screenshot
- Update workflow to call external script instead of inline code
- Cleaner and more maintainable workflow configuration

fix: make Excel application visible for debugging screenshots
- Search for and minimize all PowerShell/pwsh windows, not just current process
- Check window visibility before minimizing
- Add better logging for debugging
- More robust for CI environments where window context differs

ci: run screenshot in separate hidden process

fix(test): show VBE window for error diagnostics

ci: align with VBA-Build screenshot approach

ci: target CMD window minimization

ci: target HostedComputeAgent window

ci: add current window minimization

ci: add ListVisibleWindows utility for reporting visible windows
@DecimalTurn

Copy link
Copy Markdown
Contributor Author

@WilliamSmithEdward I realize that the following headers were actually missing from the .cls file.

VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
END

Since, the VBE export usually has them, I think it is better to include them after all, but it seems that it works either way which is a good thing.

@WilliamSmithEdward

Copy link
Copy Markdown
Owner

@DecimalTurn Thank you! Will try to review and work on this, this weekend. Appreciate your time.

Maintainer additions on top of WilliamSmithEdward#4: the workflow runs a third-party
action and COM automation, so the default token grant is narrowed to
read-only, and the contribution gets its changelog entry.
Copilot AI review requested due to automatic review settings August 2, 2026 05:47

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review is ineligible. To be eligible to request a review, you need a paid Copilot license, or your organization must enable Copilot code review.

@WilliamSmithEdward
WilliamSmithEdward requested review from WilliamSmithEdward and removed request for WilliamSmithEdward August 2, 2026 05:54
@WilliamSmithEdward
WilliamSmithEdward merged commit 331214d into WilliamSmithEdward:main Aug 2, 2026
9 checks passed
WilliamSmithEdward added a commit that referenced this pull request Aug 2, 2026
@DecimalTurn

Copy link
Copy Markdown
Contributor Author

Thanks for the merge! I'm also thinking of adding some additional test fixtures with code inside workbook/sheet objects and events such as Workbook_Open.

If those pass, I'll include an option in VBA-Build to use this tool as the build method for Excel-VBA projects skipping Office installation.

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.

3 participants