From 6dfc17c48dc022b9ac353d750cfa30184a6e3b5d Mon Sep 17 00:00:00 2001 From: Tony Hsu Date: Wed, 27 Nov 2024 14:28:56 +0100 Subject: [PATCH] Output junit --- .circleci/config.yml | 34 +++++++++++++++++--------------- .rspec-local.example | 5 +++++ spec/datadog/release_gem_spec.rb | 1 + 3 files changed, 24 insertions(+), 16 deletions(-) create mode 100644 .rspec-local.example diff --git a/.circleci/config.yml b/.circleci/config.yml index 78e150cc934..ed9caf20e38 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -97,20 +97,6 @@ step_compute_bundle_checksum: &step_compute_bundle_checksum command: | bundle lock # Create Gemfile.lock cat Gemfile Gemfile.lock Appraisals gemfiles/*.gemfile gemfiles/*.gemfile.lock | md5sum > .circleci/bundle_checksum -step_run_all_tests: &step_run_all_tests - run: - name: Run tests - command: | - # Ensures it's possible to debug hung tests in CI - echo "--format=documentation" >> .rspec-local - - # Configure RSpec metadata exporter - echo " - --format=RspecJunitFormatter - --out='/tmp/rspec/-<%= ARGV.join.gsub('/', '-') %>.xml' - " >> .rspec-local - - bundle exec rake ci step_get_test_agent_trace_check_results: &step_get_test_agent_trace_check_results run: name: Get APM Test Agent Trace Check Results @@ -278,10 +264,26 @@ orbs: - docker-wait: host: "testagent" port: 9126 - - *step_run_all_tests + - run: + name: Run tests + command: | + ln -s .rspec-local.example .rspec-local + + bundle exec rake ci - *step_get_test_agent_trace_check_results + - run: + name: Upload JUnit reports to Datadog + when: always + command: | + ls -l tmp/rspec/*.xml + + curl -L --fail --retry 3 "https://github.com/DataDog/datadog-ci/releases/latest/download/datadog-ci_linux-x64" --output "/usr/local/bin/datadog-ci" && chmod +x /usr/local/bin/datadog-ci + + datadog-ci version + + DD_ENV=ci DATADOG_API_KEY=$JUNIT_UPLOAD_API_KEY DATADOG_SITE=datadoghq.com datadog-ci junit upload --service dd-trace-rb tmp/rspec/ - store_test_results: - path: /tmp/rspec + path: tmp/rspec - persist_to_workspace: root: . paths: diff --git a/.rspec-local.example b/.rspec-local.example new file mode 100644 index 00000000000..1e33c89bcc2 --- /dev/null +++ b/.rspec-local.example @@ -0,0 +1,5 @@ +<% require 'digest' %> +--require spec_helper +--format documentation +--format RspecJunitFormatter +--out <%= "tmp/rspec/" + Digest::MD5.hexdigest(ENV['BUNDLE_GEMFILE'] + ARGV.join) + ".xml" %> diff --git a/spec/datadog/release_gem_spec.rb b/spec/datadog/release_gem_spec.rb index acfd8826df5..24f9b022184 100644 --- a/spec/datadog/release_gem_spec.rb +++ b/spec/datadog/release_gem_spec.rb @@ -41,6 +41,7 @@ |static-analysis\.datadog\.yml |\.standard\.yml |\.standard_todo\.yml + |.rspec-local.example ) $ }x