Skip to content

Add virtual audio support to CI/CD timesync-stimuli test #238

Merged
vmdocua merged 9 commits intomasterfrom
enh-ci-cd-audio
Mar 26, 2026
Merged

Add virtual audio support to CI/CD timesync-stimuli test #238
vmdocua merged 9 commits intomasterfrom
enh-ci-cd-audio

Conversation

@vmdocua
Copy link
Copy Markdown
Collaborator

@vmdocua vmdocua commented Mar 26, 2026

Previously the CI/CD timesync-stimuli test ran with --mute mode, which masked real audio issues. This was exposed during the PsychoPy 20242025 migration where audio library breakage went undetected in CI until it failed in a real environment:

This PR wires up a virtual PulseAudio null sink in xvfb mode so the test now runs with -a psychopy_sounddevice and captures actual audio output alongside the screen recording. Future audio regressions (codec changes, library incompatibilities, device initialization failures) will be caught in CI before reaching a real capture environment.

@vmdocua vmdocua self-assigned this Mar 26, 2026
@vmdocua vmdocua added enhancement New feature or request patch Increment the patch version when merged tests Add or improve existing tests labels Mar 26, 2026
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the CI/CD pipeline for the timesync-stimuli test by integrating virtual audio capabilities. This change addresses a critical gap where audio-related regressions went undetected, as highlighted by recent PsychoPy migration issues. By enabling actual audio output and recording within the virtual environment, the system can now proactively identify and prevent audio library breakages and incompatibilities before they impact real-world usage.

Highlights

  • Virtual Audio Support: Implemented a virtual PulseAudio null sink in xvfb mode for the CI/CD timesync-stimuli test, enabling actual audio output and detection of audio regressions.
  • Test Command Update: Switched the timesync-stimuli test command from --mute to -a psychopy_sounddevice to utilize the newly configured virtual audio device.
  • Combined Audio/Video Recording: Configured ffmpeg to record combined audio and video artifacts from the virtual display and audio sink, capturing a more complete representation of the test run.
  • Container Environment Integration: Ensured that the PULSE_SERVER environment variable is correctly passed to Docker and Singularity containers, facilitating communication with the virtual PulseAudio server.
  • New Task List: Added a new markdown file (.ai/task-timesync-stimuli.md) outlining future development tasks for timesync-stimuli, including unit tests and further CI/CD improvements.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/ci-cd.yml
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a task list for the timesync-stimuli project, outlining unit tests, CI/CD virtual audio support, and future work. It also implements virtual audio support for CI/CD by setting up a PulseAudio null sink in the xvfb environment and passing the PulseAudio server details to containers. This enables audio recording during CI tests. Feedback includes addressing a hardcoded video duration in the ffmpeg command and reconsidering the suppression of pulseaudio stderr output to prevent hidden errors.

echo "ffmpeg -video_size \"${FRAME_WIDTH}x${FRAME_HEIGHT}\" -framerate \"${FRAME_RATE}\" -f x11grab -i \"$DISPLAY_ID\" -t \"$VIDEO_DURATION_SEC\" -c:v libx264 -pix_fmt yuv420p \"$REPROSTIM_SCREENSHOT_PATH\""
ffmpeg -video_size "${FRAME_WIDTH}x${FRAME_HEIGHT}" -framerate "${FRAME_RATE}" -f x11grab -i "$DISPLAY_ID" -t 45 -c:v libx264 -pix_fmt yuv420p "$REPROSTIM_SCREENSHOT_PATH"
echo "ffmpeg -video_size \"${FRAME_WIDTH}x${FRAME_HEIGHT}\" -framerate \"${FRAME_RATE}\" -f x11grab -i \"$DISPLAY_ID\" ${FFMPEG_AUDIO_ARGS[*]} -t \"$VIDEO_DURATION_SEC\" -c:v libx264 -pix_fmt yuv420p \"$REPROSTIM_SCREENSHOT_PATH\""
ffmpeg -video_size "${FRAME_WIDTH}x${FRAME_HEIGHT}" -framerate "${FRAME_RATE}" -f x11grab -i "$DISPLAY_ID" "${FFMPEG_AUDIO_ARGS[@]}" -t 45 -c:v libx264 -pix_fmt yuv420p "$REPROSTIM_SCREENSHOT_PATH"
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.

high

The video recording duration is hardcoded to 45 seconds, but it should use the $VIDEO_DURATION_SEC variable defined at the top of the script for consistency and maintainability. The echo command on the preceding line correctly uses the variable, but the ffmpeg command itself does not.

Suggested change
ffmpeg -video_size "${FRAME_WIDTH}x${FRAME_HEIGHT}" -framerate "${FRAME_RATE}" -f x11grab -i "$DISPLAY_ID" "${FFMPEG_AUDIO_ARGS[@]}" -t 45 -c:v libx264 -pix_fmt yuv420p "$REPROSTIM_SCREENSHOT_PATH"
ffmpeg -video_size "${FRAME_WIDTH}x${FRAME_HEIGHT}" -framerate "${FRAME_RATE}" -f x11grab -i "$DISPLAY_ID" "${FFMPEG_AUDIO_ARGS[@]}" -t "$VIDEO_DURATION_SEC" -c:v libx264 -pix_fmt yuv420p "$REPROSTIM_SCREENSHOT_PATH"

Comment on lines +67 to +71
pulseaudio --start --exit-idle-time=-1 \
-n \
--load="module-null-sink sink_name=reprostim_sink" \
--load="module-native-protocol-unix auth-anonymous=1 socket=/tmp/reprostim_pulse.sock" \
2>/dev/null || true
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.

medium

Suppressing all stderr output with 2>/dev/null can hide important errors if pulseaudio fails to start for reasons other than it already running. This could lead to silent failures where audio is not recorded, and debugging would be difficult. Consider removing 2>/dev/null or redirecting stderr to a log file. A subsequent check to ensure the PulseAudio server is running and the sink is available would make the script more robust.

@vmdocua vmdocua marked this pull request as ready for review March 26, 2026 17:34
@vmdocua vmdocua merged commit 6bd9170 into master Mar 26, 2026
10 checks passed
@vmdocua vmdocua deleted the enh-ci-cd-audio branch March 26, 2026 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request patch Increment the patch version when merged tests Add or improve existing tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant