Skip to content

Commit

Permalink
Add windows CI (#179)
Browse files Browse the repository at this point in the history
  • Loading branch information
Benoit Coste authored May 15, 2020
1 parent 83d1fb7 commit 81da222
Show file tree
Hide file tree
Showing 12 changed files with 61 additions and 35 deletions.
15 changes: 14 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@ jobs:
CXX: g++
CC: gcc

- os: windows
language: c++
env:
- MINCONDA_VERSION="latest"
- CMAKE_GENERATOR="Visual Studio 15 2017 Win64"
- TESTS_TARGET="RUN_TESTS";
install:
- choco install --yes miniconda3
- source C:/Tools/miniconda3/Scripts/activate
- conda config --set always_yes yes --set changeps1 no
- conda update -q conda
- conda install -c conda-forge hdf5

addons:
homebrew:
packages:
Expand All @@ -32,7 +45,6 @@ addons:
packages:
- libhdf5-dev


cache:
directories:
- $HOME/.cache/pip
Expand All @@ -42,6 +54,7 @@ python:
- 3.7

install: skip

script:
- ./ci/python_test.sh
- ./ci/cpp_test.sh
4 changes: 3 additions & 1 deletion CMake/CompilerFlags.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Taken from https://github.com/BlueBrain/hpc-coding-conventions/blob/master/cpp/cmake/bob.cmake#L192-L255
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if (WIN32)
set(FLAGS "${FLAGS} /DH5_BUILT_AS_DYNAMIC_LIB /EHsc /D_USE_MATH_DEFINES")
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if(${PROJECT_NAME}_CXX_WARNINGS)
set(FLAGS "${FLAGS} -Werror -Weverything")
# Using std=c++11, no need for 98 compat
Expand Down
8 changes: 4 additions & 4 deletions ci/cpp_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set -euxo pipefail

rm -rf build
mkdir build
cd build
cmake .. -DMorphIO_CXX_WARNINGS=ON
make -j2
make test
pushd build
cmake -DMorphIO_CXX_WARNINGS=ON -G "${CMAKE_GENERATOR:-Unix Makefiles}" ..
cmake --build .
popd
21 changes: 11 additions & 10 deletions ci/python_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,22 @@ set -euxo pipefail

VENV=env

rm -rf "$VENV"
python3 -mvenv "$VENV"
if [[ "$OSTYPE" != "msys" ]]; then
rm -rf "$VENV"
python3 -mvenv "$VENV"

set +u # ignore errors in virtualenv's activate
source "$VENV/bin/activate"
set -u
set +u # ignore errors in virtualenv's activate
source "$VENV/bin/activate"
set -u

which pip
which pip

pip install --upgrade pip setuptools

# install
pip install -vvv .
pip install --upgrade pip setuptools
fi

pip install .
pip install -r tests/requirement_tests.txt

CURRENT=$(pwd)

cd ..
Expand Down
5 changes: 2 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,8 @@ def build_extension(self, ext, cmake):
cmake_args += ['-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_{}={}'.format(
cfg.upper(),
extdir)]
if sys.maxsize > 2**32:
cmake_args += ['-A', 'x64']
build_args += ['--', '/m']
cmake_args += ['-G', os.getenv('MORPHIO_CMAKE_GENERATOR',
"Visual Studio 15 2017 Win64")]
else:
cmake_args += ['-DCMAKE_BUILD_TYPE={}'.format(cfg),
'-DMorphIO_CXX_WARNINGS=OFF',
Expand Down
17 changes: 10 additions & 7 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,19 @@ set_target_properties(morphio_obj
CXX_EXTENSIONS NO
)

target_compile_options(morphio_obj
PRIVATE
-Wall
-Wextra
-Wnon-virtual-dtor
-pedantic
)
if (NOT WIN32)
target_compile_options(morphio_obj
PRIVATE
-Wall
-Wextra
-Wnon-virtual-dtor
-pedantic
)
endif()

add_library(morphio_static STATIC $<TARGET_OBJECTS:morphio_obj>)
add_library(morphio_shared SHARED $<TARGET_OBJECTS:morphio_obj>)

set_target_properties(morphio_shared PROPERTIES OUTPUT_NAME "morphio"
EXPORT_NAME "morphio")

Expand Down
2 changes: 1 addition & 1 deletion src/morphology.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ std::vector<Section> Morphology::sections() const {
std::vector<Section> sections_;
auto count = _properties->get<morphio::Property::Section>().size();
sections_.reserve(count);
for (uint i = 0; i < count; ++i) {
for (unsigned int i = 0; i < count; ++i) {
sections_.emplace_back(section(i));
}
return sections_;
Expand Down
5 changes: 5 additions & 0 deletions src/vasc/vasculature.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#include <cstdint> // uint32_t
#if defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER) || defined(__MINGW32__)
#define F_OK 0
#include <io.h>
#else
#include <unistd.h> // access / F_OK
#endif

#include <morphio/vasc/section.h>
#include <morphio/vasc/vasculature.h>
Expand Down
1 change: 1 addition & 0 deletions src/vector_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <numeric> // std::accumulate
#include <sstream> // std::stringstream
#include <string> // std::string
#include <cctype> // std::tolower

#include <morphio/types.h>

Expand Down
2 changes: 1 addition & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ set_target_properties(unittests
)

target_link_libraries(unittests
PRIVATE morphio_shared HighFive
PRIVATE morphio_static HighFive
)

add_test(NAME unittests
Expand Down
12 changes: 6 additions & 6 deletions tests/test_1_swc.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ def test_read_single_neurite():
3 3 0 0 3 0.5 2
4 3 0 0 4 0.5 3
5 3 0 0 5 0.5 4''') as tmp_file:

n = Morphology(tmp_file.name)

assert_array_equal(n.soma.points, [[0, 4, 0]])
Expand Down Expand Up @@ -320,10 +319,10 @@ def test_disconnected_neurite():
with ostream_redirect(stdout=True, stderr=True):
n = Morphology(os.path.join(_path, 'disconnected_neurite.swc'))
assert_equal(
_path + '''/disconnected_neurite.swc:10:warning
'''{}:10:warning
Warning: found a disconnected neurite.
Neurites are not supposed to have parentId: -1
(although this is normal if this neuron has no soma)''',
(although this is normal if this neuron has no soma)'''.format(os.path.join(_path, 'disconnected_neurite.swc')),
strip_color_codes(err.getvalue().strip()))

def test_neurite_wrong_root_point():
Expand All @@ -338,12 +337,13 @@ def test_neurite_wrong_root_point():

with captured_output() as (_, err):
with ostream_redirect(stdout=True, stderr=True):
n = Morphology(os.path.join(_path, 'neurite_wrong_root_point.swc'))
path = os.path.join(_path, 'neurite_wrong_root_point.swc')
n = Morphology(path)
assert_string_equal(
'''Warning: with a 3 points soma, neurites must be connected to the first soma point:
{}/neurite_wrong_root_point.swc:4:warning
{}:4:warning
{}/neurite_wrong_root_point.swc:6:warning'''.format(_path, _path),
{}:6:warning'''.format(path, path),
err.getvalue())
assert_equal(len(n.root_sections), 2)
assert_array_equal(n.root_sections[0].points,
Expand Down
4 changes: 3 additions & 1 deletion tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ def ignored_warning(warning):

@contextmanager
def _tmp_file(content, extension):
with tempfile.NamedTemporaryFile(suffix='.' + extension, mode='w') as tmp_file:
with tempfile.NamedTemporaryFile(suffix='.' + extension, mode='w', delete=False) as tmp_file:
tmp_file.write(content)
tmp_file.seek(0)
tmp_file.close()

yield tmp_file


Expand Down

0 comments on commit 81da222

Please sign in to comment.