Kaynağa Gözat

For Travis CI - revise ci_rebase task to auto prepare new CI branches.
Related to commit b902e863e61db6837ea9b3bbcd2050bc8fcd37c6.

Yao Wei Tjong 姚伟忠 11 yıl önce
ebeveyn
işleme
7b17a049a0
2 değiştirilmiş dosya ile 9 ekleme ve 3 silme
  1. 2 1
      .travis.yml
  2. 7 2
      Rakefile

+ 2 - 1
.travis.yml

@@ -56,7 +56,8 @@ before_install:
   - free -tm
   - mem=($(free -m |head -2 |tail -1)); if [ ${mem[6]} -eq 0 ]; then export BAD_VM=1; fi
   - export TAG=$(git describe --exact-match $TRAVIS_COMMIT 2>/dev/null); if [[ $TAG =~ [[:digit:]]+\.[[:digit:]]+ ]]; then export RELEASE_TAG=$TAG; fi
-  - if [ $RELEASE_TAG ] || ([ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]); then export SITE_UPDATE_ON_MASTER_COMMIT=$SITE_UPDATE; export COMMIT_MESSAGE=$(git log --format=%B -n 1 $TRAVIS_COMMIT); if [ "$CC" == "gcc" ] && ([ $RELEASE_TAG ] || echo $COMMIT_MESSAGE |grep -cq '\[ci package\]'); then export PACKAGE_UPLOAD=1; fi; fi
+  - export COMMIT_MESSAGE=$(git log --format=%B -n 1 $TRAVIS_COMMIT)
+  - if [ $RELEASE_TAG ] || ([ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]); then export SITE_UPDATE_ON_MASTER_COMMIT=$SITE_UPDATE; if [ "$CC" == "gcc" ] && ([ $RELEASE_TAG ] || echo $COMMIT_MESSAGE |grep -cq '\[ci package\]'); then export PACKAGE_UPLOAD=1; fi; fi
   - if [ "$SITE_UPDATE_ON_MASTER_COMMIT" -o "$PACKAGE_UPLOAD" ]; then travis_retry sudo add-apt-repository ppa:george-edison55/precise-backports -y; fi
   - travis_retry sudo apt-get update -q -y
 install:

+ 7 - 2
Rakefile

@@ -139,9 +139,14 @@ end
 # Usage: NOT intended to be used manually (if you insist then try: GIT_NAME=... GIT_EMAIL=... GH_TOKEN=... TRAVIS_BRANCH=... rake ci_rebase)
 desc 'Rebase all CI mirror branches'
 task :ci_rebase do
-  system 'git config user.name $GIT_NAME && git config user.email $GIT_EMAIL && git remote set-url --push origin https://[email protected]/$TRAVIS_REPO_SLUG.git'
+  #system 'git config user.name $GIT_NAME && git config user.email $GIT_EMAIL && git remote set-url --push origin https://[email protected]/$TRAVIS_REPO_SLUG.git'
   baseline = ENV['RELEASE_TAG'] || "origin/#{ENV['TRAVIS_BRANCH']}"
-  [ 'Android-CI', 'RPI-CI', 'OSX-CI' ].each { |ci| branch = ENV['RELEASE_TAG'] || ENV['TRAVIS_BRANCH'] == 'master' ? ci : "#{ENV['TRAVIS_BRANCH']}-#{ci}"; system "if git fetch origin #{branch}:#{branch} 2>/dev/null; then git rebase #{baseline} #{branch} && git push -qf -u origin #{branch} >/dev/null 2>&1; fi" or abort "Failed to rebase #{branch} mirror branch" }
+  enable = /\[ci rebase\]/ =~ ENV['COMMIT_MESSAGE']
+  [ 'Android-CI', 'RPI-CI', 'OSX-CI' ].each { |ci| ci_branch = ENV['RELEASE_TAG'] || ENV['TRAVIS_BRANCH'] == 'master' ? ci : "#{ENV['TRAVIS_BRANCH']}-#{ci}"; system "if git fetch origin #{ci_branch}:#{ci_branch} 2>/dev/null; then git rebase #{baseline} #{ci_branch} && git push -qf -u origin #{ci_branch} >/dev/null 2>&1; elif [ #{enable} ]; then git checkout -b #{ci_branch} #{ENV['TRAVIS_BRANCH']} && rm .travis.yml && wget -q https://raw.githubusercontent.com/#{ENV['TRAVIS_REPO_SLUG']}/#{ci}/.travis.yml && cat <<EOF >README.md && git add -A . && git commit -m 'For Travis CI - switch CI build to use #{ci.split('-').first} build environment.' && git push -qf -u origin #{ci_branch} >/dev/null 2>&1; fi
+This is a mirror branch which is constantly being \"rebased\" from #{ENV['TRAVIS_BRANCH']} branch. Please DO NOT checkout from this mirror branch! The purpose of this mirror branch is to perform CI build using #{ci.split('-').first} build environment on Travis-CI.org. See #{ENV['TRAVIS_BRANCH']} branch for CI build result using Ubuntu Linux build environment.
+
+[![Build Status](https://travis-ci.org/#{ENV['TRAVIS_REPO_SLUG']}.png?branch=#{ci_branch})](https://travis-ci.org/#{ENV['TRAVIS_REPO_SLUG']}?branch=#{ci_branch})
+EOF" or abort "Failed to rebase #{ci_branch} mirror branch" }
 end
 
 # Usage: NOT intended to be used manually (if you insist then try: rake ci_package_upload)