Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions .github/workflows/intel_coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Ryan Mulhall 7/22
# Uses an intel image to compile,test and generate a code coverage report.
# If triggered by PR, it will compare coverage with the last main archived result
# and output a warning for decreases in function coverage.
#on: [push, pull_request]
on:
push:
branches:
- main
pull_request:
jobs:
generate-coverage-report:
runs-on: ubuntu-latest
container:
image: intel/oneapi-hpckit:2022.2-devel-ubuntu20.04
env:
CC: mpiicc
FC: mpiifort
CFLAGS: "-I/libs/include"
FCFLAGS: "-I/libs/include -g -traceback"
LDFLAGS: "-L/libs/lib"
TEST_VERBOSE: 1
I_MPI_FABRICS: "shm" # needed for mpi in image
# intel bug causes some failures with shm option(required in container)
SKIP_TESTS: "test_mpp_update_domains.1 test_update_domains_performance.1 test_diag_manager2.23 test_field_manager2.1"
steps:
- name: Cache dependencies
id: cache
uses: actions/cache@v3
with:
path: /libs
key: ${{ runner.os }}-intel-libs
- name: Install packages for building
run: apt update && apt install -y autoconf libtool automake zlibc zlib1g-dev bc
- if: steps.cache.outputs.cache-hit != 'true'
name: Build dependencies
run: |
mkdir /libs
wget https://hdf-wordpress-1.s3.amazonaws.com/wp-content/uploads/manual/HDF5/HDF5_1_12_2/source/hdf5-1.12.2.tar.gz
tar xf hdf5-1.12.2.tar.gz && cd hdf5-1.12.2
./configure --prefix=/libs
make -j install && cd ..
wget https://github.com/Unidata/netcdf-c/archive/refs/tags/v4.8.1.tar.gz
tar xf v4.8.1.tar.gz && cd netcdf-c-4.8.1
./configure --prefix=/libs --enable-remote-fortran-bootstrap
make -j install
# sets this here to pass embeded configure checks
export LD_LIBRARY_PATH="/libs/lib:$LD_LIBRARY_PATH"
make -j -k build-netcdf-fortran
make -j install-netcdf-fortran
wget https://github.com/yaml/libyaml/releases/download/0.2.5/yaml-0.2.5.tar.gz
tar xf yaml-0.2.5.tar.gz && cd yaml-0.2.5
./configure --prefix=/libs
make -j install && cd
- name: checkout
uses: actions/checkout@v2
- name: Configure
run: autoreconf -if ./configure.ac && ./configure --enable-code-coverage --with-yaml
- name: Compile
run: make -j || make
- name: Run test suite
id: report
run: make check-code-coverage LD_LIBRARY_PATH="/libs/lib:$LD_LIBRARY_PATH"
# get coverage results from last successful main run for comparison
# the steps below only run on pull requests
- if: ${{ github.ref != 'refs/heads/main' }}
name: Download last results
uses: dawidd6/action-download-artifact@v2
continue-on-error: true
with:
workflow: intel_coverage.yml
branch: main
workflow_conclusion: success
- if: ${{ github.ref != 'refs/heads/main' }}
name: Compare coverage
run: |
if [ -f code-coverage-report/coverage-percent.txt ]; then
archive_val="`cat code-coverage-report/coverage-percent.txt`"
if [ 1 -eq "$(echo "${archive_val} > ${RESULT}" | bc)" ]; the
echo "::error title=Coverage Dropped:: This pull request will decrease coverage from $archive_val to $RESULT"
exit 1
fi
else
echo "::warning title=Coverage Not Checked:: Archived results could not be downloaded"
fi
env:
RESULT: ${{ steps.report.outputs.percentage }}
- if: ${{ github.ref == 'ref/heads/main' }}
name: Archive code coverage results
uses: actions/upload-artifact@v3
with:
name: code-coverage-report
path: /coverage-percent.txt
27 changes: 25 additions & 2 deletions test_fms/intel_coverage.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,42 @@ cat <<_EOF > coverage-report/fms-coverage.html
</head>
<body>
_EOF

# comment that seems to prevent the _EOF from inexplicably being included in the output file
total=0
covered=0
# generate code coverage report and links for each (src) subdirectory
for dir in `find . -maxdepth 1 -mindepth 1 -type d -printf '%f\n' | grep -v test_fms | sort`
# also sums the covered and total block counts
for dir in `find . -not -path '*/.*' -maxdepth 1 -mindepth 1 -type d -printf '%f\n' | grep -v test_fms | grep -v 'coverage-*'`
do
cd $dir
echo $dir
if [ ! -z "`find . -type f -name "*.spi"`" ] ; then
mkdir ../coverage-report/$dir
codecov -prj $dir -spi pgopti.spi -dpi ../fms-global-coverage.dpi

tmp="`sed -n 54p CodeCoverage/__CODE_COVERAGE.HTML | sed 's/.*>\(.*\)<.*/\1/' | sed 's/,//' `"
total="`expr $tmp + $total`"
tmp="`sed -n 55p CodeCoverage/__CODE_COVERAGE.HTML | sed 's/.*>\(.*\)<.*/\1/' | sed 's/,//' `"
covered="`expr $tmp + $covered`"

mv CODE_COVERAGE.HTML ../coverage-report/$dir
mv CodeCoverage ../coverage-report/$dir
echo "<p><a href=\"${dir}/CODE_COVERAGE.HTML\">${dir}</a></p>" >> ../coverage-report/fms-coverage.html
fi
cd ..
done
percentage="$(echo "scale=2; ${covered}*100/${total}" | bc)"

echo "</body>" >> coverage-report/fms-coverage.html
echo "</html>" >> coverage-report/fms-coverage.html
# print results for total coverage since each report is per directory
# extra output if in CI
echo "$covered covered functions out of $total total (${percentage}%)"
if [ "$CI" ]; then
echo "::set-output name=total::${total}"
echo "::set-output name=covered::${covered}"
echo "::set-output name=percentage::${percentage}"
test -z "${percentage}" && echo "::error title=Percentage calculation failed::" && exit 1
echo "::notice title=Coverage Info::${percentage}% of routine/function coverage. ${covered} covered functions out of ${total} total"
echo "${percentage}" > /coverage-percent.txt
fi