Merge pull request #560 from timfelle/fix/cmake #178
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: CI | |
on: [push, pull_request] | |
jobs: | |
Build: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-20.04] | |
gcc_v: [7,8,9,10] # Version of GFortran we want to use. | |
python-version: [3.9] | |
env: | |
FC: gfortran-${{matrix.gcc_v}} | |
GCC_V: ${{matrix.gcc_v}} | |
steps: | |
- name: Set vars | |
id: vars | |
# run: echo ::set-output name=tag::${GITHUB_REF#refs/*/} # this is depreciated: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/ | |
run: echo "name=tag::${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT | |
- name: Checkout code | |
uses: actions/[email protected] | |
with: | |
submodules: recursive | |
- name: Setup cmake | |
if: contains( matrix.gcc_v, 9 ) | |
uses: jwlawson/[email protected] | |
with: | |
cmake-version: '3.28.x' | |
- name: Install Python | |
uses: actions/[email protected] # Use pip to install latest CMake, & FORD/Jin2For, etc. | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Setup Graphviz | |
uses: ts-graphviz/[email protected] | |
- name: Install Python dependencies | |
if: contains( matrix.os, 'ubuntu') | |
run: | | |
python -m pip install --upgrade pip | |
pip install ford FoBiS.py pygooglechart | |
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | |
- name: Install GFortran Linux | |
if: contains( matrix.os, 'ubuntu') | |
run: | | |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test | |
sudo apt-get update | |
sudo apt-get install -y gcc-${GCC_V} gfortran-${GCC_V} | |
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${GCC_V} 100 \ | |
--slave /usr/bin/gfortran gfortran /usr/bin/gfortran-${GCC_V} \ | |
--slave /usr/bin/gcov gcov /usr/bin/gcov-${GCC_V} | |
- name: Compile_with_build | |
if: matrix.gcc_v != 7 | |
run: | | |
GFORTRAN=gfortran-${{matrix.gcc_v}} | |
GCOV=gcov-${{matrix.gcc_v}} | |
# build with build.sh, run unit tests | |
./build.sh --skip-documentation | |
./build.sh --skip-documentation --enable-unicode | |
- name: Compile_with_cmake | |
# CMake build with unit tests, no documentation, with coverage analysis | |
# No unicode so that coverage combined with the build script will cover unicode | |
# and non-unicode code paths | |
if: matrix.gcc_v == 9 | |
run: | | |
GFORTRAN=gfortran-${{matrix.gcc_v}} | |
GCOV=gcov-${{matrix.gcc_v}} | |
mkdir cmake-build | |
cd cmake-build | |
cmake -D ENABLE_TESTS=ON .. | |
make -j 4 check | |
- name: Compile_with_build_mkdocs | |
# build with build.sh, make documentation, run unit tests | |
# and perform coverage analysis - used for doc deployment | |
if: matrix.gcc_v == 7 | |
run: | | |
GFORTRAN=gfortran-${{matrix.gcc_v}} | |
GCOV=gcov-${{matrix.gcc_v}} | |
./build.sh --coverage --skip-documentation | |
./build.sh --coverage --enable-unicode | |
- name: Deploy Documentation for master | |
if: matrix.gcc_v == 7 && github.ref == 'refs/heads/master' | |
uses: JamesIves/[email protected] | |
with: | |
branch: gh-pages # The branch the action should deploy to. | |
folder: doc # The folder the action should deploy. | |
clean: true | |
clean-exclude: | | |
prev | |
- name: Rebuild documentation for tagged release | |
env: | |
TAGNAME: ${{ steps.vars.outputs.tag }} | |
if: matrix.gcc_v == 7 && startsWith(github.ref, 'refs/tags/') | |
run: | | |
echo ${TAGNAME} | |
rm -rf doc | |
sed "2 s/^/version: ${TAGNAME}\n/" json-fortran.md > json-fortran.tagged.md | |
ford --debug json-fortran.tagged.md | |
- name: Deploy documentation for tagged release | |
if: matrix.gcc_v == 7 && startsWith(github.ref, 'refs/tags/') | |
uses: JamesIves/[email protected] | |
with: | |
branch: gh-pages # The branch the action should deploy to. | |
folder: doc # The folder the action should deploy. | |
target-folder: prev/${{ steps.vars.outputs.tag }} # deploy to a version-specific folder | |
- name: Upload coverage | |
if: matrix.gcc_v == 7 | |
run: | | |
rm json_*.F90-*unicode.gcov || true | |
mv json_*.F90.gcov src/ | |
mv jf_test*.[fF]90.gcov src/tests/ | |
bash <(curl -s https://codecov.io/bash) -v -X $GCOV |