|
|
@@ -185,6 +185,9 @@ end
|
|
|
# Usage: NOT intended to be used manually (if you insist then try: rake ci)
|
|
|
desc 'Configure, build, and test Urho3D project'
|
|
|
task :ci do
|
|
|
+ # Skip if only performing CI for selected branches and the current branch is not in the list
|
|
|
+ matched = /\[ci only:(.*?)\]/.match(ENV['COMMIT_MESSAGE'])
|
|
|
+ next if matched && !matched[1].split(/[ ,]/).reject!(&:empty?).map { |i| /#{ENV['TRAVIS_BRANCH']}/ =~ i }.any?
|
|
|
# Obtain our custom data, if any
|
|
|
data = YAML::load(File.open(".travis.yml"))['data']
|
|
|
data['excluded_sample'].each { |name| ENV["EXCLUDE_SAMPLE_#{name}"] = '1' } if data && data['excluded_sample']
|
|
|
@@ -274,20 +277,23 @@ end
|
|
|
desc 'Create all CI mirror branches'
|
|
|
task :ci_create_mirrors do
|
|
|
# Skip if there are more commits since this one
|
|
|
- abort 'Skip creating mirror branches due to moving HEAD' unless `git fetch -qf origin master; git log -1 --pretty=format:'%H' FETCH_HEAD` == ENV['TRAVIS_COMMIT']
|
|
|
+ abort 'Skipped creating mirror branches due to moving HEAD' unless `git fetch -qf origin master; git log -1 --pretty=format:'%H' FETCH_HEAD` == ENV['TRAVIS_COMMIT']
|
|
|
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'
|
|
|
scan = ENV['PACKAGE_UPLOAD'] || /\[ci scan\]/ =~ ENV['COMMIT_MESSAGE'] # Limit the frequency of scanning
|
|
|
+ matched = /\[ci only:(.*?)\]/.match(ENV['COMMIT_MESSAGE'])
|
|
|
+ ci_only = matched ? matched[1].split(/[ ,]/).reject!(&:empty?) : nil
|
|
|
+ ci_only.push('Coverity-Scan') if ci_only && scan
|
|
|
stream = YAML::load_stream(File.open('.travis.yml'))
|
|
|
notifications = stream[0]['notifications']
|
|
|
notifications['email']['recipients'] = `git show -s --format='%ae %ce' #{ENV['TRAVIS_COMMIT']}`.chomp.split.uniq unless notifications['email']['recipients']
|
|
|
- stream.drop(1).each { |doc| branch = doc.delete('branch'); ci = branch['name']; ci_branch = ENV['RELEASE_TAG'] || (ENV['TRAVIS_BRANCH'] == 'master' && ENV['TRAVIS_PULL_REQUEST'] == 'false') ? ci : (ENV['TRAVIS_PULL_REQUEST'] == 'false' ? "#{ENV['TRAVIS_BRANCH']}-#{ci}" : "PR ##{ENV['TRAVIS_PULL_REQUEST']}-#{ci}"); unless branch['active'] || (scan && /Scan/ =~ ci); system "if git fetch origin #{ci_branch}:#{ci_branch} 2>/dev/null; then git push -qf origin --delete #{ci_branch}; fi"; next; end; lastjob = doc['matrix'] && doc['matrix']['include'] ? doc['matrix']['include'].length : (doc['env']['matrix'] ? doc['env']['matrix'].length : 1); doc['after_script'] = (lastjob == 1 ? '%s' : "if [ ${TRAVIS_JOB_NUMBER##*.} == #{lastjob} ]; then %s; fi") % 'rake ci_delete_mirror'; doc['notifications'] = notifications unless doc['notifications']; File.open('.travis.yml.doc', 'w') { |file| file.write doc.to_yaml }; system "git checkout -B #{ci_branch} && rm .travis.yml && mv .travis.yml.doc .travis.yml && git add -A . && git commit -qm '#{branch['description']}' && git push -qf -u origin #{ci_branch} >/dev/null 2>&1 && git checkout -q -" or abort "Failed to create #{ci_branch} mirror branch" }
|
|
|
+ stream.drop(1).each { |doc| branch = doc.delete('branch'); ci = branch['name']; ci_branch = ENV['RELEASE_TAG'] || (ENV['TRAVIS_BRANCH'] == 'master' && ENV['TRAVIS_PULL_REQUEST'] == 'false') ? ci : (ENV['TRAVIS_PULL_REQUEST'] == 'false' ? "#{ENV['TRAVIS_BRANCH']}-#{ci}" : "PR ##{ENV['TRAVIS_PULL_REQUEST']}-#{ci}"); unless (ci_only && ci_only.map { |i| /#{ci}/ =~ i }.any?) || (!ci_only && (branch['active'] || (scan && /Scan/ =~ ci))); system "if git fetch origin #{ci_branch}:#{ci_branch} 2>/dev/null; then git push -qf origin --delete #{ci_branch}; fi"; next; end; lastjob = doc['matrix'] && doc['matrix']['include'] ? doc['matrix']['include'].length : (doc['env']['matrix'] ? doc['env']['matrix'].length : 1); doc['after_script'] = (lastjob == 1 ? '%s' : "if [ ${TRAVIS_JOB_NUMBER##*.} == #{lastjob} ]; then %s; fi") % 'rake ci_delete_mirror'; doc['notifications'] = notifications unless doc['notifications']; File.open('.travis.yml.doc', 'w') { |file| file.write doc.to_yaml }; system "git checkout -B #{ci_branch} && rm .travis.yml && mv .travis.yml.doc .travis.yml && git add -A . && git commit -qm '#{branch['description']}' && git push -qf -u origin #{ci_branch} >/dev/null 2>&1 && git checkout -q -" or abort "Failed to create #{ci_branch} mirror branch" }
|
|
|
end
|
|
|
|
|
|
# Usage: NOT intended to be used manually
|
|
|
desc 'Delete CI mirror branch'
|
|
|
task :ci_delete_mirror do
|
|
|
# Skip if there are more commits since this one or if this is a release build
|
|
|
- abort "Skip deleting #{ENV['TRAVIS_BRANCH']} mirror branch" unless `git fetch -qf origin master; git log -1 --pretty=format:'%H' FETCH_HEAD` == `git show -s --format='%H' #{ENV['TRAVIS_COMMIT']}`.chomp && !ENV['RELEASE_TAG']
|
|
|
+ abort "Skipped deleting #{ENV['TRAVIS_BRANCH']} mirror branch (%s vs %s)" % [`git log -1 --pretty=format:'%H' FETCH_HEAD`, `git show -s --format='%H' #{ENV['TRAVIS_COMMIT']}`.chomp] unless `git fetch -qf origin master; git log -1 --pretty=format:'%H' FETCH_HEAD` == `git show -s --format='%H' #{ENV['TRAVIS_COMMIT']}`.chomp && !ENV['RELEASE_TAG']
|
|
|
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 push -qf origin --delete #{ENV['TRAVIS_BRANCH']}" or abort "Failed to delete #{ENV['TRAVIS_BRANCH']} mirror branch"
|
|
|
end
|