Skip to content

Commit

Permalink
test enable AudioTest.
Browse files Browse the repository at this point in the history
  • Loading branch information
brianhsu committed May 30, 2024
1 parent e1dde11 commit 5f8cbf6
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 20 deletions.
47 changes: 30 additions & 17 deletions .github/actions/run-unit-test/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,47 @@ name: "Run Unit Test And Coverage Report"
runs:
using: "composite"
steps:
- name: "Setup Git Information"
- name: "Show ENV"
shell: bash
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Action"
echo "========================="
echo $HOME
echo "========================="
- name: "Prepare Building Environment"
shell: bash
run: |
apt-get update -yqq
apt-get install apt-transport-https -yqq
echo "deb https://repo.scala-sbt.org/scalasbt/debian all main" | tee /etc/apt/sources.list.d/sbt.list
echo "deb https://repo.scala-sbt.org/scalasbt/debian /" | tee /etc/apt/sources.list.d/sbt_old.list
curl -sL "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x2EE0EA64E40A89B84B2DF73499E82A75642AC823" | apt-key add
apt-get update
apt-get -y install sbt
apt-get -y install xorg-dev libglu1-mesa libgl1-mesa-dev xvfb libxinerama1 libxcursor1 libswt-gtk-4-java libswt-gtk-4-jni libxml2-utils bc zip
apt-get -yq update
apt-get -yq install curl xorg-dev libglu1-mesa libgl1-mesa-dev xvfb libxinerama1 libxcursor1 libswt-gtk-4-java libswt-gtk-4-jni libxml2-utils bc zip apt-transport-https gnupg git locales-all
echo "deb https://deb.debian.org/debian unstable main non-free contrib" > /etc/apt/sources.list.d/openjdk.list
echo "deb https://repo.scala-sbt.org/scalasbt/debian all main" > /etc/apt/sources.list.d/sbt.list
echo "deb https://repo.scala-sbt.org/scalasbt/debian /" > /etc/apt/sources.list.d/sbt_old.list
curl -sL "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x2EE0EA64E40A89B84B2DF73499E82A75642AC823" | apt-key add
apt-get -yq update
apt-get -yq install openjdk-11-jdk sbt
- name: "Setup Git Information"
shell: bash
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Action"
- name: "Run Unit Test and Coverage Report"
shell: bash
run: |
./distclean
xvfb-run --auto-servernum sbt coverage test coverageAggregate
sbt "core/run"
- name: "Archive Test Reports"
uses: actions/upload-artifact@v4
with:
name: test-results
path: target/test-reports-html/
#- name: "Run Unit Test and Coverage Report"
# shell: bash
# run: |
# ./distclean
# xvfb-run --auto-servernum sbt coverage test coverageAggregate -Duser.home=/tmp/pulse-home
#- name: Archive Test Results
# if: always()
# uses: actions/upload-artifact@v4
# with:
# name: test-results
# path: target/test-reports-html/
16 changes: 16 additions & 0 deletions .github/actions/upload-testing-report/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: "Upload Testing Report"
runs:
using: "composite"
steps:
- name: 'Archive Testing Report'
shell: bash
run: |
tar -cvzf test-report.tar.gz -C target/ test-reports-html/
- name: 'Upload Testing Report to GitHub Workflow'
uses: actions/upload-artifact@v4
with:
name: test-report.tar.gz
path: test-report.tar.gz


30 changes: 28 additions & 2 deletions .github/workflows/unitTest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,40 @@ jobs:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
EXCLUDE_TEST_TAG: moe.brianhsu.AudioOutputTest
LANG: en_US.utf-8
container:
image: openjdk:11
image: debian:sid
steps:
- name: "Checkout Source Code"
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: pwd
run: |
pwd
- name: Install pulseaudio
run: |
apt-get -yq update
apt-get -yq install pulseaudio mpv alsa-utils
- name: Prepare building user
run: |
useradd -m -s /bin/bash builder
chown builder:builder -R *
- name: Start pulseaudio
run: |
runuser -l builder -c 'pulseaudio' &
- name: List sound card
run: |
runuser -l builder -c 'pactl list'
- name: Play sound file
run: |
runuser -l builder -c 'mpv ./modules/core/src/test/resources/sounds/32.wav'
- name: Unit test
uses: ./.github/actions/run-unit-test
Expand Down
12 changes: 12 additions & 0 deletions modules/core/src/main/scala/moe/brianhsu/live2d/TestAudio.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package moe.brianhsu.live2d

import javax.sound.sampled.AudioSystem

object TestAudio {
def main(args: Array[String]): Unit = {
println("Hello World")
val mixerInfo = AudioSystem.getMixerInfo().toList

println(mixerInfo)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class AudioPlayerFeature extends AnyFeatureSpec with Matchers with GivenWhenThen
Feature("Create AudioPlayer using factory") {
Scenario("Create AudioPlayer from only AudioInputStream", AudioOutputTest) {
Given("an AudioInputStream")
val audioInputStream = AudioSystem.getAudioInputStream(this.getClass.getResourceAsStream("/sounds/8.wav"))
val audioInputStream = AudioSystem.getAudioInputStream(this.getClass.getResourceAsStream("/sounds/32.wav"))

When("create an AudioPlayer using factory")
val audioPlayer = AudioPlayer(audioInputStream, 36)
Expand Down

0 comments on commit 5f8cbf6

Please sign in to comment.