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

Use features in newer CTest versions to improve and robustify git version control updates for base repo #278

Closed
bartlettroscoe opened this issue Feb 13, 2019 · 5 comments

Comments

@bartlettroscoe
Copy link
Member

bartlettroscoe commented Feb 13, 2019

CC: @fryeguy52

Next Action Status

Got specialized more robust git commands for base git repo called under ctest_update() correctly. Next: Move git commands for extra repos under ctest_update() and test that update failures are caught and handled correctly ...

Description

The current code in tribits_ctest_driver() checks out correct branches outside of the ctest_start() command (which does the initial git clone) and the ctest_update() command (which does updates of the repo after a clone). There are several problems with this implementation:

  1. If the branch that is desired is not the selected branch that is checked out after the initial clone, then CDash reports the wrong git repo SHA1.

  2. If an already checked-out repo is on a tracking branch that has its remote tracking branch changed, then the git fetch will fail and ctest_update() will fail. (This is what just happended today with the change of the Trilinos branch 'atdm-develop-nightly' to 'atdm-nightly' as described in TRIL-260.)

This makes for a fragile system and with incorrect version info on CDash in some cases.

Proposed Solution

To address these problems, we can make better usage of features in newer versions of CMake.

First, the TriBITS project (or user) defines the vars:

  • GIT_EXE: The git executable (found with find_program(GIT_EXE git ...))

  • ${PROJECT_NAME}_REPOSITORY_LOCATION: The Git repo URL used in git clone <repo-url>

  • ${PROJECT_NAME}_GIT_REPOSITORY_REMOTE: The name of the git repo remote after clone (default is 'origin') (this would be a new variable)

  • ${PROJECT_NAME}_BRANCH: The name of the branch to checkout. (Will be empty "" if to just use the default branch.)

For the initail clone, we can specify:

set(CTEST_CHECKOUT_COMMAND
  "\"${GIT_EXE}\" clone -b ${${PROJECT_NAME}_BRANCH} -o ${${PROJECT_NAME}_GIT_REPOSITORY_REMOTE} ${${PROJECT_NAME}_REPOSITORY_LOCATION}"

If no branch is provied, then the command is just:

set(CTEST_CHECKOUT_COMMAND
  "\"${GIT_EXE}\" clone  -o ${${PROJECT_NAME}_GIT_REPOSITORY_REMOTE} ${${PROJECT_NAME}_REPOSITORY_LOCATION}"

For updates, the command would be:

set(CTEST_GIT_UPDATE_CUSTOM
  "\"${GIT_EXE}\" clean -fdx"
  "\"${GIT_EXE}\" reset --hard HEAD"
  "\"${GIT_EXE}\" fetch ${${PROJECT_NAME}_GIT_REPOSITORY_REMOTE}"
  "\"${GIT_EXE}\" checkout -B ${${PROJECT_NAME}_BRANCH} ${${PROJECT_NAME}_GIT_REPOSITORY_REMOTE}/${${PROJECT_NAME}_BRANCH}"
  )

If there was no branch, the last command would instead be:

  "\"${GIT_EXE}\" reset --hard @{u}"

(but that requires that the current branch already is a tracking branch).

bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Feb 14, 2019
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Feb 14, 2019
@bartlettroscoe bartlettroscoe self-assigned this Feb 15, 2019
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Feb 15, 2019
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Feb 15, 2019
…#278)

For some reason, ctest_update() says these commands fail.  But when I run them
myself, they work!
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Feb 15, 2019
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Feb 15, 2019
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Feb 15, 2019
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Feb 15, 2019
…BITSPub#278)

So you need to use semi-colons for every argument in a **single** shell
command!
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Feb 15, 2019
…OM (TriBITSPub#278)

This does not work.  You can't use '&&' to string together commands.  And that
is not even portable.

Therefore, we will need to move to another appraoch.
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Feb 15, 2019
…SPub#278)

I also added this to the notes files and refactored that a little to clean
them up.
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Feb 16, 2019
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Feb 16, 2019
Can't actually do an update as of now with this code but perhaps we could
figure out how to do that using a mock git?
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Feb 16, 2019
…TSPub#278)

This makes sure they run the commands they should in unit test mode.
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Feb 16, 2019
…e some output (TriBITSPub#278)

Now I need to just document one set of git commands and they apply to the base
repo and the extra repos.
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Feb 18, 2019
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Feb 18, 2019
)

Just noticed this var was not getting read from the env when the initial value
should be to make things easy.

ToDo: Need to add automated tests for notes files to pin this down.
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Feb 18, 2019
…cmake (TriBITSPub#278, TriBITSPub#154)

This is needed to be able to read XML files out of the
<bulid>/Testing/<buildstarttime>/ directory needed for (TriBITSPub#278)

This will also make it easy to generate a CDash URL without knowing the build
ID.
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Feb 18, 2019
Can't actaully use this in checking the contents of the Notes.xml file because
that file does not get generated unless ctest_submit() is called and we can't
do CDash submits by default for lots of obvious reasons.

I am going to set up some tests of tribits_ctest_driver() that actually do
clones and updates and call ctest_update() that will then use this file.
bartlettroscoe added a commit to tribits/TribitsExampleMetaProject that referenced this issue Feb 19, 2019
bartlettroscoe added a commit to tribits/TribitsExampleProject that referenced this issue Feb 19, 2019
bartlettroscoe added a commit to tribits/TribitsExampleProjectAddons that referenced this issue Feb 19, 2019
bartlettroscoe added a commit to tribits/TribitsExampleMetaProject that referenced this issue Feb 19, 2019
bartlettroscoe added a commit that referenced this issue Feb 19, 2019
Looks like the git version on TravisCI puts "'" around the branch and remote
names.
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Feb 20, 2019
This is a start but these really need to be converted into README.md files and
make more complete.
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Feb 20, 2019
…tronger testing (TriBITSPub#278, TRIL-260)

This commit represents a fairly significant enhancement of the handing of git
repo clones and updates.  Previous to this commit, CDash would not report the
correct git repo SHA1 if the branch was not the default branch on the initial
clone or in checking out a new branch.  Also, the git commands were not robust
in use cases where the current branch in a base repo or an extra repo was not
on a tracking branch or the branch in the remote repo did not exist (like
occurred in TRIL-260 which changing from 'atdm-develop-nightly' to
'atdm-nightly' where 'atdm-develop-nightly' got deleted in the GitHub repo).
The documentation for git repo updates and been improved and streamlined.

This includes a huge step forward in automated testing of the
tribits_ctest_driver() function in how it does real git repo clones and
updates for various use cases.  To accomplish this, a new set of repos were
create under https://github.com/tribits/ for the example projects/repos
TribitsExampleMetaProject, TribitsExampleProject and
TribitsExampleProjectAddons.  There is a branch 'for-testing' in each of those
repos that have known stats that are used for strong testing.  Tests are set
up based on a base TribitsExampleMetaProject repo/project that clones the
extra repos TribitsExampleProject and TribitsExampleProjectAddons so we cover
use cases in the base repo and extra repos (which are mostly decoupled).  This
testing helped to catch invalid logic for the extra repos (for the case where
the current branch is not a tracking branch).

Some of the specific things done include:

* Switched from CTEST_UPDATE_COMMAND to CTEST_GIT_COMMAND (this really is git
  only)

* Added CTEST_GIT_UPDATE_CUSTOM which calls a ctest -P script to do the
  improved git repo cleanup and update commands (see updated documentation).

* Allow a set of CTEST_NOTES_FILES be specified by the user and correctly
  added to other notes files created internally and (hopefully) submitted to
  CDash.  There are now strong unit tests for the full listing of notes files
  that are generated (which requires running ctest_update() to generate a few
  of the files).

* Added TRIBITS_READ_CTEST_TAG_FILE() and TribitsGetCTestTestXmlDir.cmake
  (TriBITSPub#278, TriBITSPub#154): This is needed to be able to read XML files out of the
  <bulid>/Testing/<buildstarttime>/ directory needed for (TriBITSPub#278).  This will
  also make it easy to generate a CDash URL without knowing the build ID.  But
  this is not hooked in yet.  It was added here with the hope to check the
  contents of the Notes.xml file but that file does not get generated unless
  you actually submit to CDash (which we can't do yet and don't want to rely
  on).  Also added the file Add list_cdash_notes_files_in_xml_file.sh in hopes
  of doing this testing.

* Remove the function to get the extra repo tracking branch.  The old code
  assumed that the current branch in an extra repo was on a tacking branch.
  That is a bad assumption.  The updated code just uses '@{u}' as the tracking
  branch.  This was a real defect that was found through careful automated
  testing with real git commands.  This is why we need some tests with real
  git commands to validate our implementation.

* Updated some files in the example repos TribitsExampleMetaProject,
  TribitsExampleProject and TribitsExampleProjectAddons some to get these
  testing use cases working.  Also improved the README files some more, but
  more is needed.
bartlettroscoe added a commit that referenced this issue Feb 20, 2019
Build/Test Cases Summary
Enabled Packages:
Enabled all Packages
0) MPI_DEBUG => passed: passed=341,notpassed=0 (0.87 min)
1) SERIAL_RELEASE => passed: passed=341,notpassed=0 (0.93 min)
Other local commits for this build/test group: 76e958d, 3507ab4, 49d9c81, 2541677, 5e1677e
@bartlettroscoe
Copy link
Member Author

PR #279 was merged. The snaphsot PR Trilinos is trilinos/Trilinos#4438.

Once the Trilinos PR trilinos/Trilinos#4438 merges and is used for a few nights in ATDM Trilinos builds and testing, then we can close this Issue.

bartlettroscoe added a commit that referenced this issue Feb 22, 2019
Some of these typos were found during the review of trilinos/Trilinos#4438.

I also fixed "PASSSED" with "PASSED" that was grepped for in a bunch of
automated tests.  All good now :-)

Build/Test Cases Summary
Enabled Packages:
Enabled all Packages
0) MPI_DEBUG => passed: passed=341,notpassed=0 (0.86 min)
1) SERIAL_RELEASE => passed: passed=341,notpassed=0 (0.93 min)
@bartlettroscoe
Copy link
Member Author

Just realized that we could move the extra repo clone and update commands inside of the command run by ctest_update() so that if any of them fail, we could report an update failure to CDash and abort the build. This would also result in getting the extra repo commands to be sent to CDash as a notes file as well.

I need to make this happen and add some strong automated tests of tribits_ctest_driver() to ensure that all forms of git clone and update failures of the base and extra repos are caught and reported correctly!

@bartlettroscoe
Copy link
Member Author

bartlettroscoe commented May 5, 2020

FYI: Below are the notes I wrote from over a year ago that lead to several commits including in PR #279 working towards this.

Notes from Feb 2019

(2/14/2019)

Now I want to test that the updated git clone command does what it is supposed to do. To test this out, I will try running a TriBITS ctest -S driver script to clone my TriBITS repo on a branch with a different remote name and see if that works.

First, I had to write a ctest -S driver script for TriBITS. I only had one for TravisCI! After I created that commit, I tested this on 'crf450' with:

$ cd /home/rabartl/Trilinos.base/BUILDS/GCC-4.8.3/MOCK_TRIBITS_CTEST_S_DRIVER/

$ module load sems-env
$ module load sems-git/2.10.1   # Must have HTTPS support!

$ export https_proxy=http://wwwproxy.sandia.gov:80/

$ time env \
    CTEST_DASHBOARD_ROOT=$PWD \
    CTEST_DO_SUBMIT=OFF \
  ctest -V -S \
    /home/rabartl/Trilinos.base/Trilinos/TriBITS/cmake/ctest/generic_gcc/ctest_genertic_gcc_serial_debug.cmake \
    &> console.out

That seemed to do the trick and it cloned the repo:

[MOCK_TRIBITS_CTEST_S_DRIVER (crf450)]$ cd TriBITS/
[TriBITS (master)]$ git remote -v
origin  https://github.com/TriBITSPub/TriBITS.git (fetch)
origin  https://github.com/TriBITSPub/TriBITS.git (push)

That looks correct.

Now let's clone on a branch with a different remote name and different repo:

$ rm -rf TriBITS

$ time env \
    CTEST_DASHBOARD_ROOT=$PWD \
    TriBITS_REPOSITORY_LOCATION=git@github.com:bartlettroscoe/TriBITS.git \
    TriBITS_GIT_REPOSITORY_REMOTE=github \
    TriBITS_BRANCH=278-improve-ctest-s-git-commands \
    CTEST_DO_SUBMIT=OFF \
  ctest -V -S \
    /home/rabartl/Trilinos.base/Trilinos/TriBITS/cmake/ctest/generic_gcc/ctest_genertic_gcc_serial_debug.cmake \
    &> console.out

real    1m17.028s
user    4m52.496s
sys     2m32.726s

That gave the git repo:

[rabartl@crf450 MOCK_TRIBITS_CTEST_S_DRIVER (crf450)]$ cd TriBITS/
[rabartl@crf450 TriBITS (278-improve-ctest-s-git-commands)]$ git remote -v
github  git@github.com:bartlettroscoe/TriBITS.git (fetch)
github  git@github.com:bartlettroscoe/TriBITS.git (push)

That looks correct to me :-)

I think that is good enough testing for the clone part.

After implementing the custom update, I ran:

$ time env \
    CTEST_DASHBOARD_ROOT=$PWD \
    TriBITS_REPOSITORY_LOCATION=git@github.com:bartlettroscoe/TriBITS.git \
    TriBITS_GIT_REPOSITORY_REMOTE=github \
    TriBITS_BRANCH=278-improve-ctest-s-git-commands \
    CTEST_DO_SUBMIT=OFF \
  ctest -V -S \
    /home/rabartl/Trilinos.base/Trilinos/TriBITS/cmake/ctest/generic_gcc/ctest_genertic_gcc_serial_debug.cmake \
    &> console.out

real    1m14.451s
user    4m50.182s
sys     2m29.948s

Darn, the ctest_update() command is failing and it is showing:

Calling ctest_start(Nightly)... 


Run dashboard with model Nightly
   Source directory: /ascldap/users/rabartl/Trilinos.base/BUILDS/GCC-4.8.3/MOCK_TRIBITS_CTEST_S_DRIVER/TriBITS
   Build directory: /ascldap/users/rabartl/Trilinos.base/BUILDS/GCC-4.8.3/MOCK_TRIBITS_CTEST_S_DRIVER/BUILD
   First perform the initial checkout: '/projects/sems/install/rhel6-x86_64/sems/utility/git/2.10.1/bin/git' clone -b 278-improve-ctest-s-git-commands -o origin  https://github.com/bartlettroscoe/TriBITS.git
   Perform checkout in directory: /ascldap/users/rabartl/Trilinos.base/BUILDS/GCC-4.8.3/MOCK_TRIBITS_CTEST_S_DRIVER
   Reading ctest configuration file: /ascldap/users/rabartl/Trilinos.base/BUILDS/GCC-4.8.3/MOCK_TRIBITS_CTEST_S_DRIVER/TriBITS/CTestConfig.cmake
-- CTEST_DROP_SITE='testing-vm.sandia.gov'
-- CTEST_PROJECT_NAME='TriBITS'
-- CTEST_DROP_LOCATION='/cdash/submit.php?project=TriBITS'
-- CTEST_TRIGGER_SITE=''
-- CTEST_DROP_SITE_CDASH='TRUE'
   Site: crf450.srn.sandia.gov
   Build name: Linux-UNKNOWN-GCC_SERIAL_DEBUG
Determine Nightly Start Time
   Specified time: 04:00:00 UTC
   Use Nightly tag: 20190214-0400

***
*** Update the source code repositories ...
***


Calling CTEST_UPDATE() to update base source repo '/ascldap/users/rabartl/Trilinos.base/BUILDS/GCC-4.8.3/MOCK_TRIBITS_CTEST_S_DRIVER/TriBITS' ...
   Updating the repository: /ascldap/users/rabartl/Trilinos.base/BUILDS/GCC-4.8.3/MOCK_TRIBITS_CTEST_S_DRIVER/TriBITS
   Use GIT repository type
   Old revision of repository is: 
   New revision of repository is: 
   Gathering version information (one . per revision):
    
   Update command failed: "'/projects/sems/install/rhel6-x86_64/sems/utility/git/2.10.1/bin/git' clean -fdx " " '/projects/sems/install/rhel6-x86_64/sems/utility/git/2.10.1/bin/git' reset --hard HEAD " " '/projects/sems/install/rhel6-x86_64/sems/utility/git/2.10.1/bin/git' fetch origin " " '/projects/sems/install/rhel6-x86_64/sems/utility/git/2.10.1/bin/git' checkout -B 278-improve-ctest-s-git-commands --track origin/278-improve-ctest-s-git-commands"
CTEST_UPDATE(...) returned '-1'

If I revert back to the original version of the code with:

$  git reset --hard 629b7ac

and run as above I get:

Run dashboard with model Nightly
   Source directory: /ascldap/users/rabartl/Trilinos.base/BUILDS/GCC-4.8.3/MOCK_TRIBITS_CTEST_S_DRIVER/TriBITS
   Build directory: /ascldap/users/rabartl/Trilinos.base/BUILDS/GCC-4.8.3/MOCK_TRIBITS_CTEST_S_DRIVER/BUILD
   First perform the initial checkout: "/projects/sems/install/rhel6-x86_64/sems/utility/git/2.10.1/bin/git" clone  https://github.com/bartlettroscoe/TriBITS.git
   Perform checkout in directory: /ascldap/users/rabartl/Trilinos.base/BUILDS/GCC-4.8.3/MOCK_TRIBITS_CTEST_S_DRIVER
Cannot locate CTest configuration: in BuildDirectory: /ascldap/users/rabartl/Trilinos.base/BUILDS/GCC-4.8.3/MOCK_TRIBITS_CTEST_S_DRIVER/BUILD/CTestConfig.cmake
Cannot locate CTest configuration: in SourceDirectory: /ascldap/users/rabartl/Trilinos.base/BUILDS/GCC-4.8.3/MOCK_TRIBITS_CTEST_S_DRIVER/TriBITS/CTestConfig.cmake
   Site: crf450.srn.sandia.gov
   Build name: Linux-UNKNOWN-GCC_SERIAL_DEBUG
Determine Nightly Start Time
   Specified time: 04:00:00 UTC
   Use Nightly tag: 20190214-0400

***
*** Update the source code repositories ...
***


Calling CTEST_UPDATE() to update base source repo '/ascldap/users/rabartl/Trilinos.base/BUILDS/GCC-4.8.3/MOCK_TRIBITS_CTEST_S_DRIVER/TriBITS' ...
   Updating the repository: /ascldap/users/rabartl/Trilinos.base/BUILDS/GCC-4.8.3/MOCK_TRIBITS_CTEST_S_DRIVER/TriBITS
   Use GIT repository type
   Old revision of repository is: e2107f14384ddd90c186bc78fb2a5f6e0b431c01
   New revision of repository is: e2107f14384ddd90c186bc78fb2a5f6e0b431c01
   Gathering version information (one . per revision):
    
CTEST_UPDATE(...) returned '0'

What I am noticing is that the modified version of the code is showing and empty:

   Old revision of repository is: 
   New revision of repository is: 

while the old version showed:

   Old revision of repository is: e2107f14384ddd90c186bc78fb2a5f6e0b431c01
   New revision of repository is: e2107f14384ddd90c186bc78fb2a5f6e0b431c01

What is going on with that?

I need to go back to the orginal updating code that works and change the commands one step at a time and see what is triggering this messed up state that causes ctest_update() to fail! I am thinking it must be something different about the initial clone because ctest_update() is showing this strange behavior of now new or old git repo versions even before it tries to run the actual git commands!

(2/15/2019)

I reset the branch to just the commit with the updated clone instructions with the new commits:

a93bc1c "WIP: Working to update ctest -S git commands (#278)"
Author: Roscoe A. Bartlett <rabartl@sandia.gov>
Date:   Thu Feb 14 13:42:11 2019 -0700 (14 hours ago)

M       test/ctest_driver/MockCTestDriver/CMakeLists.txt
M       tribits/ctest_driver/TribitsCTestDriverCore.cmake
M       tribits/ctest_driver/TribitsCTestDriverCoreHelpers.cmake

629b7ac "Add generic ctest -S driver to submit to CDash"
Author: Roscoe A. Bartlett <rabartl@sandia.gov>
Date:   Thu Feb 14 18:23:30 2019 -0700 (14 hours ago)

A       cmake/ctest/TribitsProjCTestDriver.cmake
A       cmake/ctest/generic_gcc/ctest_genertic_gcc_serial_debug.cmake
M       cmake/ctest/travisci/ctest_trusty_serial_debug.cmake
M       tribits/ctest_driver/TribitsCTestDriverCore.cmake

and ran the clone with:

$ rm -rf TriBITS ; time env CTEST_DASHBOARD_ROOT=$PWD     TriBITS_REPOSITORY_LOCATION=https://github.com/bartlettroscoe/TriBITS.git     TriBITS_BRANCH=278-improve-ctest-s-git-commands  CTEST_DO_CONFIGURE=OFF  CTEST_DO_BUILD=OFF  CTEST_DO_TEST=OFF     CTEST_DO_SUBMIT=OFF   ctest -V -S     /home/rabartl/Trilinos.base/Trilinos/TriBITS/cmake/ctest/generic_gcc/ctest_genertic_gcc_serial_debug.cmake &> console.out ; echo ; grep -A 9 "Calling CTEST_UPDATE.. to update base source repo" console.out

real    0m4.728s
user    0m1.542s
sys     0m0.572s

Calling CTEST_UPDATE() to update base source repo '/ascldap/users/rabartl/Trilinos.base/BUILDS/GCC-4.8.3/MOCK_TRIBITS_CTEST_S_DRIVER/TriBITS' ...
   Updating the repository: /ascldap/users/rabartl/Trilinos.base/BUILDS/GCC-4.8.3/MOCK_TRIBITS_CTEST_S_DRIVER/TriBITS
   Use GIT repository type
   Old revision of repository is: 1d79d874e5e6a8c5135ed4584a709c1c1197a91e
   New revision of repository is: 1d79d874e5e6a8c5135ed4584a709c1c1197a91e
   Gathering version information (one . per revision):
    
CTEST_UPDATE(...) returned '0'
For extra repos, doing switch to branch 278-improve-ctest-s-git-commands

And I ran the update with an existing clone with:

$ time env CTEST_DASHBOARD_ROOT=$PWD     TriBITS_REPOSITORY_LOCATION=https://github.com/bartlettroscoe/TriBITS.git     TriBITS_BRANCH=278-improve-ctest-s-git-commands  CTEST_DO_CONFIGURE=OFF  CTEST_DO_BUILD=OFF  CTEST_DO_TEST=OFF     CTEST_DO_SUBMIT=OFF   ctest -V -S     /home/rabartl/Trilinos.base/Trilinos/TriBITS/cmake/ctest/generic_gcc/ctest_genertic_gcc_serial_debug.cmake &> console.out ; echo ; grep -A 9 "Calling CTEST_UPDATE.. to update base source repo" console.out 

real    0m0.595s
user    0m0.169s
sys     0m0.158s

Calling CTEST_UPDATE() to update base source repo '/ascldap/users/rabartl/Trilinos.base/BUILDS/GCC-4.8.3/MOCK_TRIBITS_CTEST_S_DRIVER/TriBITS' ...
   Updating the repository: /ascldap/users/rabartl/Trilinos.base/BUILDS/GCC-4.8.3/MOCK_TRIBITS_CTEST_S_DRIVER/TriBITS
   Use GIT repository type
   Old revision of repository is: 1d79d874e5e6a8c5135ed4584a709c1c1197a91e
   New revision of repository is: 1d79d874e5e6a8c5135ed4584a709c1c1197a91e
   Gathering version information (one . per revision):
    
CTEST_UPDATE(...) returned '0'

So that means that the checkout commands look to be okay. So that means that this version of the code will put the git repo on the right branch with the right remote name right from the initial clone.

Now, what changes were made to the ctest_update() after commit a93bc1c that could break this?

{noformat}
$ git diff rab-github/278-improve-ctest-s-git-commands --not a93bc1c -- tribits

...
{noformat}

Looks very minimal.

I created the new local branch '278-improve-ctest-s-git-commands-tmp' and will work very incremnetally there. I will look at the diff above and make changes manually one statement at a time and see what happens ...

So I switched from:

SET(CTEST_UPDATE_COMMAND "${GIT_EXE}")

to:

SET(CTEST_GIT_COMMAND "${GIT_EXE}")

and it works:

Calling CTEST_UPDATE() to update base source repo '/ascldap/users/rabartl/Trilinos.base/BUILDS/GCC-4.8.3/MOCK_TRIBITS_CTEST_S_DRIVER/TriBITS' ...
   Updating the repository: /ascldap/users/rabartl/Trilinos.base/BUILDS/GCC-4.8.3/MOCK_TRIBITS_CTEST_S_DRIVER/TriBITS
   Use GIT repository type
   Old revision of repository is: 1d79d874e5e6a8c5135ed4584a709c1c1197a91e
   New revision of repository is: 1d79d874e5e6a8c5135ed4584a709c1c1197a91e
   Gathering version information (one . per revision):
    
CTEST_UPDATE(...) returned '0'

Now, the question is if switching to CTEST_GIT_UPDATE_CUSTOM also works. To do that, I will add:

    SET(CTEST_GIT_UPDATE_CUSTOM
      "${GIT_EXE} pull"
      )

but this time, I did not remove the var CTEST_GIT_COMMAND and ran:

$ rm -rf TriBITS ; time env CTEST_DASHBOARD_ROOT=$PWD     TriBITS_REPOSITORY_LOCATION=https://github.com/bartlettroscoe/TriBITS.git     TriBITS_BRANCH=278-improve-ctest-s-git-commands  CTEST_DO_CONFIGURE=OFF  CTEST_DO_BUILD=OFF  CTEST_DO_TEST=OFF     CTEST_DO_SUBMIT=OFF   ctest -V -S     /home/rabartl/Trilinos.base/Trilinos/TriBITS/cmake/ctest/generic_gcc/ctest_genertic_gcc_serial_debug.cmake &> console.out ; echo ; grep -A 9 "Calling CTEST_UPDATE.. to update base source repo" console.out 

real    0m3.836s
user    0m1.426s
sys     0m0.518s

Calling CTEST_UPDATE() to update base source repo '/ascldap/users/rabartl/Trilinos.base/BUILDS/GCC-4.8.3/MOCK_TRIBITS_CTEST_S_DRIVER/TriBITS' ...
   Updating the repository: /ascldap/users/rabartl/Trilinos.base/BUILDS/GCC-4.8.3/MOCK_TRIBITS_CTEST_S_DRIVER/TriBITS
   Use GIT repository type
   Old revision of repository is: 1d79d874e5e6a8c5135ed4584a709c1c1197a91e
   New revision of repository is: 1d79d874e5e6a8c5135ed4584a709c1c1197a91e
   Gathering version information (one . per revision):
    
   Update command failed: "/projects/sems/install/rhel6-x86_64/sems/utility/git/2.10.1/bin/git pull"
CTEST_UPDATE(...) returned '-1'

So you need to always set CTEST_GIT_COMMAND even if you try to also set CTEST_GIT_UPDATE_CUSTOM. but from this little experiment, it does appear that CTest does not actually work correctly when you try to set CTEST_GIT_UPDATE_CUSTOM :-( I can run that command just fine in the cloned TriBITS repo as shown by:

[rabartl@crf450 MOCK_TRIBITS_CTEST_S_DRIVER (crf450)]$ cd TriBITS/
[rabartl@crf450 TriBITS (278-improve-ctest-s-git-commands)]$ /projects/sems/install/rhel6-x86_64/sems/utility/git/2.10.1/bin/git pull
Already up-to-date.
[rabartl@crf450 TriBITS (278-improve-ctest-s-git-commands)]$ echo $?
0

So that is it, ctest is broken w.r.t. CTEST_GIT_UPDATE_CUSTOM :-(

I will go ahead and file a bug report for this to Kitware with reproducability instructions.

Stop, wait, I read the documentation wrong. The variable CTEST_GIT_UPDATE_CUSTOM is supported to be a single command to do the update, not a list of commands! So you need semi-colons to separate the arguments used in a command. Therefore, I wonder if I can provide a stringed-together set of commands concatenated with '&&' to do the update? So I tried that with:

    SET(CTEST_GIT_UPDATE_CUSTOM
      "${GIT_EXE}" clean -fdx
      && "${GIT_EXE}" reset --hard HEAD
      && "${GIT_EXE}" fetch ${${PROJECT_NAME}_GIT_REPOSITORY_REMOTE}
      )
    IF (${PROJECT_NAME}_BRANCH)
      LIST(APPEND CTEST_GIT_UPDATE_CUSTOM
        && "${GIT_EXE}" checkout -B ${${PROJECT_NAME}_BRANCH} --track
	  ${${PROJECT_NAME}_GIT_REPOSITORY_REMOTE}/${${PROJECT_NAME}_BRANCH} )
    ELSE()
      LIST(APPEND CTEST_GIT_UPDATE_CUSTOM
        "${GIT_EXE}" reset --hard @{u} )
    ENDIF()

Unfortunately that did not work :-( And that would not have even been portable anyway. Therefore, we need to move to a different approach. An approach that I think will work will be to run an execute_process() command in a cmake -P script. You can string together multiple commands in an execute_process() function call in a portable way. To make this visible, it would be good to capture the output from these git command and post this as a notes file to the build and also echo in the ctest -S STD output.

Bingo! I got it to work with a cmake -P script with CTEST_GIT_UPDATE_CUSTOM which does:

SET(CTEST_GIT_UPDATE_CUSTOM
  "${CMAKE_COMMAND}" -DGIT_EXE=${GIT_EXE}
    -DREMOTE_NAME=${${PROJECT_NAME}_GIT_REPOSITORY_REMOTE}
    -DBRANCH=${${PROJECT_NAME}_BRANCH}
    -DUNIT_TEST_MODE=${CTEST_DEPENDENCY_HANDLING_UNIT_TESTING}
    -P ${THIS_CMAKE_CURRENT_LIST_DIR}/tribits_ctest_update_commands.cmake
  )

That seems to work pretty well and I verified manually with real git clones that it can change to a new branch even when the existing tracking branch has its remote tracking branch disappear!

But I can't see the git output in case something fails. So to fix that, I need to create a wrapper cmake -P script that will run tribits_ctest_update_commands.cmake and then send its output to a file (UpdateCommandsOutput.txt) and then attach that a a CDash notes file.

(2/16/2019)

Okay, I have gotten everything done that I think needs to get done

TODOS from Feb 2019

TODOS:

  • Add variable ${PROJECT_NAME}_GIT_REPOSITORY_REMOTE and update the automated tests to use it [Done]

  • Change the code to use new CTEST_CHECKOUT_COMMAND command and update unit testing for this change to test with and without a named branch [Done]

  • Create a genetic TriBITS ctest -S driver *.cmake file and remove duplication with ctest_trusty_serial_debug.cmake [Done]

  • Do manual testing of the new CTEST_CHECKOUT_COMMAND by cloning my TriBITS repo and checking out with and without a named branch and renamed remote [Done]

  • Get a CTEST_GIT_UPDATE_CUSTOM command working that is robust to all use cases:

    • Create skeleton ctest -P script 'tribits_ctest_update_commands.cmake' that calls executate_process() and list that call from CTEST_GIT_UPDATE_CUSTOM and manually test [Done]
    • Fill out 'tribits_ctest_update_commands.cmake' to run all of the git update commands and test manually [Done]
    • Create 'tribits_ctest_update_commands_wrapper.cmake' write a file 'UpdateCommandsOutput.txt' in the build directory and attach as CDash notes file [Done]
  • Add strong unit tests for CTEST_GIT_UPDATE_CUSTOM for with and without a named branch:

    • Check that 'tribits_ctest_update_commands_wrapper.cmake' is actually called and correct commands that are used [Done]
    • Add strong unit tests for 'tribits_ctest_update_commands_wrapper.cmake' itself in unit testing mode for different use cases [Done]
  • Update extra-repo commands to match base repo commands, exactly [Done]

  • Improve print message for git operations in tribits_ctest_update_commands.cmake and update unit tests [Done]

  • Update documentation for tribits_ctest_driver() for these changes [Done]

  • Fix the unit tests for cdash_build_testing_date (run in loop every 0.5 sec and watch how they fail twice a minute) [Done]

  • Allow CTEST_NOTES_FILES to be read from env var:

    • Add and unit-test code to read in TAG file and parse it to get buildstarttime and cdashtrack [Done]
    • Create cmake -P script that prints out /Testing/ directory given [Done]
    • Create shell script 'list_cdash_notes_files_in_xml_file.sh ' that uses grep to print out a list of notes files for the current build defined by /Testing/TAG [Done]
    • Extend existing test that actually runs ctest -S locally and then grep the default notes files from BUILD/Testing//Notes.xml ... Can't because the Notes.xml file is not created unless you submit to CDash!!! [Failed]
  • Set up automated testing for actual clones and updates of git repos:

    • Create new GitHub repos for TribitsExampleMetaProject (with snapshot of TriBITS), TribitsExampleProject, and TribitsExampleProjectAddops [Done]
    • Create new test directory ctest_drivers/TribitsExampleMetaProject and automated tests that actually clone the git repos TribitsExampleMetaProject, TribitsExampleProject, and TribitsExampleProjectAddops and check that clones and updates work correctly for various use cases [Done]
    • Move the RepoVersion.txt file to the beginning of the submitted notes files [Done]
    • Set TriBITS_ENABLE_REAL_GIT_CLONE_TESTS=TRUE for TravisCI tests [Done]
    • Push branch and set up TriBITS PR to get TravisCI to test the branch [Done]
  • Clean up commits from branch '278-improve-ctest-s-git-commands-2' on 'branch 278-improve-ctest-s-git-commands' (remove commit 3fc9de1 'Fix raw failures of cdash_build_testing_date_UnitTests.py at start of the hour') [Done]

  • Push updated branch 'branch 278-improve-ctest-s-git-commands' to main GitHub TriBITS repo so TravisCI can test it [Done]

  • Create TriBITS PR to let TravisCI test [Done]

  • Push completed branch to TriBITS 'master' (as a merge commit) [Done]

  • Create Trilinos PR for updated 'tribits_github_snapshot' branch (snapshotting TriBITS 'master') [Done]

bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue May 8, 2020
Due to the configure attempt logic, this will also abort any actions in future
ctest -S invocations as well (as long as update and configure are attempted in
the same ctest -S invocation).
bartlettroscoe added a commit that referenced this issue May 8, 2020
Build/Test Cases Summary
Enabled Packages:
Enabled all Packages
0) MPI_DEBUG => passed: passed=376,notpassed=0 (1.82 min)
1) SERIAL_RELEASE => passed: passed=376,notpassed=0 (1.61 min)
Other local commits for this build/test group: 145ffb3
@bartlettroscoe
Copy link
Member Author

I believe that with commit bartlettroscoe@145ffb3 merged to 'master' in ee227d8 that this story is finally complete, at least for the base repo.

What is not resolved, is making the update of the extra repos robust as well. To do that, the logic that updates the extra repos really needs to executed inside of the ctest_update() command in the running of cmake -P tribits_ctest_update_commands.cmake script. Doing that would actually not be that hard but we would need to pass in the needed info about the extra repos to be updated.

@bartlettroscoe
Copy link
Member Author

What is not resolved, is making the update of the extra repos robust as well

With the creation of #338 to address reporting and handling of errors cloning/updating extra repos, we can descope this story and close it. (Trilinos does not have any extra repos used in its testing so this story has provided real value there.)

@bartlettroscoe bartlettroscoe changed the title Use features in newer CTest versions to improve and robustify git version control updates Use features in newer CTest versions to improve and robustify git version control updates for base repo Nov 13, 2020
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Aug 10, 2021
TriBITSPub#278)

This was created by commit:

  49d9c81 "tribits_ctest_driver(): Use more robust and better git commands and stronger testing (TriBITSPub#278, TRIL-260)"
  Author: Roscoe A. Bartlett <rabartl@sandia.gov>
  Date:   Thu Feb 14 13:42:11 2019 -0700

  A       test/ctest_driver/TribitsExampleMetaProject/CMakeLists.txt
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Aug 10, 2021
This were fixes from the previous comment:

  49d9c81 "tribits_ctest_driver(): Use more robust and better git commands and stronger testing (TriBITSPub#278, TRIL-260)"
  Author: Roscoe A. Bartlett <rabartl@sandia.gov>
  Date:   Thu Feb 14 13:42:11 2019 -0700
@bartlettroscoe bartlettroscoe moved this to Done in TriBITS Jun 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

No branches or pull requests

1 participant