Skip to content

Implement automatic Test Optimization instrumentation for Ruby projects#476

Merged
nikita-tkachenko-datadog merged 9 commits into
jenkinsci:masterfrom
anmarchenko:anmarchenko/ruby-auto-instrumentation
Dec 10, 2024
Merged

Implement automatic Test Optimization instrumentation for Ruby projects#476
nikita-tkachenko-datadog merged 9 commits into
jenkinsci:masterfrom
anmarchenko:anmarchenko/ruby-auto-instrumentation

Conversation

@anmarchenko

@anmarchenko anmarchenko commented Dec 6, 2024

Copy link
Copy Markdown
Contributor

Requirements for Contributing to this repository

  • Fill out the template below. Any pull request that does not include enough information to be reviewed in a timely manner may be closed at the maintainers' discretion.
  • The pull request must only fix one issue at the time.
  • The pull request must update the test suite to demonstrate the changed functionality.
  • After you create the pull request, all status checks must be pass before a maintainer reviews your contribution. For more details, please see CONTRIBUTING.

What does this PR do?

Adds automatic test optimization tracer configuration for Ruby projects.

Description of the Change

The change is done similarly to #400

  • Adds RubyConfiguration class that checks versions for ruby, gem, bundle tools available in the workspace. Afterwards it executes bundle config set frozen false to unfreeze the dependencies (required to add a new dependency, tracer in this case). Then bundle add datadog-ci command is executed to add the latest version of test optimization library. The configurator returns RUBYOPT environment variable with -rbundler/setup -rdatadog/ci/auto_instrument - this will tell Ruby VM to load Datadog's code before running tests.
  • Adds RUBY to TracerLanguage enum
  • Adds Ruby to README and to help-languages.html page

Alternate Designs

N/A

Possible Drawbacks

N/A

Verification Process

Verified using docker compose setup for manual testing

Step 1: start jenkins on docker compose
Step 2: run test-pipeline-ruby without test optimization

image image

Step 3: configure Test Optimization for test-pipeline-ruby

image

Step 4: run test-pipeline-ruby with Datadog plugin and auto innjection

image

Step 5: validate that tests are present in Datadog

image

Additional Notes

N/A

Release Notes

N/A

Review checklist (to be filled by reviewers)

  • Feature or bug fix MUST have appropriate tests (unit, integration, etc...)
  • PR title must be written as a CHANGELOG entry (see why)
  • Files changes must correspond to the primary purpose of the PR as described in the title (small unrelated changes should have their own PR)
  • PR must have one changelog/ label attached. If applicable it should have the backward-incompatible label attached.
  • PR should not have do-not-merge/ label attached.
  • If Applicable, issue must have kind/ and severity/ labels attached at least.

@anmarchenko anmarchenko changed the title [SDTEST-171] Implement automatic Test Optimization instrumentation for Ruby projects Implement automatic Test Optimization instrumentation for Ruby projects Dec 6, 2024
@nikita-tkachenko-datadog nikita-tkachenko-datadog added the changelog/Added Added features results into a minor version bump label Dec 9, 2024
@nikita-tkachenko-datadog

Copy link
Copy Markdown
Collaborator

Could you please also update the list of languages at https://docs.datadoghq.com/continuous_integration/pipelines/jenkins/?tab=agentlessusinganapikey#enable-test-optimization (In the section where datadog(testVisibility: command is described)? And the screenshot, if possible (I missed it last time, when I added .NET)

listener.getLogger().println("[datadog] Configuring DD Ruby tracer: got bundler version " + bundlerVersion + " from " + workspacePath + " on " + node);

String rubygemsVersion = workspacePath.act(new ShellCommandCallable(Collections.emptyMap(), GET_VERSION_TIMEOUT_MILLIS, "gem", "-v"));
listener.getLogger().println("[datadog] Configuring DD Ruby tracer: got rubygems version " + rubygemsVersion + " from " + workspacePath + " on " + node);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why are we not checking the versions that we get? Is the idea that as long as the command doesn't fail it should be enough?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

good point, in the script I check versions, here I forgot to do that because other Jenkins configurations don't check versions

@nikita-tkachenko-datadog

nikita-tkachenko-datadog commented Dec 9, 2024

Copy link
Copy Markdown
Collaborator

There are some sample pipelines for different languages at docker/controller-node/jobs. It'd be great if you could add one for Ruby too (you can use Java, JS, Python or .NET as examples).

That'd require adding a Ruby agent in docker/docker-compose.yaml (you can check jenkins-agent-dotnet, jenkins-agent-python, and jenkins-agent-js as examples).

Comment thread docker/docker-compose.yaml
Comment thread docker/controller-node/jobs/test-pipeline-ruby.cps Outdated
@nikita-tkachenko-datadog
nikita-tkachenko-datadog merged commit c40eec7 into jenkinsci:master Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/Added Added features results into a minor version bump

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants