Skip to content

Commit

Permalink
check audio setup
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanCheshire committed Jun 30, 2024
1 parent 246d14a commit 422acc7
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 64 deletions.
94 changes: 30 additions & 64 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
name: Gradle build and test
name: Java Audio Setup Check

on:
push:
branches:
- main
workflow_dispatch:

jobs:
build:
check-audio:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}

steps:
Expand All @@ -22,92 +24,56 @@ jobs:
java-version: '17.0.6'
distribution: 'temurin'

- name: Set up Chrome
uses: browser-actions/setup-chrome@v1
with:
chrome-version: latest

- name: Set up ChromeDriver
uses: nanasess/setup-chromedriver@v1
with:
chromedriver-version: '114.0.5735.90'

- name: Grant execute permission for gradlew (Unix)
if: runner.os != 'Windows'
run: chmod +x gradlew

- name: Build Gradle Wrapper
run: ./gradlew wrapper --gradle-version 7.4

- name: Run setup and tests on Ubuntu
- name: Install PulseAudio on Ubuntu
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y ffmpeg pulseaudio xvfb alsa-utils
sudo apt-get install -y pulseaudio alsa-utils xvfb
pulseaudio --check || pulseaudio --start
pactl load-module module-null-sink sink_name=vspeaker sink_properties=device.description=virtual_speaker
pactl load-module module-remap-source master=vspeaker.monitor source_name=vmic source_properties=device.description=virtual_mic
Xvfb :99 -screen 0 1024x768x24 &
sleep 5 # Wait for Xvfb and PulseAudio to start
sleep 5
export DISPLAY=:99
# Check the status of PulseAudio
pulseaudio --check
pactl list modules
aplay -l
./gradlew clean build test --info --stacktrace --no-daemon
env:
IP_KEY: ${{ secrets.IP_KEY }}
pactl list modules
- name: Run setup and tests on macOS
- name: Install BlackHole on macOS
if: matrix.os == 'macos-latest'
run: |
brew update
brew install ffmpeg
brew install --cask blackhole-2ch
brew install blackhole-2ch
sudo mkdir -p /Library/Audio/Plug-Ins/HAL/BlackHole.driver
sudo cp -R /usr/local/Cellar/blackhole/0.6.0/BlackHole.driver /Library/Audio/Plug-Ins/HAL/
sudo launchctl kickstart -kp system/com.apple.audio.coreaudiod
python3 -m venv venv
source venv/bin/activate
pip install mutagen
./gradlew clean build test --info --stacktrace --no-daemon
env:
IP_KEY: ${{ secrets.IP_KEY }}
- name: Install Windows SDK for signtool
- name: Install Scream on Windows
if: matrix.os == 'windows-latest'
run: |
choco install windows-sdk-10.1
shell: powershell

- name: Run setup and tests on Windows
if: matrix.os == 'windows-latest'
run: |
choco install ffmpeg python
python -m pip install --upgrade pip
pip install mutagen
Invoke-WebRequest https://github.com/duncanthrax/scream/releases/download/4.0/Scream4.0.zip -OutFile Scream4.0.zip
Expand-Archive -Path Scream4.0.zip -DestinationPath Scream
openssl req -batch -verbose -x509 -newkey rsa -keyout ScreamCertificate.pvk -out ScreamCertificate.cer -nodes -extensions v3_req
openssl pkcs12 -export -nodes -in ScreamCertificate.cer -inkey ScreamCertificate.pvk -out ScreamCertificate.pfx -passout pass:
# Add the path to signtool
- name: Setup MSVC Dev Cmd
if: matrix.os == 'windows-latest'
uses: ilammy/msvc-dev-cmd@v1

- name: Sign and Install Scream Driver on Windows
if: matrix.os == 'windows-latest'
shell: powershell
run: |
$env:PATH += ';C:\Program Files (x86)\Windows Kits\10\bin\x64'
signtool sign /v /fd SHA256 /f ScreamCertificate.pfx Scream\Install\driver\x64\Scream.cat
Import-Certificate -FilePath ScreamCertificate.cer -CertStoreLocation Cert:\LocalMachine\root
Import-Certificate -FilePath ScreamCertificate.cer -CertStoreLocation Cert:\LocalMachine\TrustedPublisher
Scream\Install\helpers\devcon-x64.exe install Scream\Install\driver\x64\Scream.inf *Scream
net start audiosrv
./gradlew clean build test --info --stacktrace --no-daemon
env:
IP_KEY: ${{ secrets.IP_KEY }}
shell: powershell
timeout-minutes: 5

- name: Generate code coverage with JaCoCo
run: ./gradlew jacocoTestReport
env:
IP_KEY: ${{ secrets.IP_KEY }}
- name: Start Windows Audio Service
if: matrix.os == 'windows-latest'
run: net start audiosrv
shell: powershell

- name: Upload Test Reports
uses: actions/upload-artifact@v2
with:
name: test-reports
path: build/reports/tests/test/
if: always()
- name: Build with Gradle and run audio setup test
run: ./gradlew clean test --tests "com.github.natche.cyderutils.audio.AudioSetupTest" --info --stacktrace --no-daemon
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.github.natche.cyderutils.audio;

import org.junit.jupiter.api.Test;

import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.Clip;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.UnsupportedAudioFileException;
import java.io.File;
import java.io.IOException;

import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.fail;

public class AudioSetupTest {

@Test
public void testAudioSystemInitialization() {
try {
File audioFile = new File("src/test/resources/test.wav");
if (!audioFile.exists()) {
fail("Audio file not found.");
}

AudioInputStream audioStream = AudioSystem.getAudioInputStream(audioFile);
Clip clip = AudioSystem.getClip();
clip.open(audioStream);
assertNotNull(clip, "Audio system initialized and clip loaded successfully.");
} catch (LineUnavailableException | UnsupportedAudioFileException | IOException e) {
e.printStackTrace();
fail("Exception details: " + e.getMessage());
} catch (Exception e) {
e.printStackTrace();
fail("Unexpected exception details: " + e.getMessage());
}
}
}

0 comments on commit 422acc7

Please sign in to comment.