Skip to content

Commit

Permalink
CI: add macOS build with tests (#2661)
Browse files Browse the repository at this point in the history
  • Loading branch information
nilason committed Dec 10, 2022
1 parent 352a038 commit a7ee9e4
Show file tree
Hide file tree
Showing 4 changed files with 243 additions and 0 deletions.
80 changes: 80 additions & 0 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
---
name: macOS
# Build and run tests on macOS

on:
push:
branches:
- main
- releasebranch_*
pull_request:
branches:
- main
- releasebranch_*
env:
CACHE_NUMBER: 0
jobs:
macos_build:
name: macOS build
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: Setup Mambaforge
uses: conda-incubator/setup-miniconda@v2
with:
channels: conda-forge
miniforge-variant: Mambaforge
miniforge-version: latest
activate-environment: grass-env
use-mamba: true
- name: Get cache date
id: get-date
run: echo "today=$(/bin/date -u '+%Y%m%d')" >> $GITHUB_OUTPUT
shell: bash
- name: Cache conda environment
uses: actions/cache@v3
with:
path: ~/miniconda3/envs/grass-env
key: conda-macos-x86_64-${{steps.get-date.outputs.today
}}-${{hashFiles('.github/workflows/macos_dependencies.txt') }}-${{
env.CACHE_NUMBER}}
id: cache
- name: Update environment
run: mamba env update -n grass-env -f .github/workflows/macos_dependencies.txt
if: steps.cache.outputs.cache-hit != 'true'
- name: Conda info
shell: bash -el {0}
run: |
conda info
conda list
conda config --show-sources
conda config --show
printenv | sort
$CC --version
- name: Create installation directory
run: mkdir $HOME/install
- name: Build and install
shell: bash -l {0}
run: source ./.github/workflows/macos_install.sh $HOME/install
- name: Add the bin directory to PATH
run: echo "$HOME/install/bin" >> $GITHUB_PATH
- name: Check installed version
shell: bash -l {0}
run: source ./.github/workflows/print_versions.sh
- name: Run tests
shell: bash -el {0}
run: >
grass --tmp-location XY --exec \
g.download.location url=https://grass.osgeo.org/sampledata/north_carolina/nc_spm_full_v2alpha2.tar.gz path=$HOME
grass --tmp-location XY --exec \
python3 -m grass.gunittest.main \
--grassdata $HOME --location nc_spm_full_v2alpha2 --location-type nc \
--min-success 100 --config .github/workflows/macos_gunittest.cfg
- name: Make HTML test report available
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: testreport-macOS
path: testreport
retention-days: 3
...
37 changes: 37 additions & 0 deletions .github/workflows/macos_dependencies.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
clang_osx-64
clangxx_osx-64
setuptools
python
python.app
numpy
gdal
freetype
cairo
matplotlib
pandoc
pillow
six
wxpython
sqlite
jpeg
libpng
libtiff
pkg-config
libiconv
fftw
lapack
blas
giflib
proj
geos
krb5
gettext
lastools
ghostscript
zstd
pdal
ply
postgresql
postgis
cmake
llvm-openmp
50 changes: 50 additions & 0 deletions .github/workflows/macos_gunittest.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
[gunittest]

# Files (or wildcard patterns) to exclude from testing separated by newline or
# space. This would be ideally empty or it would include just special cases,
# but it includes mainly tests which can (and should) be fixed.
exclude =
gui/wxpython/core/testsuite/toolboxes.sh
lib/init/testsuite/test_grass_tmp_mapset.py
python/grass/gunittest/testsuite/test_assertions_rast3d.py
python/grass/gunittest/testsuite/test_assertions_vect.py
python/grass/gunittest/testsuite/test_gmodules.py
python/grass/gunittest/testsuite/test_gunitest_doctests.py
python/grass/pygrass/raster/testsuite/test_pygrass_raster_doctests.py
python/grass/pygrass/rpc/testsuite/test_pygrass_rpc_doctests.py
python/grass/script/testsuite/test_script_doctests.py
python/grass/temporal/testsuite/unittests_temporal_raster_algebra_equal_ts.py
python/grass/temporal/testsuite/unittests_temporal_raster_conditionals_complement_else.py
raster/r.contour/testsuite/testrc.py
raster/r.in.gdal/testsuite/test_r_in_gdal.py
raster/r.in.lidar/testsuite/test_base_resolution.sh
raster/r.in.lidar/testsuite/test_base_resolution.sh
raster/r.in.pdal/testsuite/test_r_in_pdal_binning.py
raster/r.in.pdal/testsuite/test_r_in_pdal_selection.py
raster/r.terraflow/testsuite/test_r_terraflow.py
raster/r.sun/testsuite/test_rsun.py
scripts/g.extension/testsuite/test_addons_download.py
scripts/g.search.modules/testsuite/test_g_search_modules.py
temporal/t.connect/testsuite/test_distr_tgis_db_raster3d.py
temporal/t.connect/testsuite/test_distr_tgis_db_raster.py
temporal/t.connect/testsuite/test_distr_tgis_db_vector.py
temporal/t.info/testsuite/test.t.info.sh
temporal/t.rast.aggregate/testsuite/test_aggregation_relative.py
temporal/t.rast.series/testsuite/test_series.py
vector/v.db.select/testsuite/test_v_db_select.py
vector/v.in.lidar/testsuite/decimation_test.py
vector/v.in.lidar/testsuite/mask_test.py
vector/v.in.lidar/testsuite/test_v_in_lidar_basic.py
vector/v.in.lidar/testsuite/test_v_in_lidar_filter.py
vector/v.in.pdal/testsuite/test_v_in_pdal_basic.py
vector/v.in.pdal/testsuite/test_v_in_pdal_filter.py
vector/v.out.lidar/testsuite/test_v_out_lidar.py
vector/v.what/testsuite/test_vwhat_layers.py
vector/v.what/testsuite/test_vwhat_ncspm.py

# Maximum time for execution of one test file (not a test function)
# after which test is terminated (which may not terminate child processes
# from that test).
# Using 5 minutes as maximum (average test time should be much shorter,
# couple seconds per file, median should be around one second).
timeout = 300
76 changes: 76 additions & 0 deletions .github/workflows/macos_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/bin/sh

set -e

if [ -z "$1" ]; then
echo "Usage: $0 PREFIX"
exit 1
fi

# recommended in https://gitter.im/conda-forge/conda-forge.github.io?at=5c40da7f95e17b45256960ce
find ${CONDA_PREFIX}/lib -name '*.la' -delete

CONDA_ARCH=$(uname -m)
INSTALL_PREFIX=$1

CONFIGURE_FLAGS="\
--prefix=${INSTALL_PREFIX} \
--with-opengl=aqua \
--with-openmp \
--without-x \
--with-freetype \
--with-freetype-includes=${CONDA_PREFIX}/include/freetype2 \
--with-freetype-libs=${CONDA_PREFIX}/lib \
--with-gdal=${CONDA_PREFIX}/bin/gdal-config \
--with-proj-includes=${CONDA_PREFIX}/include \
--with-proj-libs=${CONDA_PREFIX}/lib \
--with-proj-share=${CONDA_PREFIX}/share/proj \
--with-geos=${CONDA_PREFIX}/bin/geos-config \
--with-libpng=${CONDA_PREFIX}/bin/libpng-config \
--with-tiff-includes=${CONDA_PREFIX}/include \
--with-tiff-libs=${CONDA_PREFIX}/lib \
--with-postgres=yes \
--with-postgres-includes=${CONDA_PREFIX}/include \
--with-postgres-libs=${CONDA_PREFIX}/lib \
--without-mysql \
--with-sqlite \
--with-sqlite-libs=${CONDA_PREFIX}/lib \
--with-sqlite-includes=${CONDA_PREFIX}/include \
--with-fftw-includes=${CONDA_PREFIX}/include \
--with-fftw-libs=${CONDA_PREFIX}/lib \
--with-cxx \
--with-cairo \
--with-cairo-includes=${CONDA_PREFIX}/include/cairo \
--with-cairo-libs=${CONDA_PREFIX}/lib \
--with-cairo-ldflags="-lcairo" \
--with-zstd \
--with-zstd-libs=${CONDA_PREFIX}/lib \
--with-zstd-includes=${CONDA_PREFIX}/include \
--with-bzlib \
--with-bzlib-libs=${CONDA_PREFIX}/lib \
--with-bzlib-includes=${CONDA_PREFIX}/include \
--with-netcdf=${CONDA_PREFIX}/bin/nc-config \
--with-blas \
--with-blas-libs=${CONDA_PREFIX}/lib \
--with-blas-includes=${CONDA_PREFIX}/include \
--with-lapack
--with-lapack-includes=${CONDA_PREFIX}/include \
--with-lapack-libs=${CONDA_PREFIX}/lib \
--with-netcdf=${CONDA_PREFIX}/bin/nc-config \
--with-nls \
--with-libs=${CONDA_PREFIX}/lib \
--with-includes=${CONDA_PREFIX}/include \
--with-pdal=${CONDA_PREFIX}/bin/pdal-config \
--with-readline \
--with-readline-includes=${CONDA_PREFIX}/include/readline \
--with-readline-libs=${CONDA_PREFIX}/lib
"

export CFLAGS="-O2 -pipe -arch ${CONDA_ARCH} -DGL_SILENCE_DEPRECATION -Wall"
export CXXFLAGS="-O2 -pipe -stdlib=libc++ -arch ${CONDA_ARCH} -Wall"

./configure $CONFIGURE_FLAGS

make -j$(sysctl -n hw.ncpu) CFLAGS="$CFLAGS -Werror" CXXFLAGS="$CXXFLAGS -Werror"

make install

0 comments on commit a7ee9e4

Please sign in to comment.