Skip to content

Commit

Permalink
Add CI with build and test (#205)
Browse files Browse the repository at this point in the history
This adds a new set of scripts for build, i.e., it does not use the current build script because they mix 6 and 7 and are not parametrized enough.

The build also does not return non-zero in case of failure. Specifically, the make step does not return non-zero in case of failure because module failure is not counted as overall failure. (This does not go well with GitHub Actions or Travis style CI).

To avoid problems with getting the right Python package version combo, version is not required in the requirements.txt file. (This may need to be addressed in the future.)

There is only a small number of tests, i.e., the test coverage is small, but they are running now. However, most of the tests are failing. (Many can be probably fixed by reviewing the datasets used.)
  • Loading branch information
wenzeslaus committed Jun 19, 2020
1 parent d422fa9 commit 3d73a40
Show file tree
Hide file tree
Showing 5 changed files with 166 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/apt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
bison
build-essential
flex
libbz2-dev
libcairo-dev
libfftw3-dev
libgdal-dev
libgl1-mesa-dev
libglu1-mesa-dev
libnetcdf-dev
libopenblas-dev
libpng-dev
libproj-dev
libreadline-dev
libzstd-dev
sqlite3
subversion
zlib1g-dev
42 changes: 42 additions & 0 deletions .github/workflows/build_grass.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash

# The make step requires something like:
# export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$PREFIX/lib"
# further steps additionally require:
# export PATH="$PATH:$PREFIX/bin"

# fail on non-zero return code from a subprocess
set -e

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

export INSTALL_PREFIX=$1

# GRASS GIS

./configure \
--prefix="$INSTALL_PREFIX/" \
--enable-largefile \
--with-cxx \
--with-zstd \
--with-bzlib \
--with-blas \
--with-lapack \
--with-readline \
--with-openmp \
--with-pthread \
--with-tiff \
--with-freetype \
--with-freetype-includes="/usr/include/freetype2/" \
--with-proj-share=/usr/share/proj \
--with-geos \
--with-sqlite \
--with-fftw \
--with-netcdf

make
make install
88 changes: 88 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Build and test

on:
push:
pull_request:
schedule:
# 01:00 Pacific Time (in UTC), every day (late night PT)
- cron: '0 8 * * *'

jobs:
build:
name: ${{ matrix.grass_version }}

runs-on: ubuntu-18.04

strategy:
matrix:
grass_version:
- master
- releasebranch_7_8
fail-fast: false

steps:

- name: Checkout addons
uses: actions/checkout@v2
with:
repository: OSGeo/grass
ref: ${{ matrix.grass_version }}
path: grass

- name: Checkout core
uses: actions/checkout@v2
with:
path: grass-addons

- name: Get dependencies
run: |
sudo apt-get update -y
sudo apt-get install -y wget git gawk findutils
xargs -a <(awk '! /^ *(#|$)/' "grass-addons/.github/workflows/apt.txt") -r -- \
sudo apt-get install -y --no-install-recommends --no-install-suggests
- name: Set up Python 3 as default Python
uses: actions/setup-python@v2
with:
python-version: 3.6

- name: Get Python dependencies
run: |
python -m pip install --upgrade pip
pip install -r grass-addons/.github/workflows/requirements.txt
- name: Create installation directory
run: |
mkdir $HOME/install
- name: Set number of cores for compilation
run: |
echo "::set-env name=MAKEFLAGS::-j$(nproc)"
- name: Set LD_LIBRARY_PATH for GRASS GIS compilation
run: |
echo "::set-env name=LD_LIBRARY_PATH::$HOME/install/lib"
- name: Build GRASS GIS core
run: |
cd grass
../grass-addons/.github/workflows/build_grass.sh $HOME/install
- name: Add the bin directory to PATH
run: |
echo "::add-path::$HOME/install/bin"
- name: Make simple grass command available
run: |
ln -s $HOME/install/bin/grass* $HOME/install/bin/grass
- name: Build addons
run: |
cd grass-addons/grass7
GRASS_INSTALL=$HOME/install/grass*
make MODULE_TOPDIR=$GRASS_INSTALL
- name: Run tests
run: |
cd grass-addons/grass7
../.github/workflows/test.sh
4 changes: 4 additions & 0 deletions .github/workflows/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
matplotlib
numpy
scipy
six
14 changes: 14 additions & 0 deletions .github/workflows/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

# fail on non-zero return code from a subprocess
set -e

grass --tmp-location XY --exec \
g.extension g.download.location
grass --tmp-location XY --exec \
g.download.location url=http://fatra.cnr.ncsu.edu/data/nc_spm_full_v2alpha2.tar.gz dbase=$HOME

grass --tmp-location XY --exec \
python3 -m grass.gunittest.main \
--grassdata $HOME --location nc_spm_full_v2alpha2 --location-type nc \
--min-success 30

0 comments on commit 3d73a40

Please sign in to comment.