Skip to content

build-and-test

build-and-test #7

Workflow file for this run

name: main
on:
push:
schedule:
- cron: '*/60 8-18 * * *' # every 1 hour from 8:00 to 18:00 every day
env:
PROJECTS_DIR: $GITHUB_WORKSPACE
CRYSFML_PROJECT: CrysFML2008
PYCRYSFML_PROJECT: PyCrysFML08
CRYSFML_INSTALL_DIR: $PROJECTS_DIR/${CRYSFML_PROJECT}_install
PYCRYSFML_INSTALL_DIR: $PROJECTS_DIR/${PYCRYSFML_PROJECT}_install
jobs:
main:
timeout-minutes: 30
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, macos-12] # [ubuntu-22.04, macos-12, windows-2022]
build_system: [cmake] # [cmake, fpm]
compiler: [gfortran] # [gfortran, ifx]
include:
- os: macos-12
build_system: fpm
compiler: gfortran
- os: ubuntu-22.04
build_system: cmake
compiler: ifx
steps:
- name: Check-out repository
uses: actions/checkout@v3
- name: Set up Python environment
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Upgrade PIP
run: python -m pip install --upgrade pip
- name: Declare OS-specific env variables (macOS)
if: runner.os == 'macOS'
shell: bash
run: |
echo "LIBPYTHON=-L/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/config-3.11-darwin -lpython3.11" >> $GITHUB_ENV
echo "MACOSX_DEPLOYMENT_TARGET=$(sw_vers -productVersion)" >> $GITHUB_ENV # needed because of `brew reinstall gcc`
- name: Declare OS-independent env variables
shell: bash
run: |
echo "PROJECTS_DIR=$GITHUB_WORKSPACE" >> $GITHUB_ENV
echo "CRYSFML_PROJECT=CrysFML2008" >> $GITHUB_ENV
echo "PYCRYSFML_PROJECT=PyCrysFML08" >> $GITHUB_ENV
echo "CRYSFML_INSTALL_DIR=${{ env.PROJECTS_DIR }}/${{ env.CRYSFML_PROJECT }}_install" >> $GITHUB_ENV
echo "PYCRYSFML_INSTALL_DIR=${{ env.PROJECTS_DIR }}/${{ env.PYCRYSFML_PROJECT }}_install" >> $GITHUB_ENV
- name: Install Python dependences
run: python -m pip install numpy pytest deepdiff
- name: Install OS-specific dependences (macOS)
if: runner.os == 'macOS' && matrix.compiler == 'gfortran'
run: |
brew reinstall gcc # to add gfortran
gfortran --version
brew tap fortran-lang/homebrew-fortran
brew install fpm
fpm --version
- name: Install OS-specific dependences (Linux + FPM)
if: runner.os == 'Linux' && matrix.build_system == 'fpm'
run: |
sudo apt-get install ruby ruby-dev rubygems build-essential # needed for FPM
sudo gem install fpm # FPM
fpm --version
- name: Install OS-specific dependences (Linux + ifx)
if: runner.os == 'Linux' && matrix.compiler == 'ifx'
run: |
curl -Lo- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB | sudo gpg --dearmor -o /usr/share/keyrings/oneapi-archive-keyring.gpg
sudo tee /etc/apt/sources.list.d/oneAPI.list <<< "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main"
sudo apt update
sudo apt install intel-oneapi-compiler-fortran
source /opt/intel/oneapi/setvars.sh > /dev/null
ifx --version
- name: Download CrysFML (fpm_macos branch)
run: git clone --single-branch --branch fpm_macos https://code.ill.fr/rodriguez-carvajal/${{ env.CRYSFML_PROJECT }}.git
- name: Build CrysFML using CMake
if: matrix.build_system == 'cmake'
run: |
if [[ '${{ runner.os }}' == 'Linux' && '${{ matrix.compiler }}' == 'ifx' ]]; then
source /opt/intel/oneapi/setvars.sh > /dev/null
fi
cd ${{ env.PROJECTS_DIR }}/${{ env.CRYSFML_PROJECT }}
mkdir build
cd build
cmake -D ARCH32=OFF -D PYTHON_API=OFF -D CMAKE_BUILD_TYPE=Debug -D CMAKE_Fortran_COMPILER=${{ matrix.compiler }} -D CMAKE_INSTALL_PREFIX=${{ env.CRYSFML_INSTALL_DIR }} ..
cmake --build . -- -j
cmake --install .
- name: Build CrysFML using FPM
if: matrix.build_system == 'fpm'
run: |
cd ${{ env.PROJECTS_DIR }}/${{ env.CRYSFML_PROJECT }}
./make_CrysFML_fpm.sh ${{ matrix.compiler }}
mv ${{ matrix.compiler }}_release ${{ env.CRYSFML_INSTALL_DIR }}
- name: Download PyCrysFML (develop branch)
run: git clone --single-branch --branch develop https://code.ill.fr/scientific-software/${{ env.PYCRYSFML_PROJECT }}.git
- name: Build PyCrysFML modules one by one
run: |
if [[ '${{ runner.os }}' == 'Linux' && '${{ matrix.compiler }}' == 'ifx' ]]; then
source /opt/intel/oneapi/setvars.sh > /dev/null
COMPILER_OPTIONS=(-fpp)
elif [[ '${{ matrix.compiler }}' == 'gfortran' ]]; then
COMPILER_OPTIONS=(-cpp -std=f2008 -ffree-line-length-none)
fi
cd ${{ env.PROJECTS_DIR }}/${{ env.PYCRYSFML_PROJECT }}/src
mkdir -p ${{ env.PYCRYSFML_INSTALL_DIR }}/pycrysfml08
for name in py_cfml_metrics py_cfml_profiles py_cfml_sxtal_geom; do
${{ matrix.compiler }} ${COMPILER_OPTIONS[@]} -fPIC -c $name.f90 -I ${{ env.CRYSFML_INSTALL_DIR }}/include
${{ matrix.compiler }} -shared -o $name.so $name.o -L ${{ env.CRYSFML_INSTALL_DIR }}/lib -l CrysFML08 ${{ env.LIBPYTHON }}
mv $name.so ${{ env.PYCRYSFML_INSTALL_DIR }}/pycrysfml08
done
rm *.o *.*mod
- name: Run tests
run: pytest tests/ -vv