-
-
Notifications
You must be signed in to change notification settings - Fork 0
Add Datadog test optimization action and update pre-commit hook revisions #94
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
base: main
Are you sure you want to change the base?
Conversation
WalkthroughAdds 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
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests
Comment |
There was a problem hiding this 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
⛔ 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.
- name: Configure Datadog Test Optimization | ||
uses: datadog/[email protected] | ||
with: | ||
api_key: ${{ secrets.DATADOG_API_KEY }} | ||
languages: go | ||
service: istio-test | ||
|
There was a problem hiding this comment.
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) underwith
. - 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.
- 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.
Summary by CodeRabbit