Skip to content

Commit

Permalink
Merge pull request #128 from UiL-OTS-labs/feature/ci-windows
Browse files Browse the repository at this point in the history
Feature/ci windows
  • Loading branch information
maartenuni authored Oct 30, 2024
2 parents ba179be + d147305 commit a903a48
Show file tree
Hide file tree
Showing 8 changed files with 133 additions and 58 deletions.
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4


[meson.build]
indent_style=space
9 changes: 9 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# set the default behavior in case people don't have core.autocrlf set
* text=auto

# Explicitly declare source code files as text and to use line feed as line ending
# in CI gi-scanner tripped on files that contain crlf, it appeared, that it was
# seeing both cr and lf as lineending, hence counting both.
*.c text eol=lf
*.h text eol=lf
*.cpp text eol=lf
81 changes: 68 additions & 13 deletions .github/workflows/compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,29 @@ jobs:
buildtype: [debug, release]
runs-on: ubuntu-22.04
steps:
- name: Install apt dependencies
run: |
sudo apt-get update
# libunwind-dev is a dependency of libgstreamer1.0-dev
sudo apt-get install libglib2.0-dev libgtk-4-dev libcunit1-dev libunwind-dev
sudo apt-get install libasound-dev portaudio19-dev libboost-dev
sudo apt-get install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-bad1.0-dev gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-tools gstreamer1.0-x gstreamer1.0-alsa gstreamer1.0-gl gstreamer1.0-gtk3 gstreamer1.0-qt5 gstreamer1.0-pulseaudio
# - uses: awalsh128/cache-apt-pkgs-action@latest
# with:
# packages: libglib2.0-dev libgtk-4-dev libcunit1-dev libgstreamer1.0-dev
# version: 1.0.1
- uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: >
libglib2.0-dev
libgtk-4-dev
libcunit1-dev
libasound-dev
portaudio19-dev
libunwind-dev
libgstreamer1.0-dev
libgstreamer-plugins-good1.0-dev
libgstreamer-plugins-base1.0-dev
gstreamer1.0-plugins-good1.0-dev
gstreamer1.0-plugins-base1.0-dev
version: 1.0.5
- uses: actions/checkout@v3
- uses: actions/setup-python@v2
with:
python-version: '3.10'
cache: 'pip'
- name: Instal apt packages # for packages that don't cache nicely
run: |
sudo apt-get install libboost-all-dev
- name: Install pip packages
run: |
python3 -m pip install --upgrade pip
Expand Down Expand Up @@ -68,5 +75,53 @@ jobs:


# see https://mesonbuild.com/Continuous-Integration.html
# Compile-psylib-windows:
# runs-on: windows-latest
Compile-psylib-windows:
strategy:
matrix:
buildtype: [debug, release]
runs-on: windows-latest
defaults:
run:
shell: msys2 {0}
steps:
- uses: actions/checkout@v3
- uses: msys2/setup-msys2@v2
with:
msystem: UCRT64
update: true
install: >
git
mingw-w64-ucrt-x86_64-python
mingw-w64-ucrt-x86_64-python-pip
mingw-w64-ucrt-x86_64-toolchain
mingw-w64-ucrt-x86_64-glib2
mingw-w64-ucrt-x86_64-gstreamer
mingw-w64-ucrt-x86_64-gst-plugins-base
mingw-w64-ucrt-x86_64-gst-plugins-good
mingw-w64-ucrt-x86_64-gtk4
mingw-w64-ucrt-x86_64-libepoxy
mingw-w64-ucrt-x86_64-portaudio
mingw-w64-ucrt-x86_64-boost
mingw-w64-ucrt-x86_64-gobject-introspection
mingw-w64-ucrt-x86_64-cunit
mingw-w64-ucrt-x86_64-gi-docgen
mingw-w64-ucrt-x86_64-cmake
mingw-w64-ucrt-x86_64-meson
mingw-w64-ucrt-x86_64-ninja
mingw-w64-ucrt-x86_64-python-gobject
- name: configure
run: meson setup build --buildtype=${{matrix.buildtype}}
- name: build
run: meson compile -C build
- name: test
run: meson devenv -C build meson test
- uses: actions/upload-artifact@v4
if: '!cancelled()'
with:
name: Windows_meson_testlog-${{matrix.buildtype}}
path: build/meson-logs/
- uses: actions/upload-artifact@v4
if: '!cancelled()'
with:
name: Windows_tmp_log-${{matrix.buildtype}}
path: /tmp/psy-unit-tests
3 changes: 2 additions & 1 deletion doc/building-psylib-on-windows.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ pacboy -S glib2:p\
libepoxy:p\
portaudio:p\
boost:p\
gobject-introspection:p
gobject-introspection:p\
python-gobject:p

# optional for unit tests
pacboy -S cunit:p
Expand Down
53 changes: 17 additions & 36 deletions examples/python/meson.build
Original file line number Diff line number Diff line change
@@ -1,44 +1,33 @@


gi_typelib_path = library_build_dir
ld_library_path = library_build_dir

python3 = find_program('python3')

test(
'python-step-example',
python3,
timeout : 5,
suite : ['examples', 'python-examples'],
args : [meson.current_source_dir() + '/stepping.py'],
# env : {
# 'GI_TYPELIB_PATH' : gi_typelib_path,
# 'LD_LIBRARY_PATH' : ld_library_path
# }
if build_machine.system() != 'windows' and build_machine.system() != 'cygwin'

test(
'python-step-example',
python3,
timeout : 5,
suite : ['examples', 'python-examples'],
args : [meson.current_source_dir() + '/stepping.py'],
)

test(
'python-step-inheritance-example',
python3,
timeout : 5,
suite : ['examples', 'python-examples'],
args : [meson.current_source_dir() + '/stepping-inheritance.py'],
)

test(
'python-step-inheritance-example',
python3,
timeout : 5,
suite : ['examples', 'python-examples'],
args : [meson.current_source_dir() + '/stepping-inheritance.py'],
# env : {
# 'GI_TYPELIB_PATH' : gi_typelib_path,
# 'LD_LIBRARY_PATH' : ld_library_path
# }
)
endif

test(
'python-loop-example',
python3,
timeout : 5,
suite : ['examples', 'python-examples'],
args : [meson.current_source_dir() + '/loop.py'],
# env : {
# 'GI_TYPELIB_PATH' : gi_typelib_path,
# 'LD_LIBRARY_PATH' : ld_library_path
# }
)

test(
Expand All @@ -47,10 +36,6 @@ test(
timeout : 5,
suite : ['examples', 'python-examples'],
args : [meson.current_source_dir() + '/loop-child.py'],
# env : {
# 'GI_TYPELIB_PATH' : gi_typelib_path,
# 'LD_LIBRARY_PATH' : ld_library_path
# }
)

test(
Expand All @@ -59,8 +44,4 @@ test(
timeout : 5,
suite : ['examples', 'python-examples'],
args : [meson.current_source_dir() + '/loop-indices.py'],
# env : {
# 'GI_TYPELIB_PATH' : gi_typelib_path,
# 'LD_LIBRARY_PATH' : ld_library_path
# }
)
12 changes: 9 additions & 3 deletions tests/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,11 @@ add_suites_to_registry(void)
if (error)
return error;

#if !defined(_WIN32)
error = add_canvas_suite();
if (error)
return error;
#endif

error = add_color_suite();
if (error)
Expand All @@ -99,11 +101,11 @@ add_suites_to_registry(void)
if (error)
return error;

#if !defined(_WIN32)
error = add_gl_canvas_suite();
if (error)
return error;

#if !defined(_WIN32)
error = add_gl_utils_suite();
if (error)
return error;
Expand All @@ -117,11 +119,11 @@ add_suites_to_registry(void)
error = add_parallel_suite(g_port_num);
if (error)
return error;
#endif

error = add_picture_suite();
if (error)
return error;
#endif

error = add_queue_suite();
if (error)
Expand Down Expand Up @@ -251,8 +253,12 @@ main(int argc, char **argv)
}
}


g_object_new(
PSY_TYPE_INITIALIZER, "gstreamer", g_audio, "portaudio", g_audio);
PSY_TYPE_INITIALIZER,
"gstreamer", g_audio,
"portaudio", g_audio,
NULL);

set_save_images(g_save_images ? TRUE : FALSE);

Expand Down
4 changes: 3 additions & 1 deletion tests/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ test_timer = executable(
c_args : UNIT_PP_ARGS,
cpp_args : UNIT_PP_ARGS,
)
test('test-timer', test_timer)

# We consider the timers to perform well, when the pc is not busy otherwise
test('test-timer', test_timer, is_parallel:false)



Expand Down
19 changes: 15 additions & 4 deletions tests/test-timer2.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ static MunitResult
test_timer_fire_accurately(const MunitParameter params[], void *user_data)
{
(void) params;
gint num_correct, n_failed = 0;
TimerTestUtilities *utils = user_data;
PsyClock *clk = psy_clock_new();
PsyTimePoint *now = psy_clock_now(clk);
Expand Down Expand Up @@ -283,16 +284,26 @@ test_timer_fire_accurately(const MunitParameter params[], void *user_data)
// We expect that a timer is not fired ahead of time.
munit_assert_int64(psy_duration_get_us(time_diff), >=, 0);

// We expect that a timer is not fired too late e.g. more than one ms
#if !defined(_WIN32) // Seems unlikely in CI does seem to work in vm/pc
munit_assert_int64(psy_duration_get_us(time_diff), <, 1000);
#endif
g_info("The timer was fired at %" PRId64 " us",
psy_duration_get_us(time_diff));
if (psy_duration_get_us(time_diff) >= 1000) {
g_info("The timer was fired at %" PRId64 " us",
psy_duration_get_us(time_diff));
munit_logf(MUNIT_LOG_WARNING,
"Timer was late %lf\n",
psy_duration_get_seconds(time_diff)
);
n_failed++;
}

psy_duration_free(time_diff);
}


num_correct = NUM_TIMERS - n_failed;
gdouble percentage = (double)num_correct / NUM_TIMERS * 100;
munit_assert_double(percentage, >, 90.0);

g_ptr_array_unref(timer_data);

psy_time_point_free(now);
Expand Down

0 comments on commit a903a48

Please sign in to comment.