diff --git a/.github/workflows/buildTest.yml b/.github/workflows/buildTest.yml index 72c407d..4fbd899 100644 --- a/.github/workflows/buildTest.yml +++ b/.github/workflows/buildTest.yml @@ -1,14 +1,19 @@ name: build-test-XIOS -on: [push, pull_request] +on: + push: + branches: + - main + pull_request: jobs: build_test: - name: build XIOS and run tests + name: build test runs-on: ubuntu-latest strategy: matrix: - version: [XIOS/trunk@2252, XIOS2/trunk, XIOS3/trunk] + # version: [XIOS/trunk@2252, XIOS2/trunk, XIOS3/trunk] + version: [XIOS/trunk@2252, XIOS2/trunk] steps: # Check out repository branch - uses: actions/checkout@v4 @@ -42,8 +47,10 @@ jobs: run: | . arch/arch-GCC_LINUX_APT.env . arch/arch-GCC_LINUX_APT.path - export XIOS_BINDIR=$PWD/XIOS2/bin - export XIOS_INCDIR=$PWD/XIOS2/inc - export XIOS_LIBDIR=$PWD/XIOS2/lib + export XIOS_BINDIR=$PWD/XIOS/bin + export XIOS_INCDIR=$PWD/XIOS/inc + export XIOS_LIBDIR=$PWD/XIOS/lib - python3 -m unittest Discover -v -s xios_examples + export MVER=${{ matrix.version }} + + python3 -m unittest discover -v -s xios_examples diff --git a/xios_examples/read_axis_resample/test_resample_cases.py b/xios_examples/read_axis_resample/test_resample_cases.py index 5be2f56..a437086 100644 --- a/xios_examples/read_axis_resample/test_resample_cases.py +++ b/xios_examples/read_axis_resample/test_resample_cases.py @@ -4,6 +4,7 @@ import numpy as np import os import subprocess +import glob import unittest this_path = os.path.realpath(__file__) @@ -12,7 +13,7 @@ class TestResample(unittest.TestCase): """ UnitTest class to contain tests, - 1 test casce function per input `.cdl` file + 1 test case function per input `.cdl` file """ @classmethod @@ -21,14 +22,34 @@ def setUpClass(cls): First, build the fortran code only once for this class. """ - subprocess.run(['make', 'clean'], cwd=this_dir) - subprocess.run(['make'], cwd=this_dir) + subprocess.run(['make', 'clean'], cwd=this_dir, check=True) + subprocess.run(['make'], cwd=this_dir, check=True) + if os.environ.get('MVER', '') == 'XIOS3/trunk': + with open(os.path.join(this_dir, 'iodef.xml'), 'r') as ioin: + iodef_in = ioin.read() + # patch in transport protocol choice for XIOS3 + # needed for CI runners + in2 = '' + in3 = ('\n' + ' p2p') + iodef_out = iodef_in.replace(in2, in3) + with open(os.path.join(this_dir, 'iodef.xml'), 'w') as ioout: + ioout.write(iodef_out) def tearDown(self): """ - After each test function, remove the input and output netCDF files. + After each test function, + report any errors from XIOS, then + remove the input and output netCDF files. """ + + for ef in glob.glob('{}/*.err'.format(this_dir)): + print(ef) + with open(ef, 'r') as efile: + print(efile.read(), flush=True) + os.remove('{}/axis_input.nc'.format(this_dir)) os.remove('{}/axis_output.nc'.format(this_dir)) @@ -59,10 +80,11 @@ def make_a_test(inf): def test_resample(self): # create a netCDF file from the `.cdl` input subprocess.run(['ncgen', '-k', 'nc4', '-o', 'axis_input.nc', - infile], cwd=this_dir) + infile], cwd=this_dir, check=True) # run the compiled Fortran XIOS programme subprocess.run(['mpiexec', '-n', '1', './resample.exe', ':', - '-n', '1', './xios_server.exe'], cwd=this_dir) + '-n', '1', './xios_server.exe'], + cwd=this_dir, check=True) # load the result netCDF file rootgrp = netCDF4.Dataset('{}/axis_output.nc'.format(this_dir), 'r')