so inside bash, os.platform needs proper capitalisation #81
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: main | |
on: | |
push: | |
#schedule: | |
# - cron: '*/120 8-18 * * *' # every 2 hours from 8:00 to 18:00 every day | |
jobs: | |
main: | |
timeout-minutes: 30 | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [windows-2022] # [ubuntu-22.04, macos-12, windows-2022] | |
build_system: [cmake] # [cmake, fpm] | |
compiler: [gfortran] # [gfortran, ifort] | |
# include: | |
# - os: ubuntu-22.04 | |
# build_system: cmake | |
# compiler: ifort | |
#- os: ubuntu-22.04 | |
# build_system: fpm | |
# compiler: ifort | |
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: Set up nmake environment | |
if: runner.os == 'windows' | |
uses: ilammy/msvc-dev-cmd@v1 | |
- name: Upgrade PIP | |
run: python -m pip install --upgrade pip | |
- name: Declare env variables (independent) | |
shell: bash | |
run: | | |
echo "PROJECTS_DIR=$GITHUB_WORKSPACE" >> $GITHUB_ENV | |
echo "CRYSFML_PROJECT=crysfml08" >> $GITHUB_ENV | |
echo "PYCRYSFML_PROJECT=pycrysfml08" >> $GITHUB_ENV | |
echo "DIST_PACKAGE_NAME=pycrysfml08" >> $GITHUB_ENV | |
- name: Declare env variables (dependent) | |
shell: bash | |
run: | | |
echo "CRYSFML_REPO=${{ env.PROJECTS_DIR }}/${{ env.CRYSFML_PROJECT }}_repo" >> $GITHUB_ENV | |
echo "PYCRYSFML_REPO=${{ env.PROJECTS_DIR }}/${{ env.PYCRYSFML_PROJECT }}_repo" >> $GITHUB_ENV | |
echo "CRYSFML_BUILD=${{ env.PROJECTS_DIR }}/${{ env.CRYSFML_PROJECT }}_build" >> $GITHUB_ENV | |
echo "PYCRYSFML_BUILD=${{ env.PROJECTS_DIR }}/${{ env.PYCRYSFML_PROJECT }}_build" >> $GITHUB_ENV | |
echo "CRYSFML_DIST=${{ env.PROJECTS_DIR }}/${{ env.CRYSFML_PROJECT }}_dist" >> $GITHUB_ENV | |
echo "PYCRYSFML_DIST=${{ env.PROJECTS_DIR }}/${{ env.PYCRYSFML_PROJECT }}_dist" >> $GITHUB_ENV | |
echo "PYCRYSFML_WHEEL=${{ env.PROJECTS_DIR }}/${{ env.PYCRYSFML_PROJECT }}_wheel" >> $GITHUB_ENV | |
if [[ '${{ runner.os }}' == 'macOS' ]]; then | |
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` | |
fi | |
if [[ '${{ runner.os }}' == 'Linux' && '${{ matrix.compiler }}' == 'ifort' ]]; then | |
echo "COMPILER_OPTIONS=-fpp -fPIC" >> $GITHUB_ENV | |
elif [[ '${{ matrix.compiler }}' == 'gfortran' ]]; then | |
echo "COMPILER_OPTIONS=-cpp -std=f2008 -ffree-line-length-none -fPIC" >> $GITHUB_ENV | |
fi | |
if [[ '${{ runner.os }}' == 'Windows' ]]; then | |
echo "LIBPYTHON=${{ env.Python_ROOT_DIR }}\\libs\\python311.lib" >> $GITHUB_ENV | |
ls -l ${{ env.Python_ROOT_DIR }}\\libs | |
echo "COMPILER_OPTIONS= -std=f2008 -ffree-line-length-none -fPIC" >> $GITHUB_ENV | |
fi | |
- name: Install OS-specific dependences (macOS) | |
if: runner.os == 'macOS' && matrix.compiler == 'gfortran' | |
run: | | |
brew reinstall gcc # to add gfortran | |
gfortran --version | |
#brew install llvm # ??? OpenMP for parallel compilation in FPM | |
#brew reinstall libomp # ??? OpenMP for parallel compilation in FPM | |
- name: Install OS-specific dependences (Linux + ifort) | |
if: runner.os == 'Linux' && matrix.compiler == 'ifort' | |
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-get update | |
sudo apt-get install intel-oneapi-compiler-fortran | |
source /opt/intel/oneapi/setvars.sh | |
printenv >> $GITHUB_ENV | |
ifort --version | |
#- name: Install OS-specific dependences (Linux + ifort) | |
# if: runner.os == 'Linux' && matrix.compiler == 'ifort' | |
# run: | | |
# wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB | |
# sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB | |
# rm GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB | |
# echo "deb https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list | |
# sudo apt-get update | |
# sudo apt-get install intel-oneapi-compiler-fortran | |
# source /opt/intel/oneapi/setvars.sh | |
# printenv >> $GITHUB_ENV | |
# ifort --version | |
- name: Download CrysFML (fpm_macos branch) | |
run: git clone --single-branch --branch fpm_macos https://code.ill.fr/rodriguez-carvajal/crysfml2008.git ${{ env.CRYSFML_REPO }} | |
- name: Build CrysFML using CMake on Linux/macos | |
if: matrix.build_system == 'cmake' && (runner.os == 'Linux' || runner.os == 'macOS') | |
run: | | |
echo '### 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_DIST }} -S ${{ env.CRYSFML_REPO }} -B ${{ env.CRYSFML_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_DIST }} -S ${{ env.CRYSFML_REPO }} -B ${{ env.CRYSFML_BUILD }} | |
echo '### cmake --build ${{ env.CRYSFML_BUILD }} --parallel' | |
cmake --build ${{ env.CRYSFML_BUILD }} --parallel | |
echo '### cmake --install ${{ env.CRYSFML_BUILD }}' | |
cmake --install ${{ env.CRYSFML_BUILD }} | |
- name: Build CrysFML using CMake on Windows | |
if: matrix.build_system == 'cmake' && runner.os == 'windows' | |
run: | | |
cmake -G "NMake Makefiles" -D ARCH32=OFF -D PYTHON_API=OFF -D CMAKE_BUILD_TYPE=Debug -D CMAKE_Fortran_COMPILER=${{ matrix.compiler }} -D CMAKE_INSTALL_PREFIX=${{ env.CRYSFML_DIST }} -S ${{ env.CRYSFML_REPO }} -B ${{ env.CRYSFML_BUILD }} | |
cd ${{ env.CRYSFML_BUILD }} | |
nmake | |
nmake install | |
- name: Build CrysFML using FPM | |
if: matrix.build_system == 'fpm' | |
run: | | |
echo '# python -m pip install fpm' | |
python -m pip install fpm | |
echo '# fpm --version' | |
fpm --version | |
echo '# cd ${{ env.CRYSFML_REPO }}' | |
cd ${{ env.CRYSFML_REPO }} | |
echo '# ./make_CrysFML_fpm.sh ${{ matrix.compiler }}' | |
./make_CrysFML_fpm.sh ${{ matrix.compiler }} | |
echo '# mv ${{ matrix.compiler }}_release ${{ env.CRYSFML_DIST }}' | |
mv ${{ matrix.compiler }}_release ${{ env.CRYSFML_DIST }} | |
- name: Download PyCrysFML (develop branch) | |
run: git clone --single-branch --branch develop https://code.ill.fr/scientific-software/pycrysfml08.git ${{ env.PYCRYSFML_REPO }} | |
- name: Build PyCrysFML modules one by one (Linux/macos) | |
if: runner.os == 'Linux' || runner.os == 'macOS' | |
run: | | |
echo '### mkdir -p ${{ env.PYCRYSFML_DIST }}/${{ env.DIST_PACKAGE_NAME }}' | |
mkdir -p ${{ env.PYCRYSFML_DIST }}/${{ env.DIST_PACKAGE_NAME }} | |
echo '### cd ${{ env.PYCRYSFML_REPO }}/src' | |
cd ${{ env.PYCRYSFML_REPO }}/src | |
for name in py_cfml_metrics py_cfml_profiles py_cfml_sxtal_geom; do | |
echo "### ${{ matrix.compiler }} ${{ env.COMPILER_OPTIONS }} -c $name.f90 -I ${{ env.CRYSFML_DIST }}/include" | |
${{ matrix.compiler }} ${{ env.COMPILER_OPTIONS }} -c $name.f90 -I ${{ env.CRYSFML_DIST }}/include | |
echo "### ${{ matrix.compiler }} -shared -o $name.so $name.o -L ${{ env.CRYSFML_DIST }}/lib -l CrysFML08 ${{ env.LIBPYTHON }}" | |
${{ matrix.compiler }} -shared -o $name.so $name.o -L ${{ env.CRYSFML_DIST }}/lib -l CrysFML08 ${{ env.LIBPYTHON }} | |
echo "### mv $name.so ${{ env.PYCRYSFML_DIST }}/${{ env.DIST_PACKAGE_NAME }}" | |
mv $name.so ${{ env.PYCRYSFML_DIST }}/${{ env.DIST_PACKAGE_NAME }} | |
echo '### ls -l ${{ env.PYCRYSFML_DIST }}/${{ env.DIST_PACKAGE_NAME }}' | |
ls -l ${{ env.PYCRYSFML_DIST }}/${{ env.DIST_PACKAGE_NAME }} | |
done | |
echo "### rm *.o *.*mod" | |
rm *.o *.*mod | |
- name: Build PyCrysFML modules one by one (Windows) | |
if: runner.os == 'windows' | |
shell: cmd | |
run: | | |
mkdir -p ${{ env.PYCRYSFML_DIST }}/${{ env.DIST_PACKAGE_NAME }} | |
cd ${{ env.PYCRYSFML_REPO }}/src | |
for %%n in (py_cfml_metrics py_cfml_profiles py_cfml_sxtal_geom) do ( | |
${{ matrix.compiler }} -shared -o %%n.pyd %%n.f90 ${{ env.COMPILER_OPTIONS }} -I ${{ env.CRYSFML_DIST }}/include -L ${{ env.CRYSFML_DIST }}/lib -lCrysFML08 ${{ env.LIBPYTHON }} | |
cp %%n.pyd ${{ env.PYCRYSFML_DIST }}/${{ env.DIST_PACKAGE_NAME }} | |
) | |
rm *.smod *.*mod | |
- name: Make PyCrysFML python wheel | |
run: | | |
python -m pip install build | |
echo '### touch ${{ env.PYCRYSFML_DIST }}/${{ env.DIST_PACKAGE_NAME }}/__init__.py' | |
touch ${{ env.PYCRYSFML_DIST }}/${{ env.DIST_PACKAGE_NAME }}/__init__.py | |
echo '### python3 -m build --wheel --outdir ${{ env.PYCRYSFML_WHEEL }}' | |
python3 -m build --wheel --outdir ${{ env.PYCRYSFML_WHEEL }} | |
echo '### ls - l ${{ env.PROJECTS_DIR }}' | |
ls -l ${{ env.PROJECTS_DIR }} | |
echo '### ls -l ${{ env.PYCRYSFML_DIST }}' | |
ls -l ${{ env.PYCRYSFML_DIST }} | |
echo '### ls - l ${{ env.PYCRYSFML_WHEEL }}' | |
ls -l ${{ env.PYCRYSFML_WHEEL }} | |
- name: Install PyCrysFML from local wheel (with dev extras) | |
run: | | |
echo '### python3 -m pip install "${{ env.DIST_PACKAGE_NAME }}[dev]" --find-links=${{ env.PYCRYSFML_WHEEL }}' | |
python3 -m pip install "${{ env.DIST_PACKAGE_NAME }}[dev]" --find-links=${{ env.PYCRYSFML_WHEEL }} | |
- name: Run tests | |
run: pytest tests/ -vv |