Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Measure test coverage and report to codecov.io, take 2 #202

Closed
wants to merge 47 commits into from
Closed
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
44d6746
Pass coverage flags to gfortran, submit results to codecov
anders-dc Apr 14, 2018
d063fee
Add badge to README for CICE-Consortium/Icepack:master
anders-dc Apr 14, 2018
576ca62
Use GCC instead of clang
anders-dc Apr 14, 2018
f77a83c
Temporarily disable download of external datasets
anders-dc Apr 14, 2018
e4be7b2
Add coverage flag to linker
anders-dc Apr 14, 2018
fe47980
Reenable download of external datasets
anders-dc Apr 15, 2018
b1fc3f0
Add curl for codecov reporting
anders-dc Apr 15, 2018
f5b9cd7
Add debug flags, required for gcov
anders-dc Apr 15, 2018
22cf376
Also search build/run directory for coverage files
anders-dc Apr 15, 2018
7735758
Disable optimizations and sequentially report to codecov
anders-dc Apr 15, 2018
710bc56
Add codecov token in separate file
anders-dc May 17, 2018
dc51a08
Merge branch 'codecov' of github.com:anders-dc/Icepack into codecov
anders-dc May 17, 2018
9e86b4c
Add codecov option, append coverage flags to FFLAGS, reenable optimiz…
anders-dc May 17, 2018
72fe454
Perform FFLAGS, CFLAGS, and LDFLAGS modification directly on Macros file
anders-dc May 17, 2018
71f6b9c
Remove coverage-related flags from default travis configuration
anders-dc May 17, 2018
dd008e2
Report results to codecov.io after tests have completed
anders-dc May 17, 2018
8df71d6
Rerun with coverage metrics if test suite passes
anders-dc May 17, 2018
19f3832
Change to build directory before relaunching tests with --codecov
anders-dc May 17, 2018
9308ddf
Add newline before codecov status is displayed
anders-dc May 17, 2018
22ac61a
Move report_codecov.csh script to proper location
anders-dc May 17, 2018
3f81157
Remove previous script directory before rerunning with --codecov
anders-dc May 17, 2018
73efbc6
Fix newline in echo command
anders-dc May 17, 2018
addef2f
Do not report codecov results from travis
anders-dc May 17, 2018
52f7dde
Improve codecov reporting script with comments and better control flow
anders-dc May 17, 2018
b520ec4
Remove codecov token from codecov.yml, but place it in report_codecov…
anders-dc May 17, 2018
f42b12d
Try codecov reporting on travis
anders-dc May 17, 2018
3b893f4
Remove unused ICE_CODECOV environment variable
anders-dc May 17, 2018
143ecb2
Fix header comment in Macros for travis
anders-dc May 17, 2018
5afd38b
Fix formatting of compiler/linker flags statement to Macros file
anders-dc May 17, 2018
ea2e069
Do not generate codecov metrics on Travis
anders-dc May 17, 2018
34d57fe
Revert optimization flag for fortran
anders-dc May 17, 2018
d3a38b2
Fix minor spacing issue in icepack.setup script
anders-dc May 17, 2018
d0474fe
Use printf instead of echo for info message for newline character par…
anders-dc May 17, 2018
4c5b6d8
Update codecov token to CICE-Consortium user and launch coverage repo…
anders-dc May 17, 2018
84b3fc8
Disable coverage reporting on travis
anders-dc May 17, 2018
47c9b2a
Enforce --env gnu with --codecov, and check if curl is available
anders-dc May 18, 2018
ddee782
Add compatibility with wget
anders-dc May 18, 2018
2d4132e
Report version and host info in codecov report name, enable test on t…
anders-dc May 18, 2018
1f88a26
Disable coverage reporting from travis
anders-dc May 18, 2018
7b0648f
Launch codecov on travis
anders-dc May 18, 2018
e0b6e0c
Disable codecov on travis
anders-dc May 18, 2018
15c2c46
Report test suite environment and identifier in report name
anders-dc May 18, 2018
b36a13d
Launch coverage report from travis
anders-dc May 18, 2018
6716fae
Move --coverage flag to non-conflicting position in icepack.setup call
anders-dc May 18, 2018
b758198
Fix parameter name during call: `--coverage` to `--codecov`
anders-dc May 18, 2018
fa25e91
Fix flag for setting codecov report name
anders-dc May 18, 2018
c592730
Improve naming of report for codecov UI
anders-dc May 18, 2018
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
2 changes: 2 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# do not comment with code coverage metrics in github pull requests
comment: false
8 changes: 2 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,18 @@ language: cpp

sudo: false

compiler: clang

addons:
apt:
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-5.0
packages:
- tcsh
- pkg-config
- netcdf-bin
- libnetcdf-dev
- gfortran
- clang-5.0
- wget
- curl
#- lftp

install:
Expand All @@ -28,9 +25,8 @@ install:
#- "lftp ftp://anonymous:travis@travis-ci.org@ftp.cgd.ucar.edu
#-e 'mirror /archive/Model-Data/CICE/ ~/ICEPACK_INPUTDATA; quit'"


script:
- "./icepack.setup --suite travis_suite --testid travisCItest
- "./icepack.setup --suite travis_suite --testid travisCItest
--mach travisCI --env gnu &&
cd travis_suite.travisCItest &&
./results.csh"
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[![Build Status](https://travis-ci.org/CICE-Consortium/Icepack.svg?branch=master)](https://travis-ci.org/CICE-Consortium/Icepack)
[![Documentation Status](https://readthedocs.org/projects/cice-consortium-icepack/badge/?version=master)](http://cice-consortium-icepack.readthedocs.io/en/master/?badge=master)
[![codecov.io](http://codecov.io/github/CICE-Consortium/Icepack/coverage.svg?branch=master)](http://codecov.io/github/CICE-Consortium/Icepack?branch=master)

## Overview
This repository contains files for Icepack, the column physics of the sea ice model CICE. Icepack is maintained by the CICE Consortium. For testing purposes and guidance for including Icepack in other sea ice host models, this repository also includes a driver and basic test suite.
Expand Down
6 changes: 3 additions & 3 deletions configuration/scripts/machines/Macros.travisCI_gnu
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#==============================================================================
# Makefile macros for Travis-CI - gfortran and llvm (clang) compilers
# Makefile macros for Travis-CI - gfortran and gcc compilers
#==============================================================================

CPP := clang-cpp
CPP := cpp
CPPDEFS := -DFORTRANUNDERSCORE -DNO_R16 -DHAVE_F2008_CONTIGUOUS -DLINUX -DCPRINTEL ${ICE_CPPDEFS}
CFLAGS := -c -O2 -fp-model precise -xHost

Expand Down Expand Up @@ -30,7 +30,7 @@ ifeq ($(ICE_IOTYPE), netcdf)
INCLDIR := $(INCLDIR) -I$(NETCDF_PATH)/include
LIB_NETCDF := $(NETCDF_PATH)/lib
LIB_PNETCDF :=
SLIBS := -L$(LIB_NETCDF) -lnetcdf
SLIBS := -L$(LIB_NETCDF) -lnetcdf -lnetcdff
else
SLIBS :=
endif
Expand Down
26 changes: 26 additions & 0 deletions configuration/scripts/tests/report_codecov.csh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/csh -f
if (`where curl` == "") then
(>&2 echo "ERROR: Code coverage reporting (--codecov) needs 'curl' to upload results")
exit(1)
endif

# token from https://codecov.io/gh/CICE-Consortium/Icepack/settings
setenv CODECOV_TOKEN "df12b574-8dce-439d-8d3b-ed7428d7598a"

# The test-coverage files (*.gcno,*.gcda) must reside next to the source code
# for the coverage reporting to work. However, the coverage files are created
# for each test. For that reason, this script will copy the coverage files over
# to the source directory and report the results, one test at a time. Codecov.io
# is clever enough to report the cumulative results.
echo "Looping over test cases and uploading test coverage"
set testdirs=`ls -d ${ICE_MACHINE_WKDIR}/*`
foreach dir ($testdirs)
echo "## Submitting results from ${dir}"
cp $dir/compile/*.{gcno,gcda} ${ICE_SANDBOX}/columnphysics/
if ( $status == 0 ) then
echo "Uploading coverage results to codecov.io"
bash -c "bash <(curl -s https://codecov.io/bash)"
else
echo "No coverage files found for this test"
endif
end
29 changes: 28 additions & 1 deletion icepack.setup
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ set baseCom = $spval # Baseline compare
set baseGen = $spval # Baseline generate
set bfbcomp = $spval # BFB compare
set report = 0 # test results reporting
set codecov = 0 # code coverage measurement and reporting
#set versno = `grep "release =" doc/source/conf.py | cut -d \' -f 2`
set versno = `git log | grep 'v[0-9]\.[0-9]\.[0-9]\.[a-z][0-9]*' | head -1 | sed 's/.*\(v[0-9]\.[0-9]\.[0-9]\.[a-z][0-9]*\).*/\1/' `

Expand Down Expand Up @@ -73,7 +74,7 @@ SYNOPSIS

--suite SUITE -m MACH --testid ID
[-e ENV1,ENV2][--acct ACCT][--bdir DIR][--bgen DIR]
[--bcmp DIR][--report]
[--bcmp DIR][--report][--codecov]

DESCRIPTION
--help, -h : help
Expand All @@ -96,6 +97,7 @@ DESCRIPTION
--testid : test ID, user-defined id for testing (REQUIRED with --test or --suite)
--diff : generate comparison against another case
--report : automatically post results when tests are complete
--codecov : generate and report test coverage metrics when tests are complete

EXAMPLES
icepack.setup -c caseB -m gordon -e cray -s diag1,debug
Expand Down Expand Up @@ -172,6 +174,10 @@ while (1)
set report = 1
shift argv

else if ("$option" == "--codecov") then
set codecov = 1
shift argv

# arguments with settings
else
shift argv
Expand Down Expand Up @@ -252,6 +258,11 @@ if ($report == 1 && $testsuite == $spval) then
exit -1
endif

if ($codecov == 1 && $testsuite == $spval) then
echo "${0}: ERROR in arguments, must use --suite with --codecov"
exit -1
endif

if ($testsuite == $spval) then
if ("$compilers" =~ "*,*") then
echo "${0}: ERROR in arguments, cannot set multiple compilers without --suite"
Expand Down Expand Up @@ -302,6 +313,10 @@ if ( $testsuite != $spval ) then
cp -f ${ICE_SCRIPTS}/tests/poll_queue.csh ./${tsdir}
endif

if ($codecov == 1) then
cp -f ${ICE_SCRIPTS}/tests/report_codecov.csh ./${tsdir}
endif

cat >! ./${tsdir}/suite.run << EOF0
#!/bin/csh -f
EOF0
Expand Down Expand Up @@ -443,6 +458,14 @@ foreach file (env.${machcomp} Macros.${machcomp})
cp -f -p ${ICE_SCRIPTS}/machines/$file ${casedir}
end

# append coverage-related flags to Macros if `codecov` is true
if ($codecov == 1) then
printf "FFLAGS += -O0 -fprofile-arcs -ftest-coverage -g\
CFLAGS += -O0 -coverage -g\
LDFLAGS += -ftest-coverage -fprofile-arcs -g\n" >> \
${casedir}/Macros.${machcomp}
endif

# from basic script dir to casescr
foreach file (parse_namelist.sh parse_settings.sh parse_namelist_from_settings.sh icepack_decomp.csh icepack.run.setup.csh icepack.test.setup.csh)
if !(-e ${ICE_SCRIPTS}/$file) then
Expand Down Expand Up @@ -720,6 +743,10 @@ EOF
./results.csh
./report_results.csh
endif
if ($codecov == 1) then
printf "\nMeasuring test coverage and uploading results to codecov.io\n"
./report_codecov.csh
endif
cd ${ICE_SANDBOX}

endif
Expand Down