Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
16b3f4d
Test workflow for OSGeo4W
HuidaeCho May 26, 2020
b894b70
Test workflow for OSGeo4W
HuidaeCho May 26, 2020
edcfa53
Try installing OSGeo4W
HuidaeCho May 28, 2020
37bc652
Try installing OSGeo4W
HuidaeCho May 28, 2020
87dd0b9
Try installing OSGeo4W
HuidaeCho May 28, 2020
cc90b66
Try installing OSGeo4W
HuidaeCho May 28, 2020
07346df
Try installing OSGeo4W
HuidaeCho May 28, 2020
a77b60c
Try installing OSGeo4W
HuidaeCho May 28, 2020
545cd39
Let's try configure
HuidaeCho Jun 4, 2020
77be2ba
Fix run
HuidaeCho Jun 4, 2020
08034b3
OK.. Let me use bash in MSYS2
HuidaeCho Jun 4, 2020
0faa797
Fix path to osgeo4w.sh
HuidaeCho Jun 4, 2020
d5e5ba3
Add osgeo4w.sh
HuidaeCho Jun 4, 2020
2cbc03e
Where am I?
HuidaeCho Jun 4, 2020
fa7d4dc
Pass absolute path to bash.exe
HuidaeCho Jun 4, 2020
46c6b07
Try to compile
HuidaeCho Jun 4, 2020
d39a443
Where am I again?
HuidaeCho Jun 4, 2020
efd0ba1
Happy?
HuidaeCho Jun 4, 2020
f8ae60d
CD first..?
HuidaeCho Jun 4, 2020
92cc739
nc-config may not work
HuidaeCho Jun 4, 2020
6805a5d
What?
HuidaeCho Jun 4, 2020
048f8e3
Let me check C:\OSGeo4W64
HuidaeCho Jun 4, 2020
6980310
Wait for OSGeo4W to be fully installed
HuidaeCho Jun 4, 2020
db4d930
Need to install MSYS2 packages?
HuidaeCho Jun 4, 2020
d7af4c7
Why pacman does not run
HuidaeCho Jun 4, 2020
63193de
Execute pacman directly
HuidaeCho Jun 4, 2020
4a44dd2
Execute pacman directly without confirmation
HuidaeCho Jun 4, 2020
e4771e5
nc-config just works?
HuidaeCho Jun 4, 2020
2b20fd9
Define PROJ_LIB
HuidaeCho Jun 4, 2020
458cbaa
Add test batch files
HuidaeCho Jun 4, 2020
2798394
Fix PROJ_LIB
HuidaeCho Jun 4, 2020
a4e8847
No autocrlf
HuidaeCho Jun 5, 2020
6cb23d2
Add packaging code
HuidaeCho Jun 5, 2020
9b2c5ac
Test packaging
HuidaeCho Jun 5, 2020
459b394
Test both uninstalled and packaged binaries
HuidaeCho Jun 5, 2020
c480c8c
PATH not recognized?
HuidaeCho Jun 5, 2020
2dd4065
Test PATH
HuidaeCho Jun 5, 2020
472e9b6
Test PATH
HuidaeCho Jun 5, 2020
bbc4549
Test PATH
HuidaeCho Jun 5, 2020
9e50a0c
OK, runs are separate sessions
HuidaeCho Jun 5, 2020
9d604af
OK.. batch files do not recognize $env:PATH?
HuidaeCho Jun 5, 2020
a755800
Remove trailing semi-colons
HuidaeCho Jun 5, 2020
9093e58
unix2dos batch files
HuidaeCho Jun 5, 2020
acf8bc9
Back to LF; use cmd /c
HuidaeCho Jun 5, 2020
5bc58ad
Use call instead of cmd /c
HuidaeCho Jun 5, 2020
c65727b
cmd /c works; call does not
HuidaeCho Jun 5, 2020
32dd642
Fix gunittest for Windows
HuidaeCho Jun 5, 2020
de48e5c
Relative paths not working?
HuidaeCho Jun 5, 2020
757020b
Workflow name to build and tests
HuidaeCho Jun 5, 2020
26f2a45
Fix paths
HuidaeCho Jun 6, 2020
fae13e7
Add mingw64 path
HuidaeCho Jun 6, 2020
8b559e3
Back to relative paths
HuidaeCho Jun 6, 2020
1b1001d
Use $bin instead of bin.$arch
HuidaeCho Jun 6, 2020
141d117
Just directly call grass.bat; PATH changes after each grass.bat call
HuidaeCho Jun 6, 2020
1d59764
Python encodings module test
HuidaeCho Jun 6, 2020
2a1bbfd
Avoid python3 from mingw64
HuidaeCho Jun 6, 2020
b13a7e8
MSYS2 path first for DLL dependencies
HuidaeCho Jun 6, 2020
d073630
50% success rate
HuidaeCho Jun 6, 2020
d8dd14a
Unit test encoding should be independent of the system encoding
HuidaeCho Jun 6, 2020
48e82a6
Just test packaged binaries only
HuidaeCho Jun 7, 2020
517c808
Use a non-interactive monitor for unit testing
HuidaeCho Jun 7, 2020
6af11b3
Success rate for test_thorough.bat 60%
HuidaeCho Jun 8, 2020
3a9983c
Address review comments
HuidaeCho Jun 9, 2020
16450be
Rename (src|dist)_win_esc to (src|dist)_esc
HuidaeCho Jun 21, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
143 changes: 143 additions & 0 deletions .github/workflows/build_osgeo4w.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
#!/bin/sh
#
# Usage: build_osgeo4w.sh [-p] [path]
#
# By default, the script will look for the source code in the current directory
# and create bin.x86_64-w64-mingw32\grass$ver.bat (run this batch file to start
# GRASS GIS) and dist.x86_64-w64-mingw32\etc\env.bat.
#
# -p optionally install GRASS GIS to C:\OSGeo4W64\opt\grass (run
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are the binaries downloadable somewhere? could these be used to upload for daily builds in OSGeo4W?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not at this point, but we could use GitHub artifacts to copy out the package: https://help.github.com/en/actions/configuring-and-managing-workflows/persisting-workflow-data-using-artifacts

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok.

if we're going this way later on, maybe the install scheme (now in \opt) have to be adapted to be usable in OSGeo4W?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current workflow is mainly for testing, but changing the install scheme wouldn't be a problem. I thought about that possibility too, but we already have working daily builds for Windows. Also, I wanted to create a portable package that doesn't require admin rights to install.

# C:\OSGeo4W64\opt\grass\grass$ver.bat) and create an unzippable package
# grass$ver-x86_64-w64-mingw32-osgeo4w64-$date.zip
#
# path specify a path to the source code
#

# stop on errors
set -e

if [ "$1" = "-p" ]; then
package=1
shift
else
package=0
fi

test -d "$1" && cd "$1"

osgeo4w_path=/c/OSGeo4W64
arch=x86_64-w64-mingw32
src=`pwd`

# compile

export PATH=/mingw64/bin:/c/OSGeo4W64/bin:/usr/bin
export PROJ_LIB=$osgeo4w_path/share/proj

OSGEO4W_ROOT_MSYS=$osgeo4w_path \
./configure \
--host=$arch \
--with-includes=$osgeo4w_path/include \
--with-libs="$osgeo4w_path/lib $osgeo4w_path/bin" \
--with-nls \
--with-freetype-includes=$osgeo4w_path/include/freetype2 \
--with-bzlib \
--with-geos=$src/mswindows/osgeo4w/geos-config \
--with-netcdf=$osgeo4w_path/bin/nc-config \
--with-gdal=$src/mswindows/osgeo4w/gdal-config \
--with-liblas=$src/mswindows/osgeo4w/liblas-config \
--with-opengl=windows

make

# install

bin=bin.$arch
dist=dist.$arch
ver=`sed -n '/^INST_DIR[ \t]*=/{s/^.*grass//; p}' include/Make/Platform.make`

rm -f $dist/grass$ver.tmp $dist/etc/fontcap

# create batch files

src_esc=`echo $src | sed 's#^/\([a-z]\)#\1:#; s#/#\\\\\\\\#g'`
dist_esc="$src_esc\\\\$dist"

(
sed 's/^\(set GISBASE=\).*/\1'$dist_esc'/' \
mswindows/osgeo4w/env.bat.tmpl
cat<<EOT

set PATH=C:\\msys64\\mingw64\\bin;%OSGEO4W_ROOT%\\apps\\msys\\bin;%PATH%

if not exist %GISBASE%\etc\fontcap (
pushd .
%~d0
cd %GISBASE%\lib
set GISRC=dummy
%GISBASE%\bin\g.mkfontcap.exe
popd
)
EOT
) > $dist/etc/env.bat
unix2dos $dist/etc/env.bat

(
sed -e 's/^\(call "\)%~dp0\(.*\)$/\1C:\\OSGeo4W64\\bin\2/' \
-e 's/^\(call "\).*\(\\etc\\env\.bat"\)$/\1'$dist_esc'\2/' \
-e 's/^\(.* "\)%GISBASE%\\etc\(\\grass.*\)$/\1%GISBASE%\\..\\'$bin'\2/' \
-e 's/@POSTFIX@/'$ver'/g' \
mswindows/osgeo4w/grass.bat.tmpl
) > $bin/grass$ver.bat
unix2dos $bin/grass$ver.bat

test $package -eq 0 && exit

# package

opt_path=$osgeo4w_path/opt
grass_path=$opt_path/grass

mkdir -p $opt_path
cp -a $dist $grass_path
cp -a $bin/grass$ver.py $grass_path/etc
cp -a `ldd $dist/lib/*.dll | awk '/mingw64/{print $3}' |
sort -u | grep -v 'lib\(crypto\|ssl\)'` $grass_path/lib

(
sed -e 's/^\(set GISBASE=\).*/\1%OSGEO4W_ROOT%\\opt\\grass/' \
mswindows/osgeo4w/env.bat.tmpl
cat<<EOT

set PATH=%OSGEO4W_ROOT%\\apps\\msys\\bin;%PATH%

if not exist %GISBASE%\etc\fontcap (
pushd .
%~d0
cd %GISBASE%\lib
set GISRC=dummy
%GISBASE%\bin\g.mkfontcap.exe
popd
)
EOT
) > $grass_path/etc/env.bat
unix2dos $grass_path/etc/env.bat

(
sed -e 's/^\(call "%~dp0\)\(.*\)$/\1\\..\\..\\bin\2/' \
-e 's/^\(call "%OSGEO4W_ROOT%\\\).*\(\\etc\\env\.bat"\)$/\1opt\\grass\2/' \
-e 's/@POSTFIX@/'$ver'/g' \
mswindows/osgeo4w/grass.bat.tmpl
) > $grass_path/grass$ver.bat
unix2dos $grass_path/grass$ver.bat

exit

# don't package for GitHub workflow; unnecessary

osgeo4w_basename=`basename $osgeo4w_path`
date=`date +%Y%m%d`
zip=$src/grass$ver-$arch-osgeo4w64-$date.zip

cd $osgeo4w_path/..
zip -r $zip $osgeo4w_basename -x "$osgeo4w_basename/var/*" "*/__pycache__/*"
37 changes: 37 additions & 0 deletions .github/workflows/osgeo4w.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: OSGeo4W

on:
- push
- pull_request

jobs:
build:
name: ${{ matrix.os }} build and tests

runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- windows-2019
fail-fast: false

steps:
- name: Set git to use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- uses: actions/checkout@v2
- name: Install OSGeo4W
run: |
$exe = 'osgeo4w-setup-x86_64.exe'
$url = 'http://download.osgeo.org/osgeo4w/' + $exe
(New-Object System.Net.WebClient).DownloadFile($url, $exe)
Start-Process ('.\'+$exe) -ArgumentList '-A -g -k -q -s http://download.osgeo.org/x86_64 -P cairo,fftw,freetype-devel,gdal-ecw,gdal-mrsid,liblas-devel,libxdr,msys,pdcurses,python3-numpy,python3-pywin32,python3-wx,regex-devel,wxpython,zstd-devel' -Wait
- name: Install MSYS2 packages
run: C:\msys64\usr\bin\pacman.exe --noconfirm -S tar libintl make bison diffutils git dos2unix zip mingw-w64-x86_64-toolchain mingw-w64-x86_64-cairo mingw-w64-x86_64-python3-six
- name: Compile GRASS GIS
run: C:\msys64\usr\bin\bash.exe -l (''+(Get-Location)+'\.github\workflows\build_osgeo4w.sh') -p (Get-Location)
- name: Test executing of the grass command
run: .github/workflows/test_simple.bat 'C:\OSGeo4W64\opt\grass\grass79.bat'
- name: Run tests
run: .github/workflows/test_thorough.bat 'C:\OSGeo4W64\opt\grass\grass79.bat'
3 changes: 3 additions & 0 deletions .github/workflows/test_simple.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
set grass=%1

call %grass% --tmp-location EPSG:4326 --exec g.region res=0.1 -p
6 changes: 6 additions & 0 deletions .github/workflows/test_thorough.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
set grass=%1
set python=C:\OSGeo4W64\bin\python3

call %grass% --tmp-location XY --exec g.extension g.download.location
call %grass% --tmp-location XY --exec g.download.location url=http://fatra.cnr.ncsu.edu/data/nc_spm_full_v2alpha2.tar.gz dbase=%USERPROFILE%
call %grass% --tmp-location XY --exec %python% -m grass.gunittest.main --grassdata %USERPROFILE% --location nc_spm_full_v2alpha2 --location-type nc --min-success 60
5 changes: 4 additions & 1 deletion lib/python/gunittest/case.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from grass.pygrass.modules import Module
from grass.exceptions import CalledModuleError
from grass.script import shutil_which, text_to_string, encode
from grass.script import shutil_which, text_to_string, encode, decode

from .gmodules import call_module, SimpleModule
from .checkers import (check_text_ellipsis,
Expand Down Expand Up @@ -184,6 +184,9 @@ def assertLooksLike(self, actual, reference, msg=None):

See :func:`check_text_ellipsis` for details of behavior.
"""
# actual is in the system codec while the passed reference is in utf-8;
# re-decode reference into the system codec for proper comparison
reference = decode(encode(reference, 'utf-8'))
self.assertTrue(isinstance(actual, (str, unicode)), (
'actual argument is not a string'))
self.assertTrue(isinstance(reference, (str, unicode)), (
Expand Down
11 changes: 8 additions & 3 deletions lib/python/gunittest/reporters.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,17 @@ def anonymize(self, filenames):
# besides GISBASE and test recursion start directory (which is
# supposed to be source root directory or similar) we can also try
# to remove user home directory and GISDBASE
# we suppuse that we run in standard grass session
# we suppose that we run in standard grass session
# TODO: provide more effective implementation

# regex for a trailing separator
path_end = r'[\\/]?'
for path in self._paths_to_remove:
for filename in filenames:
path_end = r'[\\/]?'
replace_in_file(filename, path + path_end, '')
# literal special characters (e.g., ^\()[]{}.*+-$) in path need
# to be escaped in a regex (2nd argument); otherwise, they will
# be interpreted as special characters
replace_in_file(filename, re.escape(path) + path_end, '')


def get_source_url(path, revision, line=None):
Expand Down
4 changes: 2 additions & 2 deletions scripts/r.blend/testsuite/test_r_blend.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ def setUpClass(cls):
"""Create maps in a small region."""
cls.use_temp_region()
cls.runModule('g.region', raster=cls.map1, flags='p')
run_command('d.mon', start='wx0')
run_command('d.mon', start='png')

@classmethod
def tearDownClass(cls):
"""Remove temporary region"""
cls.runModule('g.remove', flags='f', type='raster',
name=(cls.temp1, cls.temp2, cls.temp3))
cls.del_temp_region()
run_command('d.mon', stop='wx0')
run_command('d.mon', stop='png')

def test_blend(self):
"""blends color test"""
Expand Down