Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test virtual midi and playback (alsa issue) #156

Open
wants to merge 34 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
6c3afa9
test creating a virtual midi device
wang-edward Jan 19, 2025
2d355d7
add PlayTransport test
wang-edward Jan 19, 2025
48e167c
add assert that the playhead is moving
wang-edward Jan 19, 2025
94c01ad
format err messages
wang-edward Jan 19, 2025
687b8be
more test message
wang-edward Jan 19, 2025
d61e916
wrong order for test namespaces
wang-edward Jan 19, 2025
e66f08e
Merge branch 'main' into test-alsa
wang-edward Jan 19, 2025
62cf7ab
runscripts
wang-edward Jan 20, 2025
7724c72
try junit gtest
wang-edward Jan 20, 2025
5851a65
update boxtest runscript
wang-edward Jan 22, 2025
e35df6a
use ccache in local?
wang-edward Jan 22, 2025
dbe360f
fix bin path
wang-edward Jan 22, 2025
34e4ee6
log showing different results on the same program
wang-edward Jan 22, 2025
c96f2a5
fake main cmake
wang-edward Jan 22, 2025
3caaa7d
fake main
wang-edward Jan 22, 2025
487a180
comment
wang-edward Jan 22, 2025
cb49b05
run fakemain in ci
wang-edward Jan 22, 2025
58a5b49
typo
wang-edward Jan 22, 2025
1170a65
print build
wang-edward Jan 22, 2025
748f43e
seperate build and test into seperate steps
wang-edward Jan 22, 2025
1feb482
use same job, update cache
wang-edward Jan 22, 2025
ccdb11a
try fix cache key
wang-edward Jan 22, 2025
ea5ee58
it worked? print cache key and remove upload-changes
wang-edward Jan 22, 2025
8257bfc
use 2 jobs
wang-edward Jan 23, 2025
ef7d03b
name build
wang-edward Jan 23, 2025
e0d142f
download artifact
wang-edward Jan 23, 2025
53428f2
download v4
wang-edward Jan 23, 2025
bc998b2
ls
wang-edward Jan 23, 2025
3c4ff07
ls bro
wang-edward Jan 23, 2025
f9e51f8
ls build
wang-edward Jan 24, 2025
121c7a9
tree
wang-edward Jan 24, 2025
69dbb58
cmake debug
wang-edward Jan 24, 2025
a76a437
chmod
wang-edward Jan 24, 2025
6c386f6
random commit to change cmakelists hash
wang-edward Jan 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 97 additions & 41 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,81 +11,137 @@ on:

jobs:
build:
runs-on: ${{ matrix.os }}

strategy:
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
fail-fast: false

# Set up a matrix to run the following 3 configurations:
# 1. <Windows, Release, latest MSVC compiler toolchain on the default runner image, default generator>
# 2. <Linux, Release, latest GCC compiler toolchain on the default runner image, default generator>
# 3. <Linux, Release, latest Clang compiler toolchain on the default runner image, default generator>
#
# To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list.
matrix:
os: [ubuntu-22.04]
build_type: [Release]
c_compiler: [clang]
include:
- os: ubuntu-22.04
c_compiler: clang
cpp_compiler: clang++
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Install dependencies
run: |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt update
sudo apt-get install -y tree clang clang-format ccache gcc-11 g++-11 freeglut3-dev g++ libasound2-dev libcurl4-openssl-dev libfreetype6-dev libjack-jackd2-dev libx11-dev libxcomposite-dev libxcursor-dev libxinerama-dev libxrandr-dev mesa-common-dev ladspa-sdk webkit2gtk-4.0 libgtk-3-dev xvfb ninja-build libwebkit2gtk-4.1-dev
- name: Check format
sudo apt-get update
sudo apt-get install -y tree clang clang-format ccache gcc-11 g++-11 \
freeglut3-dev g++ libasound2-dev libcurl4-openssl-dev libfreetype6-dev \
libjack-jackd2-dev libx11-dev libxcomposite-dev libxcursor-dev \
libxinerama-dev libxrandr-dev mesa-common-dev ladspa-sdk \
webkit2gtk-4.0 libgtk-3-dev xvfb ninja-build libwebkit2gtk-4.1-dev

- name: Linter
run: |
clang-format --dry-run --Werror src/**/*.cc include/**/*.hh

- name: Set reusable strings
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
id: strings
shell: bash
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"

- name: Make cache dir
run: mkdir /home/runner/.ccache
- name: Cache build artifacts
run: mkdir -p /home/runner/.ccache

- name: Restore ccache
id: restore-ccache # TODO delete?
uses: actions/cache@v4
with:
path: /home/runner/.ccache
key: ${{ runner.os }}-ccache-${{ hashFiles('**/CMakeLists.txt') }}-${{ env.DOWNLOAD_CACHE_VERSION }}
restore-keys: |
${{ runner.os }}-ccache-

- name: Configure CMake
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-D CMAKE_C_COMPILER_LAUNCHER=ccache
-D CMAKE_CXX_COMPILER_LAUNCHER=ccache
-S ${{ github.workspace }}
run: |
cmake -B "${{ steps.strings.outputs.build-output-dir }}" \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-S "${{ github.workspace }}"

# 2) Build
- name: Build
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} --parallel $(nproc)
- name: Print ccache stats
id: build
run: |
# TODO option for --config Release
cmake --build ${{ steps.strings.outputs.build-output-dir }} \
--config Debug \
--parallel $(nproc)

- name: Print ccache stats (post-build)
run: |
ccache -s
ccache -p
echo "cache-key: " ${{ steps.restore-ccache.outputs.cache-key}}

- name: Upload build artifacts
if: ${{ steps.build.outcome == 'success' }}
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: |
build

tests:
runs-on: ubuntu-22.04
needs: build
steps:
# - uses: actions/checkout@v4
# with:
# submodules: recursive

- name: Install test dependencies
run: |
sudo apt-get update
sudo apt-get install -y xvfb

- name: check pwd
run: |
pwd

- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-artifacts
# The artifact will be placed in your workspace or a subfolder
# (defaults to ./build-artifacts in GITHUB_WORKSPACE).
path: build

- name: ls
run: |
ls
ls build
- name: tree
run: tree

- name: Run tests
id: test
continue-on-error: true # Allows next steps to run even if this fails
continue-on-error: true # If tests fail, we still proceed
run: |
chmod +x ./build/BoxTests_artefacts/Debug/BoxTests
set -o pipefail
xvfb-run -a --server-args="-screen 0 1280x1024x24" ./build/BoxTests 2>&1 | tee test_log.txt
xvfb-run -a --server-args="-screen 0 1280x1024x24" \
./build/BoxTests_artefacts/Debug/BoxTests 2>&1 | tee test_log.txt

- name: Upload test log
if: always() # This ensures it uploads even if the test fails
- name: Run "Fake Main" test
id: fake_main_test
continue-on-error: true
run: |
chmod +x ./build/BoxTests_artefacts/Debug/BoxTests
set -o pipefail
xvfb-run -a --server-args="-screen 0 1280x1024x24" \
./build/FakeMain_artefacts/Debug/FakeMain 2>&1 | tee fake_main_test_log.txt

- name: Upload test logs
if: always()
uses: actions/upload-artifact@v4
with:
name: test-logs
path: test_log.txt
path: |
test_log.txt
fake_main_test_log.txt

- name: Check test result
if: always()
run: |
Expand Down
50 changes: 46 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,62 @@ target_link_libraries(Box
PRIVATE
BoxLib)

# fake_main
juce_add_console_app(FakeMain
PRODUCT_NAME "FakeMain"
NEEDS_WEB_BROWSER FALSE
)
target_sources(FakeMain
PRIVATE
fake_main/fake_main.cc)
target_compile_definitions(FakeMain
PRIVATE
JUCE_WEB_BROWSER=0
JUCE_USE_CURL=0)
target_link_libraries(FakeMain
PRIVATE
BoxLib
gtest
gtest_main)

# boxtest
enable_testing()
file(GLOB_RECURSE TEST_SRC_FILES test/*.cc)
add_executable(BoxTests
${TEST_SRC_FILES})
juce_add_console_app(BoxTests
PRODUCT_NAME "BoxTests"
NEEDS_WEB_BROWSER FALSE
)
target_sources(BoxTests
PRIVATE
${TEST_SRC_FILES})
target_compile_definitions(BoxTests
PRIVATE
JUCE_WEB_BROWSER=0
JUCE_USE_CURL=0)
target_include_directories(BoxTests
PUBLIC
test)
target_link_libraries(BoxTests
PRIVATE
BoxLib
gtest
gtest
gtest_main)

file(GLOB_RECURSE JUNIT_TEST_SRC_FILES junit/*.cc)
juce_add_console_app(JunitTests
PRODUCT_NAME "JunitTests"
NEEDS_WEB_BROWSER FALSE)
target_sources(JunitTests
PRIVATE
${JUNIT_TEST_SRC_FILES})
target_compile_definitions(JunitTests
PRIVATE
JUCE_WEB_BROWSER=0
JUCE_USE_CURL=0)
target_link_libraries(JunitTests
PRIVATE
BoxLib)

# Register tests with ctest
add_test(NAME BoxTests COMMAND BoxTests)
# add_test(NAME BoxTests COMMAND BoxTests)
# set_tests_properties(BoxTests PROPERTIES CONFIGURATIONS Debug Release)
Loading
Loading