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

Add tests to github actions #4

Merged
merged 6 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
64 changes: 64 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Build and run tests

on:
push:
paths-ignore:
- "**/**.md"
branches: [ "main" ]
pull_request:
paths-ignore:
- "**/**.md"
branches: [ "main" ]

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

strategy:
fail-fast: true

matrix:
os: [ubuntu-latest, ubuntu-22.04-arm64]
build_type: [Release]
c_compiler: [gcc]
include:
- os: ubuntu-latest
c_compiler: gcc
cpp_compiler: g++
- os: ubuntu-22.04-arm64
c_compiler: gcc
cpp_compiler: g++

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

- 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: Install libsndfile (for tests)
run: |
sudo apt install libsndfile1-dev

- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
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 }}
-DLOUDNESS_ENABLE_TESTS=ON
-S ${{ github.workspace }}

- name: Build
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} --target loudness_tests

- name: Test
working-directory: ${{ steps.strings.outputs.build-output-dir }}/test
run: ctest --build-config ${{ matrix.build_type }}
9 changes: 3 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ add_subdirectory(vendor)
add_subdirectory(src)

if(LOUDNESS_ENABLE_TESTS)
message(STATUS "building tests!")
add_subdirectory(test)
else()
message(STATUS "not building tests, set LOUDNESS_ENABLE_TESTS to ON to enable")
endif()


Expand All @@ -22,9 +25,3 @@ if(BUILD_SHARED_LIBS)
else()
message(STATUS "Building static library")
endif()

if(LOUDNESS_ENABLE_TESTS)
message(STATUS "building tests!")
else()
message(STATUS "not building tests, set ENABLE_TESTS to ON to enable")
endif()
1 change: 1 addition & 0 deletions src/loudness/interpolator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include <cmath>
#include <numeric>
#include <span>
#include <vector>

#include "loudness/utils.hpp"
Expand Down
2 changes: 2 additions & 0 deletions src/loudness/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class ScopedFTZ {
};

#elif defined(__ARM_ARCH)
#include <cstdint>

class ScopedFTZ {
public:
ScopedFTZ() noexcept
Expand Down
4 changes: 4 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,7 @@ target_sources(loudness_tests
target_link_libraries(loudness_tests PRIVATE Catch2::Catch2WithMain loudness)
target_link_libraries(loudness_tests PRIVATE sndfile)
target_compile_definitions(loudness_tests PRIVATE TEST_DIR="${CMAKE_SOURCE_DIR}/test/")
list(APPEND CMAKE_MODULE_PATH ${catch2_SOURCE_DIR}/extras)
include(CTest)
include(Catch)
catch_discover_tests(loudness_tests)