Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F61837766
test_repo.sh
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Thu, May 9, 07:03
Size
1 KB
Mime Type
text/x-shellscript
Expires
Sat, May 11, 07:03 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
17565124
Attached To
rPHINFRA c4science
test_repo.sh
View Options
#!/bin/bash -e
MAIL_BOT
=
'admin+bot@c4science.ch'
MAIL_MONIT
=
'jean-baptiste.aubort@epfl.ch'
TMPDIR
=
$(
mktemp -d
)
LOGFILE
=
'/tmp/test_repo.log'
REPO_GIT
=
'ssh://git@c4science.ch/diffusion/PHMONITGIT/monitoring-git.git'
REPO_SVN
=
'svn+ssh://git@c4science.ch/diffusion/PHMONITSVN/'
REPO_HG
=
'ssh://git@c4science.ch/diffusion/PHMONITHG/monitoring-hg/'
monit
()
{
vcs
=
$1
action
=
$2
cmd
=
$3
echo
-n
"c4science_vcs,vcs=$vcs,action=$action "
_duration
=
$(
echo
"$(date +%s)+$(date +%3N)/1000"
| bc -l
)
$cmd
1> /dev/null
||
error
$name
_exit
=
$?
_time
=
$(
echo
"$(date +%s)-$_duration + $(date +%3N)/1000"
| bc -l
)
echo
"duration=$_time,exitcode=$_exit"
}
error
()
{
cat
$LOGFILE
| mail -s
"Error $1"
$MAIL_MONIT
}
prepare
()
{
git config --global user.name
'c4science bot'
git config --global user.email
$MAIL_BOT
echo
-e
"[ui]\nusername = scitas-bot <$MAIL_BOT>"
> ~/.hgrc
}
clean
()
{
cd
rm -fr
$TMPDIR
}
#
# GIT
#
test_clone_git
()
{
git clone
$REPO_GIT
$TMPDIR
}
test_push_git
()
{
cd
$TMPDIR
echo test
>> README.md
git add README.md
git commit -m
"Testing GIT..."
git push origin master
}
test_lfs_git
()
{
FILE
=
$(
mktemp --suffix .lfs -p
$TMPDIR
)
cd
$TMPDIR
cat /dev/urandom | tr -dc
'a-zA-Z0-9'
| fold -w 64 | head -n 1 >
$FILE
git lfs track
$(
basename
$FILE
)
git add
$FILE
git commit -am
"Testing GIT LFS..."
git push origin master
}
#
# SVN
#
test_checkout_svn
()
{
svn checkout
$REPO_SVN
$TMPDIR
}
test_commit_svn
()
{
cd
$TMPDIR
echo test
>> README.md
svn commit -m
"Testing SVN..."
}
#
# Mercurial
#
test_clone_hg
()
{
hg clone
$REPO_HG
$TMPDIR
}
test_push_hg
()
{
cd
$TMPDIR
echo test
>> README.md
hg commit -m
"Testing Mercurial..."
hg push
}
exec
2>
$LOGFILE
date >>
$LOGFILE
prepare
monit git clone test_clone_git
monit git push test_push_git
monit git lfs test_lfs_git
clean
monit svn checkout test_checkout_svn
monit svn commit test_commit_svn
clean
monit hg clone test_clone_hg
monit hg push test_push_hg
clean
Event Timeline
Log In to Comment