Skip to content

[feat] Add synthetics plugin #153

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

Draft
wants to merge 19 commits into
base: master
Choose a base branch
from
Draft

Conversation

yoannmoinet
Copy link
Member

@yoannmoinet yoannmoinet commented Mar 26, 2025

Stacked on

Related to

What and why?

Add a Synthetics plugin.

It will be used in collaboration with datadog-ci for a new "Build and test" workflow:

  1. Run datadog-ci synthetics build-and-test (name TBD).
  2. datadog-ci will run the build command of the project passing BUILD_PLUGINS_S8S_PORT.
  3. build-plugins will recognise BUILD_PLUGINS_S8S_PORT and will run a local dev server over the outDir of the build, with a small api /_datadog-ci_/build-status for datadog-ci to follow the build progression.
  4. build's complete.
  5. datadog-ci opens a tunnel.
  6. datadog-ci trigger a test batch using the local assets from the build through the resourceUrlSubstitutionRegexes configuration.

More details

The local server offers two routes (in addition to the file server over the out directory):

  1. /_datadog-ci_/build-status responding with:
{
    "status": "running" | "success" | "fail",
    "outDir": "/..." // Absolute path of the build's outDir.
    "publicPath": "/" // Assets' public path if available.
}
  1. /_datadog-ci_/kill kills the server.

TODO

  • Add documentation for s8s.

@yoannmoinet yoannmoinet changed the base branch from master to yoann/move-dev-server March 26, 2025 15:58
@yoannmoinet yoannmoinet force-pushed the yoann/s8s-dev-server branch from 98f973d to d0b4490 Compare March 26, 2025 17:02
@yoannmoinet yoannmoinet force-pushed the yoann/s8s-dev-server branch from f66613e to 7914418 Compare March 27, 2025 09:35
@yoannmoinet yoannmoinet requested review from elbywan and etnbrd March 27, 2025 10:18
@yoannmoinet yoannmoinet marked this pull request as ready for review March 27, 2025 10:18
@yoannmoinet yoannmoinet requested a review from Copilot March 27, 2025 10:20
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a new Synthetics plugin that enables the local development server for build-time testing and integrates with datadog-ci for build status reporting.

  • Added Synthetics plugin implementation across various bundler plugins.
  • Updated exports and factory configuration to include SyntheticsTypes.
  • Introduced plugin validation, routes for build status and server shutdown, and comprehensive test coverage.

Reviewed Changes

Copilot reviewed 16 out of 20 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/published/webpack-plugin/src/index.ts Added SyntheticsTypes export in the plugin.
packages/published/vite-plugin/src/index.ts Added SyntheticsTypes export in the plugin.
packages/published/rspack-plugin/src/index.ts Added SyntheticsTypes export in the plugin.
packages/published/rollup-plugin/src/index.ts Added SyntheticsTypes export in the plugin.
packages/published/esbuild-plugin/src/index.ts Added SyntheticsTypes export in the plugin.
packages/plugins/synthetics/src/{validate,types,index,constants}.ts Introduced core implementation for the new Synthetics plugin.
packages/plugins/synthetics/src/index.test.ts Added tests validating server behavior and plugin initialization.
packages/plugins/synthetics/README.md Provided documentation for the new Synthetics plugin.
packages/factory/src/index.ts Updated factory exports and configuration to include the Synthetics plugin.
packages/core/src/types.ts Extended core types to support configuration for the Synthetics plugin.
README.md Updated root documentation to include Synthetics plugin guidelines.
Files not reviewed (4)
  • .github/CODEOWNERS: Language not supported
  • packages/factory/package.json: Language not supported
  • packages/plugins/synthetics/package.json: Language not supported
  • packages/plugins/synthetics/tsconfig.json: Language not supported
Comments suppressed due to low confidence (1)

packages/plugins/synthetics/src/index.ts:66

  • [nitpick] Multiple server shutdown calls (server.close, server.closeAllConnections, server.closeIdleConnections) occur in immediate succession, which may lead to unexpected behavior. Consider consolidating these calls or adding checks to ensure that the server shutdown process is idempotent.
server.close();

@@ -29,3 +29,6 @@ packages/plugins/analytics @yoannmoin

# Custom Hooks
packages/plugins/custom-hooks @yoannmoinet

# Synthetics
packages/plugins/synthetics @yoannmoinet @etnbrd
Copy link
Collaborator

Choose a reason for hiding this comment

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

You need to invite etienne I think:

image

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch.
I'll wait for his review, see if I should instead maybe use a team (cc @etnbrd)

Copy link

Choose a reason for hiding this comment

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

You should definitely use the @DataDog/synthetics-ct team, indeed.

Copy link
Collaborator

@Ayc0 Ayc0 left a comment

Choose a reason for hiding this comment

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

LGTM but i'm not versed in s8s

Copy link

@etnbrd etnbrd left a comment

Choose a reason for hiding this comment

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

LGTM, left a few questions, but nothing blocking.

Base automatically changed from yoann/move-dev-server to master March 28, 2025 16:59
@yoannmoinet
Copy link
Member Author

Putting this on hold for now.

We'll redesign a bit the feature to have the server part running on datadog-ci's side instead of build-plugins's.

While testing with web-ui we noticed that handling sequential builds (or parallel ones even) would be very difficult to do from the build-plugins's PoV.

Instead, we'll have datadog-ci run a server and build-plugins register its builds and reporting its status to it by calling the server's API.

@yoannmoinet yoannmoinet marked this pull request as draft April 8, 2025 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants