Skip to content

build-and-test

build-and-test #2

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]
include:
- os: macos-12
build_system: fpm
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'
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: 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: |
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=gfortran -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 gfortran
mv gfortran_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: |
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
gfortran -std=f2008 -ffree-line-length-0 -fPIC -c $name.f90 -I ${{ env.CRYSFML_INSTALL_DIR }}/include
gfortran -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
rm *.mod
rm *.smod
- name: Run tests
run: pytest tests/ -vv