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

Update code coverage documentation #436

Merged
merged 7 commits into from
Apr 24, 2020
Merged
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
15 changes: 11 additions & 4 deletions cice.setup
Original file line number Diff line number Diff line change
Expand Up @@ -504,11 +504,18 @@ EOF0
cat >! ${tsdir}/report_codecov.csh << EOF0
#!/bin/csh -f

#setenv CODECOV_TOKEN "1d09241f-ed9e-47d8-847c-038bab024b53" # consortium cice
#setenv CODECOV_TOKEN "f3236008-0b92-4707-9ad5-ad906f5d2ba7" # apcraig cice
setenv CODECOV_TOKEN "0dcc6066-fdce-47b6-b84a-c55e2a0af4c0" # apcraig test_cice_icepack
set report_name = "${shhash}:${branch}:${machine} ${testsuite}"
# define CODECOV_TOKEN env variable
if !(\$?CODECOV_TOKEN) then
if (-e ~/.codecov_cice_token) then
source ~/.codecov_cice_token
endif
if !(\$?CODECOV_TOKEN) then
echo "\${0}: ERROR, CODECOV_TOKEN env variable not defined"
exit 2
endif
endif

set report_name = "${shhash}:${branch}:${machine} ${testsuite}"
set use_curl = 1

EOF0
Expand Down
75 changes: 75 additions & 0 deletions configuration/scripts/tests/cice_test_codecov.csh
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/bin/csh

# This was a script on gordon
# This script should only be run on hardware with the gnu compiler with a
# modified Macros file to turn on the codecov flags
# This should be run interactively because git push will require login information

#PBS -N cice_test
#PBS -q standard
#PBS -A NRLSS03755018
#PBS -l application=Regional-Arctic-System-Model
#PBS -l select=1:ncpus=32:mpiprocs=32
#PBS -l walltime=24:00:00
#PBS -j oe
#PBS -M [email protected]
#PBS -m be

#set verbose
module load costinit git

set scrdir = "~"
set testdir = "~/cice_testing"
set date0 = `date -u "+%y%m%d"`
set date = ${date0}cc

mkdir -p ${testdir}

cd ${testdir}

# Check out current cice master
echo " "
echo "*** checkout current cice master ***"
git clone https://github.com/cice-consortium/cice cice.master.${date} --recursive
cd cice.master.${date}
set hash = `git rev-parse --short HEAD `
cd ../

# Check out test_cice_icepack, remove all code and copy from cice master
# Need to be careful about dot files, particularly .git* files
# This copies in all files via standard file expansion (except dot files at root)
# This also copies in all dot file at the root that do not start with .g (ie. .git*)
echo " "
echo "*** checkout current test_cice_master ***"
git clone https://github.com/apcraig/test_cice_icepack test_cice_icepack.${date}
Copy link
Member

@phil-blain phil-blain Apr 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the clone is done using SSH ([email protected]:apcraig/Test_CICE_Icepack.git) instead of HTTPS, the script will not ask for a password for git push as long as the SSH keys are correctly configured

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, if we want to this to be easier to setup for others, I think the username (here apcraig) should be a script parameter, or at least an environment variable.

But as I wrote in #89 (comment), I think it would be more "official" if the "test_cice_icepack" repo (or whatever we call it) was under the CICE-Consortium organization no ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @phil-blain. We could use ssh, but I'm not sure it's worth setting up the ssh keys for occasional testing. Putting in a username and password doesn't seem like a large burden or hurdle.

I have given a few people access to the test_cice_icepack repo. You should be able to push to that repo using your own username/password. Or are you suggesting that the "organization" name be a variable? My idea is that a handful of us will have access to the repo under "apcraig", and we'll use it for now. I don't see any value in setting up the equivalent repo under multiple users. If we did that, we'd end up needing to test/change a few other things including the codecov location and the token string that connects github and codecov. It seems just easier to give a subset of folks write access to my test_cice_icepack repo. It's just a temporary repo and if it's get trashed, it's not a big deal. Every use basically removes all files and adds them all back again anyway.

I replied in #89 that I would prefer to keep the test_cice_icepack repo hidden and out of the CICE-Consortium. My hope is that it's temporary (until codecov supports submodules although I don't have a lot of optimism), and I prefer the fake repo not be visible to the community in general, especially since it's not part of the standard workflow and testing. I think it can only create confusion in the community. It would be easy to migrate test_cice_icepack to the consortium org if others felt it was better there though.

cd test_cice_icepack.${date}
echo " "
echo "*** remove current files and copy in cice master files ***"
set verbose
git rm -r * >& /dev/null
cp -p -r ../cice.master.${date}/* .
cp -p ../cice.master.${date}/.[a-f,h-z]* .

# Clean up icepack .git stuff and commit
rm -r -f icepack/.git*
git add .
unset verbose
echo " "
echo "*** git status of changes ***"
git status
echo " "
echo "*** commit changes ***"
git commit -m "update test_cice_icepack master to ${hash}"

# Push test_cice_icepack
echo " "
echo "*** push changes to test_cice_icepack ***"
git push origin master

# Run test suite
echo " "
echo "*** run test suite ***"
./cice.setup --suite first_suite,base_suite,travis_suite,decomp_suite,reprosum_suite,quick_suite -m gordon -e gnu --testid T${date} --codecov --queue standard

# The test suite will wait until all jobs are complete then run report_codecov.csh
# If that fails, you can run report_codecov.csh manually after all jobs are done
29 changes: 11 additions & 18 deletions doc/source/user_guide/ug_testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -668,32 +668,25 @@ Code Coverage Testing
The ``--codecov`` feature in **cice.setup** provides a method to diagnose code coverage.
This argument turns on special compiler flags including reduced optimization and then
invokes the gcov tool.
This option is currently only available with the gnu compiler and on a few systems.
This option is currently only available with the gnu compiler and on a few systems
with modified Macros files.

Because codecov.io does not support git submodule analysis right now, a customized
repository has to be created to test CICE with Icepack integrated directly. The repository
https://github.com/apcraig/Test_CICE_Icepack serves as the current default test repository.
In general, to setup the code coverage test in CICE, the current CICE master has
to be copied into the Test_CICE_Icepack repository, then the code coverage tool can
be run on that repository. A sample script to do that would be::
to be copied into the Test_CICE_Icepack repository, then the full test suite
can be run with the gnu compiler with the ``--codecov`` argument.

git clone https://github.com/cice-consortium/cice cice.master --recursive

git clone https://github.com/apcraig/test_cice_icepack
cd test_cice_icepack
git rm -r *
cp -p -r ../cice.master/* .
git add .
git commit -m "update to current cice master"
git push origin master

./cice.setup --suite first_suite,base_suite,travis_suite,decomp_suite,reprosum_suite,quick_suite -m gordon -e gnu --codecov --testid cc01

To use, submit a full test suite using an updated Test_CICE_Icepack version
and the gnu compiler with the ``--codecov`` argument.
The test suite will run and then a report will be generated and uploaded to
the `codecov.io site <https://codecov.io/gh/apcraig/Test_CICE_Icepack>`_ by the
**report_codecov.csh** script.
**report_codecov.csh** script. The env variable CODECOV_TOKEN needs to be defined
either in the environment or in a file named **~/.codecov_cice_token**. That
token provides write permission to the Test_CICE_Icepack codecov.io site and is available
by contacting the Consortium team directly.

A script that carries out the end-to-end testing can be found in
**configuration/scripts/tests/cice_test_codecov.csh**

This is a special diagnostic test and does not constitute proper model testing.
General use is not recommended, this is mainly used as a diagnostic to periodically
Expand Down