Skip to content

Commit

Permalink
ci: add dd agent to azure pipelines (#241)
Browse files Browse the repository at this point in the history
  • Loading branch information
jirikuncar authored Nov 19, 2020
1 parent 752569a commit b2fd098
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 15 deletions.
44 changes: 36 additions & 8 deletions .azure-pipelines/all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,36 @@ pr:
include:
- master

resources:
containers:
- container: datadog-agent
image: datadog/agent:7
options: --health-cmd="exit 0" --health-interval=1s
ports:
- 8125:8125
- 8126:8126/tcp
env:
DD_API_KEY: $(ddAPIKey)
DD_APM_ENABLED: "true"
DD_APM_NON_LOCAL_TRAFFIC: "true"
DD_LOGS_ENABLED: "true"
DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL: "true"
DD_AC_EXCLUDE: "name:datadog-agent"
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- /proc/:/host/proc/:ro
- /sys/fs/cgroup/:/host/sys/fs/cgroup:ro

jobs:
- job: UnitTests
pool:
vmImage: "Ubuntu-16.04"
container:
image: ruby:$(RUBY_VERSION)
options: >-
-l com.datadoghq.ad.logs="[{\"source\": \"Azure Pipeline\", \"service\": \"dogapi-rb\"}]"
services:
datadog-agent: datadog-agent
strategy:
matrix:
Rb24:
Expand All @@ -31,17 +57,19 @@ jobs:
RUBY_VERSION: '2.6'
TASK: rubocop
steps:
- task: UseRubyVersion@0
displayName: Use Ruby $(RUBY_VERSION)
inputs:
versionSpec: $(RUBY_VERSION)
addToPath: true
- script: |
gem install bundler
bundle install --retry=3 --jobs=4
- script: bundle install --retry=3 --jobs=4
displayName: 'bundle install'
env:
GEM_HOME: '~/.gem'
- script: bundle exec rake $(TASK)
displayName: Run $(TASK) via bundle
env:
GEM_HOME: '~/.gem'
DD_AGENT_HOST: datadog-agent
DD_ENV: ci
DD_SERVICE: dogapi-rb
DD_TAGS: "team:integration-tools-and-libraries,runtime:ruby-$(RUBY_VERSION),ci.job.name:$(System.JobName),matrix:$(TASK)"
DD_TRACE_ANALYTICS_ENABLED: "true"
- job: TestRuby19
pool:
vmImage: "Ubuntu-16.04"
Expand Down
4 changes: 1 addition & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ source 'https://rubygems.org'
gemspec

group :test do
gem 'ddtrace', git: 'https://github.com/datadog/dd-trace-rb'
gem 'rubocop', "~> 0.49.0"
# NOTE: rake < 12.3.3 is vulnerable to CVE-2020-8130, but we only use it as a test dependency
# and neither our users nor our CI is vulnerable in any way
gem 'rake', '>= 2.4.2'
gem 'rspec'
gem 'simplecov'
gem 'webmock'
Expand Down
3 changes: 0 additions & 3 deletions Gemfile_1.9
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ gemspec

group :test do
gem 'rubocop', "~> 0.41.0"
# NOTE: rake < 12.3.3 is vulnerable to CVE-2020-8130, but we only use it as a test dependency
# and neither our users nor our CI is vulnerable in any way
gem 'rake', '>= 2.4.2'
gem 'rspec'
gem 'simplecov', "~> 0.11.2"
gem 'webmock'
Expand Down
14 changes: 13 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,19 @@
add_filter 'spec'
end

WebMock.disable_net_connect!(allow_localhost: false)
webmock_allow = []

begin
require 'ddtrace'
Datadog.configure do |c|
c.use :rspec, service_name: 'dogapi-rb'
end
webmock_allow << "#{Datadog::Transport::HTTP.default_hostname}:#{Datadog::Transport::HTTP.default_port}"
rescue LoadError
puts 'ddtrace gem not found'
end

WebMock.disable_net_connect!(allow_localhost: false, allow: webmock_allow)

# include our code and methods
require 'dogapi'
Expand Down

0 comments on commit b2fd098

Please sign in to comment.