Skip to content

Model GitHub API enum fields as StrEnum in the async client#24316

Draft
HadhemiDD wants to merge 7 commits into
masterfrom
hs/github-async-strenum-models
Draft

Model GitHub API enum fields as StrEnum in the async client#24316
HadhemiDD wants to merge 7 commits into
masterfrom
hs/github-async-strenum-models

Conversation

@HadhemiDD

Copy link
Copy Markdown
Contributor

What does this PR do?

Models the GitHub REST API's declared-enum response fields as StrEnums in the async client (ddev/src/ddev/utils/github_async/), following the folder's guidelines. Every decision is validated against GitHub's official OpenAPI description pinned to GITHUB_API_VERSION (2022-11-28).

  • Adds PullRequestState (open, closed) and retypes PullRequest.state.
  • Adds WorkflowJobStatus (6 values) and WorkflowJobConclusion (7 values, nullable) for WorkflowJob.
  • Adds JobStepStatus (3 values) for JobStep.status; JobStep.conclusion has no declared enum, so it stays str | None.
  • Adds CheckRunStatus (6 values) and CheckRunConclusion (7 values, nullable) for CheckRun.
  • Keeps WorkflowRun.status/conclusion and GitHubUser.type as free-form strings (the OpenAPI schema declares no enum for them).
  • Adds a WorkflowRun.is_completed helper and retypes update_check_run's conclusion parameter to CheckRunConclusion | None.
  • Cites the docs.github.com reference backing each enum decision in the model docstrings and updates the async client unit tests.

Motivation

Keeping workflow/job status/conclusion and PR state as bare strings does not scale: call sites compare against scattered string literals with no validation and no single source of truth. Modeling the declared-enum fields as StrEnums makes the allowed values explicit, validated, and self-documenting before the gatherer work that depends on these types lands. See AI-6959.

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Add qa/required if this PR needs QA validation, or qa/skip-qa if it does not. Exactly one of the two is required.
  • If you need to backport this PR to another branch, you can add the backport/<branch-name> label to the PR and it will automatically open a backport PR once this one is merged

Convert response-model fields the GitHub OpenAPI description (pinned to
GITHUB_API_VERSION 2022-11-28) declares as an enum into StrEnums, per the
github_async guidelines:

- PullRequestState (open, closed) for PullRequest.state
- WorkflowJobStatus / WorkflowJobConclusion for WorkflowJob
- JobStepStatus (3-value) for JobStep.status (JobStep.conclusion has no
  declared enum, kept str | None)
- CheckRunStatus / CheckRunConclusion for CheckRun

WorkflowRun.status/conclusion and GitHubUser.type declare no enum in the
description, so they stay free-form strings. Add WorkflowRun.is_completed
helper, retype update_check_run's conclusion param, and cover the new field
types in the async client unit tests.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@HadhemiDD HadhemiDD added the qa/skip-qa Automatically skip this PR for the next QA label Jul 3, 2026
@dd-octo-sts dd-octo-sts Bot added the ddev label Jul 3, 2026
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

⚠️ Major version bump
The changelog type changed or removed was used in this Pull Request, so the next release will bump major version. Please make sure this is a breaking change, or use the fixed or added type instead.

@datadog-prod-us1-6

datadog-prod-us1-6 Bot commented Jul 3, 2026

Copy link
Copy Markdown

Tests  Code Coverage

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 88.30% (+0.10%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: b5088da | Docs | Datadog PR Page | Give us feedback!

HadhemiDD and others added 5 commits July 6, 2026 11:41
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…enum-models

# Conflicts:
#	ddev/tests/utils/test_github_async.py
@dd-octo-sts

dd-octo-sts Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Validation Report

All 21 validations passed.

Show details
Validation Description Status
agent-reqs Verify check versions match the Agent requirements file
ci Validate CI configuration and code coverage settings
codeowners Validate every integration has a CODEOWNERS entry
config Validate default configuration files against spec.yaml
dep Verify dependency pins are consistent and Agent-compatible
http Validate integrations use the HTTP wrapper correctly
imports Validate check imports do not use deprecated modules
integration-style Validate check code style conventions
jmx-metrics Validate JMX metrics definition files and config
labeler Validate PR labeler config matches integration directories
legacy-signature Validate no integration uses the legacy Agent check signature
license-headers Validate Python files have proper license headers
licenses Validate third-party license attribution list
metadata Validate metadata.csv metric definitions
models Validate configuration data models match spec.yaml
openmetrics Validate OpenMetrics integrations disable the metric limit
package Validate Python package metadata and naming
qa-label Validate the pull request declares whether it needs QA for the next Agent release
readmes Validate README files have required sections
saved-views Validate saved view JSON file structure and fields
version Validate version consistency between package and changelog

View full run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ddev qa/skip-qa Automatically skip this PR for the next QA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant