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

use GH Actions #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
52 changes: 52 additions & 0 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Actions

on:
push:
branches: [master]
pull_request:
branches: [master]

env:
BUILD_TYPE: Release

jobs:
linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install dependencies
run: sudo apt-get install cmake g++
- name: Configure CMake
run: cmake -S . -B build -DMIDIFILE_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
- name: Build project
run: cmake --build build
- name: Run tests
run: ./build/midifile_test

windows:
runs-on: windows-2019
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Configure CMake
run: cmake -S . -B build -DMIDIFILE_BUILD_TESTS=ON -G "Visual Studio 16 2019" -A x64
- name: Build project
run: cmake --build build --config ${{env.BUILD_TYPE}}
- name: Run tests
run: ./build/${{env.BUILD_TYPE}}/midifile_test.exe

macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Configure CMake
run: cmake -S . -B build -DMIDIFILE_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
- name: Build project
run: cmake --build build
- name: Run tests
run: ./build/midifile_test
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@

.*
!.gitignore
_site
temp
Expand Down Expand Up @@ -27,3 +25,5 @@ err
*.idb
*.ilk
*.opendb
build*
.DS_Store
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "Catch2"]
path = external_libraries/Catch2
url = https://github.com/catchorg/Catch2.git
branch = v3.x
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 3.1)

project(midifile C CXX)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

include(CheckIncludeFiles)
Expand All @@ -19,7 +19,7 @@ check_include_files(sys/io.h HAVE_SYS_IO_H)
##

if(APPLE)
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "Minimum OS X deployment version")
set(CMAKE_OSX_DEPLOYMENT_TARGET "12" CACHE STRING "Minimum OS X deployment version")
endif()

if(MSVC)
Expand Down
46 changes: 46 additions & 0 deletions test/test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#include <sstream>
#include <vector>
#include <tuple>

#define CATCH_CONFIG_MAIN
#include "catch2/catch.hpp"

#include "MidiFile.h"

TEST_CASE("Writing and reading an empty MIDI file works") {
smf::MidiFile midifile1;
REQUIRE(midifile1.size() == 1);
std::stringstream stream;
midifile1.write(stream);
REQUIRE(midifile1.status());
smf::MidiFile midifile2;
midifile2.read(stream);
REQUIRE(midifile2.size() == 1);
REQUIRE(midifile2.status());
}

TEST_CASE("Writing and reading a MIDI file with note on and note off messages works") {
smf::MidiFile midifile1;

std::vector<uint8_t> noteOnMessage = { 0x90, 0x3c, 0x7F };
smf::MidiEvent noteOn(0, 1, noteOnMessage);
std::vector<uint8_t> noteOffMessage = { 0x80, 0x3c, 0x7F };
smf::MidiEvent noteOff(100, 1, noteOffMessage);
std::vector<uint8_t> trackEndMessage = { 0xFF, 0x2F, 0x00 };
smf::MidiEvent trackEnd(200, 1, trackEndMessage);
midifile1[0].push_back(noteOn);
midifile1[0].push_back(noteOff);
midifile1[0].push_back(trackEnd);

std::stringstream stream;
midifile1.write(stream);
REQUIRE(midifile1.status());
smf::MidiFile midifile2;
midifile2.read(stream);

REQUIRE(midifile1.size() == midifile2.size());
REQUIRE(midifile1[0].size() == midifile2[0].size());
for (int i = 0; i < midifile1[0].size(); i++) {
REQUIRE(midifile1[0][i] == midifile2[0][i]);
}
}
Loading