Skip to content

Commit

Permalink
Merge pull request #326 from saraedum/macos
Browse files Browse the repository at this point in the history
Run tests on macOS in CI
  • Loading branch information
saraedum committed Jan 10, 2024
2 parents 4784e94 + 2152f09 commit edfbc0f
Show file tree
Hide file tree
Showing 27 changed files with 180 additions and 71 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:

jobs:
asv:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
with:
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@ jobs:
uses: flatsurf/actions/conda-forge-build@main
with:
recipe: libflatsurf/recipe
channels: flatsurf
- name: Build pyflatsurf
uses: flatsurf/actions/conda-forge-build@main
with:
recipe: pyflatsurf/recipe
channels: flatsurf
- uses: actions/upload-artifact@v2
with:
name: conda-packages
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ concurrency:

jobs:
codecov:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
with: { submodules: recursive, fetch-depth: 0 }
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ concurrency:

jobs:
clang-format:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: DoozyX/clang-format-lint-action@v0.11
Expand Down
59 changes: 47 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,27 @@ concurrency:

jobs:
test-libflatsurf:
runs-on: ubuntu-20.04
runs-on: ${{ matrix.on }}
strategy:
matrix:
include:
- target: check
- on: ubuntu-22.04
target: check
libflint: '2'
- target: check
- on: ubuntu-22.04
target: check
libflint: '3'
- target: check-valgrind
- on: macos-11
target: check
libflint: '2'
- target: check-valgrind
- on: macos-11
target: check
libflint: '3'
- on: ubuntu-22.04
target: check-valgrind
libflint: '2'
- on: ubuntu-22.04
target: check-valgrind
libflint: '3'
steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -62,24 +72,45 @@ jobs:
- uses: flatsurf/actions/show-logs@main
if: ${{ always() }}
test-pyflatsurf:
runs-on: ubuntu-20.04
runs-on: ${{ matrix.on }}
strategy:
matrix:
include:
# No released SageMath supports FLINT 3 yet. So we only test with FLINT 2.
- python: "3.8"
- on: macos-11
python: "3.8"
libflint: "2"
target: check
- on: macos-11
python: "3.9"
libflint: "2"
target: check
- on: macos-11
python: "3.10"
libflint: "2"
target: check
- python: "3.9"
- on: macos-11
python: "3.11"
libflint: "2"
target: check
- python: "3.10"
- on: ubuntu-22.04
python: "3.8"
libflint: "2"
target: check
- python: "3.11"
- on: ubuntu-22.04
python: "3.9"
libflint: "2"
target: check
- python: "3.11"
- on: ubuntu-22.04
python: "3.10"
libflint: "2"
target: check
- on: ubuntu-22.04
python: "3.11"
libflint: "2"
target: check
- on: ubuntu-22.04
python: "3.11"
libflint: "2"
target: check-valgrind
steps:
Expand Down Expand Up @@ -110,6 +141,10 @@ jobs:
echo "libflint ${{ matrix.libflint }}.*" >> $CONDA_PREFIX/conda-meta/pinned
mamba env update --quiet -n test -f pyflatsurf/environment.yml
conda list
- name: silence cppyy startup
shell: bash -l {0}
run: |
python -c 'import cppyy'
- name: make ${{ matrix.target }}
shell: bash -l {0}
run: |
Expand All @@ -129,7 +164,7 @@ jobs:
- uses: flatsurf/actions/show-logs@main
if: ${{ always() }}
distcheck:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
with: { submodules: recursive }
Expand Down
2 changes: 0 additions & 2 deletions asv.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,3 @@
"results_dir": ".asv/results",
"html_dir": ".asv/html"
}


3 changes: 3 additions & 0 deletions doc/news/macos.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**Fixed:**

* Fixed tests on macOS. All tests are now automatically run for macOS 11 on GitHub's CI.
1 change: 0 additions & 1 deletion libflatsurf/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
name: libflatsurf-build
channels:
- conda-forge
- defaults
dependencies:
- automake
- benchmark
Expand Down
1 change: 0 additions & 1 deletion pyflatsurf/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
name: pyflatsurf-build
channels:
- conda-forge
- defaults
dependencies:
- automake
- cppyy
Expand Down
4 changes: 3 additions & 1 deletion pyflatsurf/src/pyflatsurf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
The translation surface coming from a square::
>>> from pyflatsurf import Surface, flatsurf
>>> from pyflatsurf import Surface, flatsurf # random output # we ignore the output because cppyy produces some deprecation warnings
... # doctest: +ELLIPSIS
...
>>> R2 = flatsurf.Vector['long long']
>>> square = Surface([[1, 3, 2, -1, -3, -2]], [R2(1, 0), R2(0, 1), R2(1, 1)])
Expand Down
44 changes: 26 additions & 18 deletions pyflatsurf/test/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,38 @@ EXTRA_DIST = $(TESTS) surfaces.py

AM_TESTS_ENVIRONMENT = . $(builddir)/test-env.sh;

bound.py: test-env.sh
half_edge.py: test-env.sh
equivalence_class.py: test-env.sh surfaces.py
flat_triangulation.py: test-env.sh surfaces.py
flat_triangulation_combinatorial.py: test-env.sh surfaces.py
point.py: test-env.sh surfaces.py
saddle_connections.py: test-env.sh surfaces.py
vector_renf_elem.py: test-env.sh surfaces.py
vector_gmp.py: test-env.sh
deformation.py: test-env.sh surfaces.py
vertex.py: test-env.sh surfaces.py
python-doctest.sh: test-env.sh
sage-doctest.sh: test-env.sh
bound.py: test-env.sh bin/python
half_edge.py: test-env.sh bin/python
equivalence_class.py: test-env.sh surfaces.py bin/python
flat_triangulation.py: test-env.sh surfaces.py bin/python
flat_triangulation_combinatorial.py: test-env.sh surfaces.py bin/python
point.py: test-env.sh surfaces.py bin/python
saddle_connections.py: test-env.sh surfaces.py bin/python
vector_renf_elem.py: test-env.sh surfaces.py bin/python
vector_gmp.py: test-env.sh bin/python
deformation.py: test-env.sh surfaces.py bin/python
vertex.py: test-env.sh surfaces.py bin/python
python-doctest.sh: test-env.sh bin/python
sage-doctest.sh: test-env.sh bin/python

@VALGRIND_CHECK_RULES@

BUILT_SOURCES = test-env.sh python-doctest.sh sage-doctest.sh
EXTRA_DIST += test-env.sh.in python-doctest.sh.in sage-doctest.sh.in disable-pytest/pytest.py
CLEANFILES = test-env.sh python-doctest.sh sage-doctest.sh
BUILT_SOURCES = test-env.sh bin/python python-doctest.sh sage-doctest.sh
EXTRA_DIST += test-env.sh.in bin/python.in python-doctest.sh.in sage-doctest.sh.in disable-pytest/pytest.py
CLEANFILES = test-env.sh bin/python python-doctest.sh sage-doctest.sh

$(builddir)/bin/python: $(srcdir)/bin/python.in Makefile
mkdir -p $(builddir)/bin
sed -e 's,[@]abs_srcdir[@],$(abs_srcdir),g' -e 's,[@]abs_builddir[@],$(abs_builddir),g' -e 's,[@]pythondir[@],$(pythondir),g' < $< > $@
chmod +x $@

$(builddir)/test-env.sh: $(srcdir)/test-env.sh.in Makefile
sed -e 's,[@]abs_srcdir[@],$(abs_srcdir),g' -e 's,[@]abs_builddir[@],$(abs_builddir),g' -e 's,[@]pythondir[@],$(pythondir),g' < $< > $@

$(builddir)/python-doctest.sh: $(srcdir)/python-doctest.sh.in Makefile
sed -e 's,[@]srcdir[@],$(srcdir),g' < $< > $@
sed -e 's,[@]abs_srcdir[@],$(abs_srcdir),g' -e 's,[@]abs_builddir[@],$(abs_builddir),g' < $< > $@
chmod +x $@

$(builddir)/sage-doctest.sh: $(srcdir)/sage-doctest.sh.in Makefile
sed -e 's,[@]srcdir[@],$(srcdir),g' < $< > $@
sed -e 's,[@]abs_srcdir[@],$(abs_srcdir),g' -e 's,[@]abs_builddir[@],$(abs_builddir),g' < $< > $@
chmod +x $@
42 changes: 42 additions & 0 deletions pyflatsurf/test/bin/python.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/sh

# Run Python 3 with environment variables set so that local headers and
# libraries in this repository are used when running tests.

# Usually, one would do this setup as part of test-env.sh, i.e.,
# AM_TESTS_ENVIRONMENT. However, macOS drops DYLD_LIBRARY_PATH whenever a
# shebang is followed, so we actually need to execute the Python binary
# directly and pass a script to it as a parameter to keep DYLD_LIBRARY_PATH
# alive.

# Disable warnings on macOS with FLINT 2.8.4, see https://github.com/conda-forge/libflint-feedstock/issues/26
export EXTRA_CLING_ARGS="-Wno-macro-redefined $EXTRA_CLING_ARGS"

# Resolve #include <flatsurf/*.hpp> relative to libflatsurf in the source tree and
# resolve #include "local.h" relative to libflatsurf/flatsurf in the build tree.
export EXTRA_CLING_ARGS="-I@abs_srcdir@/../../libflatsurf -I@abs_builddir@/../../libflatsurf/flatsurf $EXTRA_CLING_ARGS"

# Load libflatsurf.so from our build tree.
export LD_LIBRARY_PATH="@abs_builddir@/../../libflatsurf/src/.libs/:$LD_LIBRARY_PATH"

# Load libflatsurf.dylib from our build tree.
export DYLD_LIBRARY_PATH="@abs_builddir@/../../libflatsurf/src/.libs/:$DYLD_LIBRARY_PATH"

# Load pyflatsurf from our source tree.
export PYTHONPATH="@abs_srcdir@/../src/:$PYTHONPATH:@pythondir@"

# Support libasan loading when our library has been built with -fsanitize=address.
if [ ! -z "$FLATSURF_LD_PRELOAD" ]; then
export LD_PRELOAD="$FLATSURF_LD_PRELOAD:$LD_PRELOAD"
fi

# Support libasan loading on macOS when our library has been built with -fsanitize=address.
if [ ! -z "$FLATSURF_DYLD_INSERT_LIBRARIES" ]; then
if [ -z "$DYLD_INSERT_LIBRARIES" ]; then
export DYLD_INSERT_LIBRARIES="$FLATSURF_DYLD_INSERT_LIBRARIES"
else
export DYLD_INSERT_LIBRARIES="$FLATSURF_DYLD_INSERT_LIBRARIES:$DYLD_INSERT_LIBRARIES"
fi
fi

exec python3 $@
2 changes: 1 addition & 1 deletion pyflatsurf/test/bound.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env python

######################################################################
# This file is part of flatsurf.
Expand Down
2 changes: 1 addition & 1 deletion pyflatsurf/test/deformation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env python

######################################################################
# This file is part of flatsurf.
Expand Down
2 changes: 1 addition & 1 deletion pyflatsurf/test/equivalence_class.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env python

######################################################################
# This file is part of flatsurf.
Expand Down
3 changes: 2 additions & 1 deletion pyflatsurf/test/flat_triangulation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python3
#!/usr/bin/env python

######################################################################
# This file is part of flatsurf.
#
Expand Down
3 changes: 2 additions & 1 deletion pyflatsurf/test/flat_triangulation_combinatorial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python3
#!/usr/bin/env python

######################################################################
# This file is part of flatsurf.
#
Expand Down
3 changes: 1 addition & 2 deletions pyflatsurf/test/flow_decomposition.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#!/usr/bin/env python

######################################################################
# This file is part of flatsurf.
Expand Down
3 changes: 1 addition & 2 deletions pyflatsurf/test/half_edge.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#!/usr/bin/env python

######################################################################
# This file is part of flatsurf.
Expand Down
2 changes: 1 addition & 1 deletion pyflatsurf/test/point.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env python

######################################################################
# This file is part of flatsurf.
Expand Down
13 changes: 9 additions & 4 deletions pyflatsurf/test/python-doctest.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
######################################################################
# This file is part of flatsurf.
#
# Copyright (C) 2019 Vincent Delecroix
# Copyright (C) 2019 Julian Rüth
# Copyright (C) 2019 Vincent Delecroix
# Copyright (C) 2019-2024 Julian Rüth
#
# flatsurf is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
Expand All @@ -22,5 +22,10 @@

set -ex

TARGETS=`grep -l '>>>' @srcdir@/../src/pyflatsurf/*.py`
pytest -vv --doctest-modules $TARGETS
# We cannot run pytest directly since it would be invoked through its shebang
# which makes macOS sanitize some environment variables. Instead, we go through
# our bin/python wrapper to set the necessary environment variables and invoke
# the Python binary to run pytest which keeps our environment intact on macOS.

IGNORE=`grep -L '>>>' @abs_srcdir@/../src/pyflatsurf/*.py | awk '{ print "--ignore=" $0 }'`
python -m pytest --verbose --doctest-modules $IGNORE '@abs_srcdir@/../src/pyflatsurf' $@
3 changes: 1 addition & 2 deletions pyflatsurf/test/saddle_connections.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#!/usr/bin/env python

######################################################################
# This file is part of flatsurf.
Expand Down

0 comments on commit edfbc0f

Please sign in to comment.