Skip to content

Conversation

brettcurtis
Copy link
Member

@brettcurtis brettcurtis commented Sep 24, 2025

Summary by CodeRabbit

  • Chores
    • CI: Added Datadog Test Optimization to the Sandbox workflow to enhance visibility and performance of Go test runs, enabling smarter test selection and faster feedback.
    • Tooling: Pinned pre-commit hooks to immutable revisions for reproducible, stable linting and formatting across environments, reducing variability and improving reliability of local and CI checks.

@brettcurtis brettcurtis self-assigned this Sep 24, 2025
Copy link
Contributor

coderabbitai bot commented Sep 24, 2025

Walkthrough

Adds a Datadog Test Optimization step to the Sandbox GitHub Actions workflow for Go tests, placed before the test run. Pins two pre-commit repositories to specific commit hashes with frozen version annotations. No changes to exported/public entities.

Changes

Cohort / File(s) Summary
CI workflow
.github/workflows/sandbox.yml
Inserts "Configure Datadog Test Optimization" step using datadog/[email protected], configuring api_key (from secrets), languages: go, and service: istio-test, before the test step.
Pre-commit configuration
.pre-commit-config.yaml
Pins pre-commit-hooks and osinfra-io/pre-commit-hooks to specific commit SHAs with comments noting the corresponding frozen versions (v6.0.0, v0.1.1).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title accurately and concisely describes the two primary changes in the pull request by stating the addition of the Datadog test optimization action and the update to pre-commit hook revisions, making it clear to reviewers what the main updates are.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@brettcurtis brettcurtis marked this pull request as ready for review September 24, 2025 19:46
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 605fe03 and 8f04233.

⛔ Files ignored due to path filters (1)
  • go.mod is excluded by !**/*.mod
📒 Files selected for processing (2)
  • .github/workflows/sandbox.yml (1 hunks)
  • .pre-commit-config.yaml (1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: brettcurtis
PR: osinfra-io/google-cloud-kubernetes#55
File: regional/main.tf:0-0
Timestamp: 2024-07-14T11:40:35.132Z
Learning: When suggesting changes to Terraform module references, ensure to use specific version tags for stability and reproducibility. The user, brettcurtis, prefers using specific version tags for Terraform module references.
Learnt from: brettcurtis
PR: osinfra-io/google-cloud-kubernetes#55
File: regional/main.tf:0-0
Timestamp: 2024-10-08T15:39:14.063Z
Learning: When suggesting changes to Terraform module references, ensure to use specific version tags for stability and reproducibility. The user, brettcurtis, prefers using specific version tags for Terraform module references.
📚 Learning: 2025-08-02T21:40:04.571Z
Learnt from: brettcurtis
PR: osinfra-io/terraform-core-helpers#14
File: .pre-commit-config.yaml:13-18
Timestamp: 2025-08-02T21:40:04.571Z
Learning: When using pre-commit's autoupdate feature, hooks must be pinned to tags or branches rather than commit SHAs, as autoupdate cannot update commit SHA references.

Applied to files:

  • .pre-commit-config.yaml
📚 Learning: 2024-10-19T13:56:36.246Z
Learnt from: brettcurtis
PR: osinfra-io/github-organization-management#169
File: .pre-commit-config.yaml:6-6
Timestamp: 2024-10-19T13:56:36.246Z
Learning: When pre-commit hooks are updated in `.pre-commit-config.yaml`, it's not necessary to suggest running them manually on the entire codebase because they will automatically run before each commit.

Applied to files:

  • .pre-commit-config.yaml
🔇 Additional comments (1)
.pre-commit-config.yaml (1)

6-6: Pinned SHAs match v6.0.0 and v0.1.1 tags; freezing confirmed — autoupdate disabled as intended.

Comment on lines +27 to +33
- name: Configure Datadog Test Optimization
uses: datadog/[email protected]
with:
api_key: ${{ secrets.DATADOG_API_KEY }}
languages: go
service: istio-test

Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

🧩 Analysis chain

Guard Datadog step for forked PRs; ensure git history for optimization.

  • Secrets are not exposed to forked pull_request runs; this step will fail on external PRs. Add an if guard.
  • Intelligent test optimization often needs more than a shallow clone. Recommend fetch-depth: 0 on checkout.

Apply this diff to conditionally run the step when secrets are available and PR is not from a fork:

       - name: Configure Datadog Test Optimization
+        if: ${{ github.event_name != 'pull_request' || (github.event.pull_request.head.repo.full_name == github.repository && secrets.DATADOG_API_KEY != '') }}
         uses: datadog/[email protected]
         with:
           api_key: ${{ secrets.DATADOG_API_KEY }}
           languages: go
           service: istio-test

Additionally, set full history for better change detection (outside the selected lines):

- name: Checkout
  uses: actions/checkout@v5
  with:
    fetch-depth: 0

Verification:

  • Confirm your Datadog site (defaults to datadoghq.com). If using EU/other, add site: datadoghq.eu to the action inputs.
  • Confirm Go test visibility/optimization requirements are met in the repo (e.g., dd-trace-go or the action’s Go support is sufficient). Run:

🏁 Script executed:

#!/bin/bash
# Check for dd-trace-go usage to confirm instrumentation presence (optional for optimization, useful for visibility)
rg -n --type=go -C2 'github\.com/(DataDog|datadog)/dd-trace-go|datadog' || true

# List workflow steps to ensure the Datadog step is before tests (sanity check)
rg -n -C2 'Configure Datadog Test Optimization|Run tests' .github/workflows/sandbox.yml

Length of output: 269


Guard Datadog step on forked PRs and enable full Git history

  • Add an if condition so the action only runs when secrets are available and it’s not an external PR.
  • In your checkout step, set fetch-depth: 0 to fetch full history for test optimization.
  • If you use a non-default Datadog site, add site: datadoghq.eu (or appropriate) under with.
  • No dd-trace-go imports detected; include Go instrumentation to unlock full test-visibility support.
       - name: Configure Datadog Test Optimization
+        if: ${{ github.event_name != 'pull_request' || (github.event.pull_request.head.repo.full_name == github.repository && secrets.DATADOG_API_KEY != '') }}
         uses: datadog/[email protected]
         with:
           api_key: ${{ secrets.DATADOG_API_KEY }}
           languages: go
           service: istio-test
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Configure Datadog Test Optimization
uses: datadog/[email protected]
with:
api_key: ${{ secrets.DATADOG_API_KEY }}
languages: go
service: istio-test
- name: Configure Datadog Test Optimization
if: ${{ github.event_name != 'pull_request' || (github.event.pull_request.head.repo.full_name == github.repository && secrets.DATADOG_API_KEY != '') }}
uses: datadog/[email protected]
with:
api_key: ${{ secrets.DATADOG_API_KEY }}
languages: go
service: istio-test
🤖 Prompt for AI Agents
.github/workflows/sandbox.yml lines 27-33: The Datadog Test Optimization step
must be guarded and checkout must fetch full history; add an if condition so the
action only runs when the DATADOG_API_KEY secret exists and the PR is not from a
fork/external repository, update the checkout step to use fetch-depth: 0 to
fetch full git history, add a site: <appropriate datadog site> under with if you
use a non-default Datadog site (e.g., datadoghq.eu), and ensure your Go tests
include dd-trace-go instrumentation (import and initialize dd-trace-go in your
test or application setup) so full test-visibility features are enabled.

@github-project-automation github-project-automation bot moved this from Todo ✏ to In Progress 🔨 in 🔨Open Source Infrastructure (as Code) Sep 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress 🔨
Development

Successfully merging this pull request may close these issues.

1 participant