Skip to content

feat(ci): add days-since-last-pin daily workflow#22951

Open
dkirov-dd wants to merge 4 commits intomasterfrom
dk/AI-6462/days-since-last-pin
Open

feat(ci): add days-since-last-pin daily workflow#22951
dkirov-dd wants to merge 4 commits intomasterfrom
dk/AI-6462/days-since-last-pin

Conversation

@dkirov-dd
Copy link
Contributor

@dkirov-dd dkirov-dd commented Mar 18, 2026

Summary

  • Adds .github/workflows/days-since-last-pin.yml that runs daily at 9:42 UTC (+ workflow_dispatch for manual triggering)
  • Fetches release.json from DataDog/datadog-agent and walks recent commits to determine when INTEGRATIONS_CORE_VERSION last changed
  • Posts a gauge metric integrations_core.days_since_last_pin{team:agent-integrations} to Datadog API v2
  • Uses only run: steps (no uses: actions), so pinact validation is unaffected

Related to DataDog/datadog-agent#48035

Motivation

Jira: AI-6462

The agent repo (DataDog/datadog-agent) is pinned to integrations-core bi-weekly via an auto-created PR that must be manually merged. This metric enables a CI dashboard widget (on the Agent Integrations Overview dashboard) that turns red when the pin is stale (> 4 days).

Post-merge steps (manual)

Add a Query Value widget to the CI dashboard:

  • Query: max:integrations_core.days_since_last_pin{team:agent-integrations}
  • Conditional formatting: red when value > 4

Test plan

  • Trigger workflow_dispatch from GitHub Actions UI after merge
  • Confirm workflow run succeeds and logs show the computed days value
  • Check Datadog Metrics Explorer for integrations_core.days_since_last_pin
  • Add dashboard widget and confirm it renders correctly

🤖 Generated with Claude Code

- Add .github/workflows/days-since-last-pin.yml that runs daily at 9:42 UTC
- Computes days since INTEGRATIONS_CORE_VERSION was last updated in datadog-agent/release.json
- Posts gauge metric integrations_core.days_since_last_pin{team:agent-integrations} to Datadog API v2

Rationale: AI-6462 — need a CI dashboard counter that turns red when the agent repo hasn't been pinned in >4 days
@dkirov-dd dkirov-dd requested a review from a team as a code owner March 18, 2026 14:18
@github-actions
Copy link
Contributor

⚠️ Recommendation: Add qa/skip-qa label

This PR does not modify any files shipped with the agent.

To help streamline the release process, please consider adding the qa/skip-qa label if these changes do not require QA testing.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 09fde01b31

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

print(f"Current pin: {current_pin}")

# Step 2: fetch recent commits to release.json
commits_url = f"{COMMITS_API_URL}?path=release.json&per_page=30"

Choose a reason for hiding this comment

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

P2 Badge Paginate past the first 30 release.json commits

per_page=30 means this job only inspects the newest 30 commits that touched release.json. If INTEGRATIONS_CORE_VERSION stays unchanged across more than 30 such commits, the loop never reaches the commit where the pin last changed, so last_pin_commit becomes the oldest item in that first page and the reported age is too small. Because this metric is supposed to drive a stale-pin alert, the dashboard can stay green even when the pin is older than the threshold.

Useful? React with 👍 / 👎.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will check all commits in the last 30 days instead.

Comment on lines +69 to +72
pin_at_sha = get_integrations_core_version(sha)
except Exception as e:
print(f"Warning: could not fetch release.json at {sha}: {e}")
break

Choose a reason for hiding this comment

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

P2 Badge Fail instead of submitting a partial metric on fetch errors

If any historical release.json fetch fails here (for example due to a transient GitHub API/raw-content error), the code logs a warning, breaks the scan, and still posts a metric based on the newest successfully read commit. In that case the workflow silently undercounts days_since_last_pin, which is worse than failing because it can suppress the very alert this workflow is meant to power.

Useful? React with 👍 / 👎.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will raise an error if the fetch fails

@dkirov-dd dkirov-dd added the qa/skip-qa Automatically skip this PR for the next QA label Mar 18, 2026
…nce-last-pin

- Extract 90-line embedded Python heredoc to .github/workflows/scripts/days_since_last_pin.py
- Add actions/checkout step so the workflow can access the script file
- Replace silent break-on-error with raise to fail the job on fetch errors
- Split single step into compute + submit for step-level failure attribution
- Add comment explaining the per_page=30 assumption

Rationale: PR review found inline heredoc diverged from repo convention, and a mid-walk fetch failure would silently submit a falsely-healthy metric

This commit made by [/dd:git:commit:quick](https://github.com/DataDog/claude-marketplace/tree/main/dd/commands/git/commit/quick.md)
- Replace per_page=30 with a since=30-days-ago query parameter and full pagination
- release.json is updated for many dep changes (JMXFETCH, OMNIBUS_RUBY, etc.),
  so a fixed page count could exhaust without finding the pin-change commit
- When no commits found in the window, report days=30 (pin is at least that old)

Rationale: the sparse-commit assumption was wrong; time-bounded window is the correct approach

This commit made by [/dd:git:commit:quick](https://github.com/DataDog/claude-marketplace/tree/main/dd/commands/git/commit/quick.md)
…cess

- Add dd-octo-sts-action step to exchange OIDC token for a scoped token on
  DataDog/datadog-agent (contents:read only)
- Pass dd-octo-sts token as GITHUB_TOKEN to the compute step instead of the
  built-in secrets.GITHUB_TOKEN
- Add id-token:write permission to the job for OIDC federation

Trust policy PR: DataDog/datadog-agent#48035

Rationale: scoped short-lived token is more secure than using the default
GITHUB_TOKEN for cross-repo access

This commit made by [/dd:git:commit:quick](https://github.com/DataDog/claude-marketplace/tree/main/dd/commands/git/commit/quick.md)
gh-worker-dd-mergequeue-cf854d bot pushed a commit to DataDog/datadog-agent that referenced this pull request Mar 19, 2026
…t-pin (#48035)

## Summary

Adds a dd-octo-sts trust policy authorizing `DataDog/integrations-core`'s daily `days-since-last-pin` workflow to read `release.json` from this repo.

Needed for DataDog/integrations-core#22951

## Context

The `days-since-last-pin.yml` workflow in `integrations-core` (Jira: AI-6462) computes how many days it has been since `INTEGRATIONS_CORE_VERSION` was last updated in this repo's `release.json`, and posts a gauge metric to Datadog for CI dashboard alerting (turns red when > 4 days).

## Policy

**File:** `.github/chainguard/integrations-core.github.read-release-json.schedule.sts.yaml`

- **Source:** `DataDog/integrations-core` (scheduled + workflow_dispatch, runs on `master`)
- **Permission:** `contents: read` on this repo (to read `release.json` at historical SHAs and query the commits API)
- Restricted to the exact workflow file and default branch via `claim_pattern`

## Related PR

DataDog/integrations-core#22951

Co-authored-by: david.kirov <david.kirov@datadoghq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant