fhem-mirror/.travis.yml

91 lines
3.1 KiB
YAML

dist: xenial
sudo: required
language: bash
addons:
apt:
sources:
- github-git-lfs-xenial
- ppa:git-core/ppa
packages:
- git
- subversion
- libsvn-perl
- libyaml-perl
- libterm-readkey-perl
branches:
only:
- travis
notifications:
email: false
before_install: |
cd /tmp
apt-get download git-svn;
sudo dpkg --ignore-depends=git -i git-svn*.deb;
rvm all do gem install svn2git;
sudo sed -i 's/die "Failed to strip path/print "Failed to strip path/g' `find /usr -name Fetcher.pm -type f 2> /dev/null | grep Git | head -n 1`;
svn log -q https://svn.fhem.de/fhem --xml --quiet | grep author | sort -u | perl -pe 's/.*>(.*?)<.*/$1 = $1 <>/' > $TRAVIS_BUILD_DIR/authors_svn.txt;
cat $TRAVIS_BUILD_DIR/authors.txt $TRAVIS_BUILD_DIR/authors_svn.txt | sort -u -k1,1 > $TRAVIS_BUILD_DIR/authors_merged.txt;
ls -la $TRAVIS_BUILD_DIR/authors_merged.txt;
if [[ ! -d "$TRAVIS_BUILD_DIR/src/fhem-mirror/.git" ]]; then
git init "$TRAVIS_BUILD_DIR/src/fhem-mirror" ;
cd "$TRAVIS_BUILD_DIR/src/fhem-mirror";
git svn init --trunk=trunk --prefix=svn/ --no-metadata https://svn.fhem.de/fhem ;
git config --add svn-remote.svn.preserve-empty-dirs "true" ;
git config --add svn-remote.svn.placeholder-filename ".gitkeep" ;
git config --add svn.authorsfile "$TRAVIS_BUILD_DIR/authors_merged.txt" ;
else
echo "Current .git/config file content:";
cat $TRAVIS_BUILD_DIR/src/fhem-mirror/.git/config;
fi
install: |
export SVN_FETCH_STATUS="incomplete";
cd "$TRAVIS_BUILD_DIR/src/fhem-mirror";
timeout 2790 git svn -q fetch ;
RET=$? ;
if [[ $RET == 0 ]]; then
export SVN_FETCH_STATUS="complete";
git checkout -f "master"
git rebase "remotes/svn/trunk"
elif [[ $RET != 124 ]]; then
export SVN_FETCH_STATUS="error";
fi
script: |
if [[ "$SVN_FETCH_STATUS" == "error" ]]; then
echo "A permanent error occured"
exit 1
elif [[ "$SVN_FETCH_STATUS" != "complete" ]]; then
if [[ -n "$TRAVIS_API_TOKEN" ]]; then
body='{"request":{"branch":"travis","message":"Extend build runtime"}}';
curl -s -X POST \
-H "Content-Type: application/json" -H "Accept: application/json" -H "Travis-API-Version: 3" -H "Authorization: token $TRAVIS_API_TOKEN" -d "$body" https://api.travis-ci.com/repo/fhem%2Ffhem-mirror/requests ;
else
echo "TRAVIS_API_TOKEN missing - unable to automatically trigger next build run"
fi
fi
cache:
directories:
- $TRAVIS_BUILD_DIR/src/fhem-mirror/
after_success: |
if [[ "$SVN_FETCH_STATUS" != "complete" ]]; then
echo "Maximum runtime reached - will continue next run!";
elif [[ -n "$GITHUB_API_KEY" ]]; then
cd "$TRAVIS_BUILD_DIR/src/fhem-mirror";
echo "Will now push the following directory structure to remote repo:";
ls -la ;
git remote add origin https://jpawlowski:$GITHUB_API_KEY@github.com/fhem/fhem-mirror.git ;
git config --add remote.origin.push 'refs/remotes/svn/trunk:refs/heads/master' ;
git push --follow-tags --force origin master ;
git remote remove origin ;
else
echo "GITHUB_API_KEY missing - unable to push updated repository";
exit 1;
fi