Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[travis][ci] launch core and extras if CI run successful #3214

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ cache:
- vendor/cache
- $HOME/embedded

matrix:
fast_finish: true

env:
global:
- CONCURRENCY=2
Expand All @@ -26,11 +23,8 @@ env:
- PIP_CACHE=$HOME/.cache/pip
- VOLATILE_DIR=/tmp
- DD_CASHER_DIR=/tmp/casher
- secure: cljGaYMtRkLuW1xjGyF8W0ACrkBwHQTGJUaEoqxtIEJaVjLwcuznny9qzuQvF8YJhjs7g9eRAsZqWGpgRw765rzUB5C4Cp5GpUdTHS/fPINj3AXRzGztL2m6DHBidjEyYaX8dryO4xR0uCULwp4bSI0Rht71VqE90/6z1ehIzBs=
matrix:
- TRAVIS_FLAVOR=default
- TRAVIS_FLAVOR=core_integration
- TRAVIS_FLAVOR=checks_mock
- TRAVIS_FLAVOR=system

# Override travis defaults with empty jobs
before_install: echo "OVERRIDING TRAVIS STEPS"
Expand All @@ -43,9 +37,15 @@ script:
# Needed if no cache exists
- mkdir -p $INTEGRATIONS_DIR
- ls -al $INTEGRATIONS_DIR
- 'rake ci:run'
- 'rake ci:run[default]'
- 'rake ci:run[core_integration]'
- 'rake ci:run[checks_mock]'
- 'rake ci:run[system]'
- ls -al $INTEGRATIONS_DIR

after_success:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we do this after every run (failed or not)? This should not run with PR's so it's not something that will clobber our CI in the SDK repos (and CI activity in the dd-agent should come way down anyway, so it shouldn't be too bad).

- 'rake ci:trigger[integrations-core]'
- 'rake ci:trigger[integrations-extras]'

after_failure:
- echo "Logs from installation process come here / DEBUG LOGS"
Expand Down
30 changes: 30 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env rake
# encoding: utf-8
# 3p
require 'json'
require 'net/http'
require 'rake/clean'
require 'rubocop/rake_task'

Expand Down Expand Up @@ -87,6 +89,34 @@ namespace :ci do
flavors = flavor.split(',')
flavors.each { |f| Rake::Task["ci:#{f}:execute"].invoke }
end

desc 'Trigger remote CI'
task :trigger, :repo do |_, args|
abort 'Task only applies to travis builds.' if !ENV['TRAVIS'] || !ENV['TRAVIS_API_TOKEN']
abort 'Task skipped for Pull Requests.' if !ENV['TRAVIS_PULL_REQUEST'].nil? && ENV['TRAVIS_PULL_REQUEST'].casecmp('false')
repo = "DataDog%2F#{args[:repo]}"
url = "https://api.travis-ci.org/repo/#{repo}/requests"
body = { 'request' => { 'branch' => 'master' } }.to_json

uri = URI(url)
res = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
req = Net::HTTP::Post.new(uri.path)
req['Content-Type'] = 'application/json'
req['Accept'] = 'application/json'
req['Travis-API-Version'] = '3'
req['Authorization'] = "token #{ENV['TRAVIS_API_TOKEN']}"
# The body needs to be a JSON string, use whatever you know to parse Hash to JSON
req.body = body
http.request(req)
end

case res
when Net::HTTPSuccess then
puts "Build Triggered remotely for: #{url}"
else
puts "Error triggering build (error #{res.code}): #{url}"
end
end
end

task default: ['lint', 'ci:run']