Skip to content

Commit

Permalink
GitHub actions: compile driver on Ubuntu (#1)
Browse files Browse the repository at this point in the history
Compile GDAL-GRASS driver including tests for GRASS GIS raster and vector maps.
  • Loading branch information
neteler authored May 3, 2022
1 parent fd2f34e commit 29e776c
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/apt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
gdal-bin
grass
grass-dev
libgdal-dev
libpq-dev
pkg-config
29 changes: 29 additions & 0 deletions .github/workflows/build_ubuntu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash

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

# print commands
set -x

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

# non-existent variables as an errors
set -u

# versionless in future?
GRASS=grass$(pkg-config --modversion grass | cut -d. -f1,2 | sed 's+\.++g')

export GDAL_AUTOLOAD_DIR=$1

./configure \
--prefix=/usr \
--with-autoload=${GDAL_AUTOLOAD_DIR} \
--with-grass=/usr/lib/${GRASS} \
--with-postgres-includes=$(pg_config --includedir)

make
make install
34 changes: 34 additions & 0 deletions .github/workflows/test_simple.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash

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

# print commands
set -x

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

# non-existent variables as an errors
set -u

export GDAL_AUTOLOAD_DIR=$1
export GDAL_DRIVER_PATH=${GDAL_AUTOLOAD_DIR}

# add small GRASS GIS dataset for tests
(mkdir -p $HOME/grassdata && \
cd $HOME/grassdata/ && \
wget -c --quiet https://grass.osgeo.org/sampledata/north_carolina/nc_spm_08_micro.zip && \
unzip nc_spm_08_micro.zip && \
rm -f nc_spm_08_micro.zip )

# Using LD_LIBRARY_PATH workaround for GRASS GIS < 7.8.8
export LD_LIBRARY_PATH=$(grass --config path)/lib

# test GRASS GIS raster map
gdalinfo $HOME/grassdata/nc_spm_08_micro/PERMANENT/cellhd/elevation

# test GRASS GIS vector map
ogrinfo -so -al $HOME/grassdata/nc_spm_08_micro/PERMANENT/vector/firestations/head
23 changes: 23 additions & 0 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Build on Ubuntu
on: [push]

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Get dependencies
run: |
sudo apt-get update -y
sudo apt-get install -y wget git gawk findutils
xargs -a <(awk '! /^ *(#|$)/' ".github/workflows/apt.txt") -r -- \
sudo apt-get install -y --no-install-recommends --no-install-suggests
- name: Create GDAL_AUTOLOAD directory
run: |
mkdir $HOME/gdalplugins
- name: Build
run: .github/workflows/build_ubuntu.sh $HOME/gdalplugins
- name: Test executing of GDAL with driver on GRASS maps
run: .github/workflows/test_simple.sh $HOME/gdalplugins

0 comments on commit 29e776c

Please sign in to comment.