Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/sandbox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ jobs:
with:
go-version: '^1.25'

- name: Configure Datadog Test Optimization
uses: datadog/[email protected]
with:
api_key: ${{ secrets.DATADOG_API_KEY }}
languages: go
service: istio-test

Comment on lines +27 to +33
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.

- name: Run tests
run: go test ./...

Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
rev: 3e8a8703264a2f4a69428a0aa4dcb512790b2c8c # frozen: v6.0.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-symlinks

- repo: https://github.com/osinfra-io/pre-commit-hooks
rev: v0.1.1
rev: 55243c9fc3556620122b1ffaef067bb7c7c4ae9d # frozen: v0.1.1
hooks:
- id: tofu-fmt
verbose: true
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module istio-test

go 1.24.2
go 1.25.1

require (
github.com/sirupsen/logrus v1.9.3
Expand Down
Loading