Skip to content

refactor(providers): constantize provider StatusOpt conclusion options#2384

Merged
chmouel merged 1 commit intotektoncd:mainfrom
aThorp96:no-start-status-description
Feb 23, 2026
Merged

refactor(providers): constantize provider StatusOpt conclusion options#2384
chmouel merged 1 commit intotektoncd:mainfrom
aThorp96:no-start-status-description

Conversation

@aThorp96
Copy link
Copy Markdown
Member

@aThorp96 aThorp96 commented Jan 9, 2026

📝 Description of the Change

The Conclusion field of StatusOpts has a discrete number of supported values. These being typed as strings has introduced bugs in the past and makes adding new values difficult. Defining the supported values as constant enums improves both the safety of the values and the ease of working with them.

👨🏻‍ Linked Jira

None

🔗 Linked GitHub Issue

Fixes #

🚀 Type of Change

  • 🐛 Bug fix (fix:)
  • ✨ New feature (feat:)
  • 💥 Breaking change (feat!:, fix!:)
  • 📚 Documentation update (docs:)
  • ⚙️ Chore (chore:)
  • 💅 Refactor (refactor:)
  • 🔧 Enhancement (enhance:)
  • 📦 Dependency update (deps:)

🧪 Testing Strategy

  • Unit tests
  • Integration tests
  • End-to-end tests
  • Manual testing
  • Not Applicable

🤖 AI Assistance

  • I have not used any AI assistance for this PR.
  • I have used AI assistance for this PR.

If you have used AI assistance, please provide the following details:

Which LLM was used?

  • GitHub Copilot
  • ChatGPT (OpenAI)
  • Claude (Anthropic)
  • Cursor
  • Gemini (Google)
  • Other: ____________

Extent of AI Assistance:

  • Documentation and research only
  • Unit tests or E2E tests only
  • Code generation (parts of the code)
  • Full code generation (most of the PR)
  • PR description and comments
  • Commit message(s)

Important

If the majority of the code in this PR was generated by an AI, please add a Co-authored-by trailer to your commit message.
For example:

Co-authored-by: Gemini gemini@google.com
Co-authored-by: ChatGPT noreply@chatgpt.com
Co-authored-by: Claude noreply@anthropic.com
Co-authored-by: Cursor noreply@cursor.com
Co-authored-by: Copilot Copilot@users.noreply.github.com

**💡You can use the script ./hack/add-llm-coauthor.sh to automatically add
these co-author trailers to your commits.

✅ Submitter Checklist

  • 📝 My commit messages are clear, informative, and follow the project's How to write a git commit message guide. The Gitlint linter ensures in CI it's properly validated
  • ✨ I have ensured my commit message prefix (e.g., fix:, feat:) matches the "Type of Change" I selected above.
  • ♽ I have run make test and make lint locally to check for and fix any
    issues. For an efficient workflow, I have considered installing
    pre-commit and running pre-commit install to
    automate these checks.
  • 📖 I have added or updated documentation for any user-facing changes.
  • 🧪 I have added sufficient unit tests for my code changes.
  • 🎁 I have added end-to-end tests where feasible. See README for more details.
  • 🔎 I have addressed any CI test flakiness or provided a clear reason to bypass it.
  • If adding a provider feature, I have filled in the following and updated the provider documentation:
    • GitHub App
    • GitHub Webhook
    • Gitea/Forgejo
    • GitLab
    • Bitbucket Cloud
    • Bitbucket Data Center

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @aThorp96, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly refactors the handling of status conclusions across the application's provider integrations. By introducing a dedicated status package and migrating from string literals to constant enums for StatusOpts conclusions, the change aims to improve the robustness and clarity of status reporting. This standardization will prevent common errors associated with string-based comparisons and make the system more adaptable to new status types.

Highlights

  • Introduction of status package: A new package pkg/provider/status has been created to centralize the definition of StatusOpts and Conclusion types, along with a set of constant Conclusion values.
  • Constantization of Status Conclusions: Hardcoded string literals for status conclusions (e.g., "success", "failure", "pending") have been replaced with strongly typed constants (e.g., status.ConclusionSuccess, status.ConclusionFailure) across the codebase.
  • Improved Type Safety and Maintainability: This refactoring enhances type safety by preventing errors from incorrect string inputs for status conclusions and simplifies future maintenance and extension of status types.
  • Removal of Redundant Constants: Old string constants for status conclusions within pkg/pipelineascode/pipelineascode.go have been removed, as they are now superseded by the new centralized constants.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

ConclusionSuccess Conclusion = "success"
)

//nolint:revive
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I opted (no pun intended) to keep the existing struct's name StatusOpts even though the linter warned about the name being status.StatusOpts but I have no qualms with renaming to status.Opts, status.UpdateOpts, or something.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This is a great refactoring that introduces constants for StatusOpts.Conclusion values, improving type safety and maintainability across the providers. The changes are well-applied throughout the codebase. I've found a few places where new conclusion constants are not fully handled in provider-specific implementations, leading to // TODO comments or empty switch cases. I've provided suggestions to complete the implementation for these cases. I also have a minor suggestion to improve code readability in one of the pointer conversions.

Comment on lines +224 to 225
default:
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The default case in this switch is empty. This means that several conclusion types (completed, skipped, cancelled) will be passed directly to gitea.StatusState, which may not be valid Gitea statuses. These should be explicitly mapped to valid Gitea statuses (e.g., pending, success, error, failure, warning).

For example:

  • ConclusionCompleted should probably map to gitea.StatusSuccess.
  • ConclusionSkipped could map to gitea.StatusWarning.
  • ConclusionCancelled could map to gitea.StatusFailure.
case providerstatus.ConclusionCompleted:
		state = gitea.StatusSuccess
	case providerstatus.ConclusionSkipped:
		state = gitea.StatusWarning
	case providerstatus.ConclusionCancelled:
		state = gitea.StatusFailure
	default:
		// This will handle success, failure, pending which are already valid gitea.StatusState
	}

Comment on lines +333 to 334
default:
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The default case in this switch is empty. This means that several conclusion types (completed, skipped, cancelled) will be passed directly to the GitHub API, which are not valid statuses. These should be explicitly mapped to valid GitHub statuses (error, failure, pending, success).

For example:

  • ConclusionCompleted and ConclusionSkipped could be mapped to ConclusionSuccess.
  • ConclusionCancelled could be mapped to ConclusionFailure.
Suggested change
default:
}
case providerstatus.ConclusionCompleted, providerstatus.ConclusionSkipped:
status.Conclusion = providerstatus.ConclusionSuccess
case providerstatus.ConclusionCancelled:
status.Conclusion = providerstatus.ConclusionFailure
default:
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can you double check @aThorp96 this is the case? this seems relevant...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think this comment may be correct, but there is no change in behavior in this PR. Can these be fixed in a followup PR?

Comment on lines +109 to 111
case status.ConclusionCancelled:
// TODO
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The cancelled conclusion is not handled here. It should probably be mapped to the STOPPED state, similar to skipped and neutral.

Suggested change
case status.ConclusionCancelled:
// TODO
}
case status.ConclusionCancelled:
state = stateStopped
statusopts.Title = "🚫 Cancelled"
}

Comment on lines +111 to +112
// TODO: Should this be scm.StateRunning?
state = scm.StatePending
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The TODO comment questions whether scm.StateRunning should be used. Since the status title is "CI has started", scm.StateRunning seems more appropriate than scm.StatePending. go-scm defines StateRunning as "The build is running.".

Suggested change
// TODO: Should this be scm.StateRunning?
state = scm.StatePending
state = scm.StateRunning

Comment on lines +121 to 123
case status.ConclusionCancelled:
// TODO
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The cancelled conclusion is not handled. It should be mapped to scm.StateCanceled.

case status.ConclusionCancelled:
		state = scm.StateCanceled
		statusOpts.Title = "🚫 Cancelled"
	}

Comment on lines +197 to 198
case providerstatus.ConclusionCancelled, providerstatus.ConclusionCompleted, providerstatus.ConclusionSkipped:
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

This new case for cancelled, completed, and skipped conclusions is empty. This means statusOpts.Title and statusOpts.Summary won't be set for these cases, which could lead to confusing or missing information in the status updates. These cases should be handled explicitly.

For example:

  • ConclusionCompleted could be treated like ConclusionSuccess.
  • ConclusionCancelled could be a Failure or Warning.
  • ConclusionSkipped could be a Warning.
case providerstatus.ConclusionCompleted:
		statusOpts.Title = "Completed"
		statusOpts.Summary = "has <b>completed</b>."
	case providerstatus.ConclusionCancelled:
		statusOpts.Title = "Cancelled"
		statusOpts.Summary = "has been <b>cancelled</b>."
	case providerstatus.ConclusionSkipped:
		statusOpts.Title = "Skipped"
		statusOpts.Summary = "has been <b>skipped</b>."
	}

Comment on lines +421 to 422
case providerstatus.ConclusionCompleted, providerstatus.ConclusionSkipped:
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

This new case for completed and skipped conclusions is empty. This means statusOpts.Title and statusOpts.Summary won't be set for these cases, which could lead to confusing or missing information in the status updates. These cases should be handled explicitly.

For example:

  • ConclusionCompleted could have a title "Completed".
  • ConclusionSkipped could have a title "Skipped".
Suggested change
case providerstatus.ConclusionCompleted, providerstatus.ConclusionSkipped:
}
case providerstatus.ConclusionCompleted:
statusOpts.Title = "Completed"
statusOpts.Summary = "has <b>completed</b>."
case providerstatus.ConclusionSkipped:
statusOpts.Title = "Skipped"
statusOpts.Summary = "has been <b>skipped</b>."
}

@aThorp96 aThorp96 requested review from chmouel and zakisk January 9, 2026 21:28
@zakisk zakisk force-pushed the no-start-status-description branch from ce689be to d2ef3de Compare January 12, 2026 11:17
@pipelines-as-code
Copy link
Copy Markdown

pipelines-as-code bot commented Jan 12, 2026

🔍 PR Lint Feedback

Note: This automated check helps ensure your PR follows our contribution guidelines.

⚠️ Items that need attention:

🎫 Jira reference

Add a Jira reference in the description using one of the following formats:

  • https://issues.redhat.com/browse/SRVKP-<number>

If no SRVKP ticket exists yet, link a GitHub issue instead (e.g., Fixes #123).
Minor housekeeping PRs without Jira coverage can skip this after confirming with reviewers.


🤖 AI attribution

The following commits lack an explicit AI attribution footer:

  • dd7cfa8 refactor(providers): constantize provider StatusOpt conclusion options

If no AI assistance was used for a commit, you can ignore this warning.
Otherwise add an Assisted-by: or Co-authored-by: footer referencing the AI used.


ℹ️ Next Steps

  • Review and address the items above
  • Push new commits to update this PR
  • This comment will be automatically updated when issues are resolved
🔧 Admin Tools (click to expand)

Automated Issue/Ticket Creation:

  • /issue-create - Generate a GitHub issue from this PR content using AI
  • /jira-create - Create a SRVKP Jira ticket from this PR content using AI

⚠️ Important: Always review and edit generated content before finalizing tickets/issues.
The AI-generated content should be used as a starting point and may need adjustments.

These commands are available to maintainers and will post the generated content as PR comments for review.

🤖 This feedback was generated automatically by the PR CI system

@aThorp96 aThorp96 force-pushed the no-start-status-description branch 2 times, most recently from 80ddccb to 8d2dff2 Compare January 12, 2026 16:47
@aThorp96
Copy link
Copy Markdown
Member Author

Note on the Gemini feedback: most of the Gemini feedback is requesting I enumerate switch statements and/or have logic for some currently-noop cases (e.g. Gitea doesn't handle Cancelled, Completed, or Skipped).

A downside of using a pseudo-enum for these states is that the linter requires switch statements be exhaustive and also tells you to switch any if+elseif statements to switched. The upside though is these linting rules seem to be highlighting VCS feature-parity gaps. That being said, IMO resolving those gaps is out of scope of this PR. This PR should IMO have no change in behavior, just code organization and safety

Copy link
Copy Markdown
Member

@theakshaypant theakshaypant left a comment

Choose a reason for hiding this comment

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

LGTM, I would still like to wait for the CI fix to run e2e on the PR before merging it.

@chmouel
Copy link
Copy Markdown
Member

chmouel commented Jan 13, 2026

can you double check the default case if they are being passed directly to the provider status ? i am uncertain it's the case but i haven't dug down into the code

@aThorp96 aThorp96 force-pushed the no-start-status-description branch 2 times, most recently from c7a9a38 to c77cb57 Compare January 20, 2026 11:13
@zakisk
Copy link
Copy Markdown
Member

zakisk commented Feb 18, 2026

@aThorp96 again there are many conflicts 🥲

The Conclusion field of StatusOpts has a discrete number of supported
values. These being typed as strings has introduced bugs in the past
and makes adding new values difficult. Defining the supported values
as constant enums improves both the safety of the values and the ease
of working with them.
@theakshaypant theakshaypant force-pushed the no-start-status-description branch from 1befc05 to dd7cfa8 Compare February 23, 2026 05:32
@theakshaypant
Copy link
Copy Markdown
Member

Only did a rebase. Will address the comments in a separate commit next

@chmouel chmouel merged commit 41c6ace into tektoncd:main Feb 23, 2026
11 checks passed
@chmouel
Copy link
Copy Markdown
Member

chmouel commented Feb 23, 2026

Thank you @theakshaypant 🙏🏻

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants