|
@@ -187,7 +187,7 @@ desc 'Configure, build, and test Urho3D project'
|
|
|
task :ci do
|
|
task :ci do
|
|
|
# Skip if only performing CI for selected branches and the current branch is not in the list
|
|
# Skip if only performing CI for selected branches and the current branch is not in the list
|
|
|
matched = /\[ci only:(.*?)\]/.match(ENV['COMMIT_MESSAGE'])
|
|
matched = /\[ci only:(.*?)\]/.match(ENV['COMMIT_MESSAGE'])
|
|
|
- next if matched && !matched[1].split(/[ ,]/).reject!(&:empty?).map { |i| /#{ENV['TRAVIS_BRANCH']}/ =~ i }.any?
|
|
|
|
|
|
|
+ next if matched && !matched[1].split(/[ ,]/).reject!(&:empty?).map { |i| /#{i}/ =~ ENV['TRAVIS_BRANCH'] }.any?
|
|
|
# Obtain our custom data, if any
|
|
# Obtain our custom data, if any
|
|
|
data = YAML::load(File.open(".travis.yml"))['data']
|
|
data = YAML::load(File.open(".travis.yml"))['data']
|
|
|
data['excluded_sample'].each { |name| ENV["EXCLUDE_SAMPLE_#{name}"] = '1' } if data && data['excluded_sample']
|
|
data['excluded_sample'].each { |name| ENV["EXCLUDE_SAMPLE_#{name}"] = '1' } if data && data['excluded_sample']
|
|
@@ -195,6 +195,16 @@ task :ci do
|
|
|
if ENV['CI'] && ENV['PACKAGE_UPLOAD'] && !ENV['RELEASE_TAG']
|
|
if ENV['CI'] && ENV['PACKAGE_UPLOAD'] && !ENV['RELEASE_TAG']
|
|
|
system 'git fetch --unshallow' or abort 'Failed to unshallow cloned repository'
|
|
system 'git fetch --unshallow' or abort 'Failed to unshallow cloned repository'
|
|
|
end
|
|
end
|
|
|
|
|
+ # Use internal cache store instead of using Travis CI one (this is a workaround for using ccache on Travis CI legacy build infra)
|
|
|
|
|
+ if ENV['USE_CCACHE'].to_i == 2
|
|
|
|
|
+ puts 'Setting up build cache'
|
|
|
|
|
+ job_number = ENV['TRAVIS_JOB_NUMBER'].split('.')[1]
|
|
|
|
|
+ job_number = ".#{job_number}" if job_number
|
|
|
|
|
+ repo_slug = "#{ENV['TRAVIS_REPO_SLUG'].split('/')[0]}/cache-store.git"
|
|
|
|
|
+ # Do not abort even when it fails here
|
|
|
|
|
+ system "time if `git clone -q --depth 1 --branch #{ENV['TRAVIS_BRANCH']}#{job_number} https://github.com/#{repo_slug} ~/.ccache`; then ccache -z; else git clone -q --depth 1 https://github.com/#{repo_slug} ~/.ccache && cd ~/.ccache && git -qf checkout -b #{ENV['TRAVIS_BRANCH']}#{job_number} && ccache -M 100M; fi"
|
|
|
|
|
+ puts "\n"
|
|
|
|
|
+ end
|
|
|
# Clear ccache on demand
|
|
# Clear ccache on demand
|
|
|
system 'ccache -C' if /\[ccache clear\]/ =~ ENV['COMMIT_MESSAGE']
|
|
system 'ccache -C' if /\[ccache clear\]/ =~ ENV['COMMIT_MESSAGE']
|
|
|
# Packaging always use Release configuration
|
|
# Packaging always use Release configuration
|
|
@@ -202,7 +212,7 @@ task :ci do
|
|
|
$configuration = 'Release'
|
|
$configuration = 'Release'
|
|
|
$testing = 0
|
|
$testing = 0
|
|
|
else
|
|
else
|
|
|
- $configuration = ENV['CI'] && ENV['USE_CCACHE'].to_i == 1 ? 'Release' : 'Debug' # Aways use a same build configuration to keep ccache's cache size small when on Travis CI
|
|
|
|
|
|
|
+ $configuration = ENV['CI'] && ENV['USE_CCACHE'].to_i > 0 ? 'Release' : 'Debug' # Aways use a same build configuration to keep ccache's cache size small when on Travis CI
|
|
|
# Only 64-bit Linux environment with virtual framebuffer X server support and not MinGW build; or OSX build environment and not iOS build; or Emscripten build environment are capable to run tests
|
|
# Only 64-bit Linux environment with virtual framebuffer X server support and not MinGW build; or OSX build environment and not iOS build; or Emscripten build environment are capable to run tests
|
|
|
$testing = (ENV['LINUX'] && !ENV['URHO3D_64BIT']) || (ENV['OSX'] && ENV['IOS'].to_i != 1) || ENV['EMSCRIPTEN'] ? 1 : 0
|
|
$testing = (ENV['LINUX'] && !ENV['URHO3D_64BIT']) || (ENV['OSX'] && ENV['IOS'].to_i != 1) || ENV['EMSCRIPTEN'] ? 1 : 0
|
|
|
if $testing
|
|
if $testing
|
|
@@ -221,6 +231,12 @@ task :ci do
|
|
|
# GCC or Clang
|
|
# GCC or Clang
|
|
|
makefile_ci
|
|
makefile_ci
|
|
|
end
|
|
end
|
|
|
|
|
+ # Upload cache to internal cache store
|
|
|
|
|
+ if ENV['USE_CCACHE'].to_i == 2
|
|
|
|
|
+ puts "\nStoring build cache"
|
|
|
|
|
+ # Do not abort even when it fails here
|
|
|
|
|
+ system "time (cd ~/.ccache && git config user.name $GIT_NAME && git config user.email $GIT_EMAIL && git remote set-url --push origin https://[email protected]/#{repo_slug} && git add -A . && git commit --amend -qm \"Travis CI: cache update at #{Time.now.utc}.\" && git push -qf -u origin #{ENV['TRAVIS_BRANCH']}#{job_number} >/dev/null 2>&1)"
|
|
|
|
|
+ end
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
# Usage: NOT intended to be used manually
|
|
# Usage: NOT intended to be used manually
|
|
@@ -286,7 +302,7 @@ task :ci_create_mirrors do
|
|
|
stream = YAML::load_stream(File.open('.travis.yml'))
|
|
stream = YAML::load_stream(File.open('.travis.yml'))
|
|
|
notifications = stream[0]['notifications']
|
|
notifications = stream[0]['notifications']
|
|
|
notifications['email']['recipients'] = `git show -s --format='%ae %ce' #{ENV['TRAVIS_COMMIT']}`.chomp.split.uniq unless notifications['email']['recipients']
|
|
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 (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" }
|
|
|
|
|
|
|
+ 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| /#{i}/ =~ ci }.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'] = [*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
|
|
end
|
|
|
|
|
|
|
|
# Usage: NOT intended to be used manually
|
|
# Usage: NOT intended to be used manually
|