Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F63108000
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
Fri, May 17, 20:09
Size
2 KB
Mime Type
text/x-shellscript
Expires
Sun, May 19, 20:09 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
17732987
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_LFS
=
'ssh://git@c4science.ch/diffusion/PHMONITLFS/monitoring-git-lfs.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 "
_start
=
$(
get_time
)
$cmd
1> /dev/null
_exit
=
$?
_end
=
$(
get_time
)
_duration
=
$(
echo
$_end
-
$_start
| bc -l
)
if
[
$error
!
=
0
]
;
then
error
$vcs
$action
fi
echo
"duration=$_duration,exitcode=$_exit"
}
get_time
()
{
_date
=
$(
date +
'%s %3N'
)
_sec
=
$(
echo
$_date
| awk
'{print $1}'
)
_dec
=
$(
echo
"$(echo $_date | awk '{print $2}')/1000"
| bc -l
)
echo
"$_sec+$_dec"
| bc -l
}
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
}
#
# GIT LFS
#
test_clone_lfs_git
()
{
git clone
$REPO_LFS
$TMPDIR
}
test_remove_lfs_git
()
{
cd
$TMPDIR
git lfs untrack *.lfs
git rm -f *.lfs
git commit -am
"Removing LFS file"
git push origin master
}
test_push_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 install
git lfs track
$(
basename
$FILE
)
git add
$FILE
git add .gitattributes
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
}
#
# MAIN
#
exec
2>
$LOGFILE
date >>
$LOGFILE
prepare
monit git clone test_clone_git
monit git push test_push_git
clean
monit lfs clone test_clone_lfs_git
monit lfs remove test_remove_lfs_git
monit lfs push test_push_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