Skip to content

Support for status commits#93

Merged
wechuli merged 18 commits intomainfrom
wechuli/support-status-commits
Oct 5, 2025
Merged

Support for status commits#93
wechuli merged 18 commits intomainfrom
wechuli/support-status-commits

Conversation

@wechuli
Copy link
Copy Markdown
Owner

@wechuli wechuli commented Oct 4, 2025

Fixes #61
This pull request introduces support for including commit statuses alongside checks when evaluating the state of a commit. It adds a new input to the action, updates the core logic to fetch and process commit statuses, and improves the summary output to clearly distinguish between checks and commit statuses. The changes also include refactoring for code clarity and test coverage for the new filtering logic.

…ntainability

- Cleaned up imports and exports in checks.ts, checksAPI.ts, checksConstants.ts, checksFilters.ts, and checksInterfaces.ts.
- Consolidated and optimized functions for filtering and processing checks based on app ID and name.
- Introduced new utility functions to handle duplicate entries and check statuses.
- Added new statuses module with interfaces and constants for managing commit statuses.
- Removed commented-out code to enhance clarity and focus on active functionality.
- Implement getMostRecentStatusPerContextAndCreator function to filter statuses.
- Update getAllStatusCommits to return typed IStatus[].
- Create tests for status filtering logic.
- Add documentation for filtering by commit status.
@wechuli wechuli requested a review from Copilot October 4, 2025 18:05
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces support for GitHub commit statuses alongside checks when evaluating commit state. The action can now optionally fetch and process commit statuses through a new include_status_commits input parameter.

  • Adds new input parameter include_status_commits to enable/disable commit status evaluation
  • Implements commit status fetching, filtering, and mapping to the existing checks model
  • Enhances summary output to distinguish between checks and commit statuses with separate tables

Reviewed Changes

Copilot reviewed 15 out of 41 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/utils/inputsExtractor.ts Adds new boolean input includeStatusCommits
src/statuses/statusesInterfaces.ts Defines interface for GitHub commit status objects
src/statuses/statusesFilters.ts Implements filtering logic to get most recent status per context/creator
src/statuses/statusesConstants.ts Defines commit status states and emoji mapping functions
src/statuses/statusesAPI.ts Provides API client for fetching commit statuses
src/statuses/statuses.ts Maps commit statuses to the existing checks model
src/checks/checksInterfaces.ts Refactors interfaces and adds optional commit_status field
src/checks/checksFilters.ts Code formatting improvements without functional changes
src/checks/checksConstants.ts Removes duplicate commit status constants and formatting cleanup
src/checks/checksAPI.ts Adds proper typing and removes commented code
src/checks/checks.ts Integrates commit status fetching and enhances summary display
src/checks/checkEmoji.ts Formatting improvements for object properties
docs/adrs/commit_status.md Placeholder documentation for commit status filtering
action.yml Adds new input parameter definition
tests/statuses/statusesFilters.test.ts Comprehensive test coverage for status filtering logic

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +8 to +12
interface ICommitStatuseEmoji {
[key: string]: string;
}

const commitStatusStateEmojis: ICommitStatuseEmoji = {
Copy link

Copilot AI Oct 4, 2025

Choose a reason for hiding this comment

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

Corrected spelling of 'ICommitStatuseEmoji' to 'ICommitStatusEmoji'.

Suggested change
interface ICommitStatuseEmoji {
[key: string]: string;
}
const commitStatusStateEmojis: ICommitStatuseEmoji = {
interface ICommitStatusEmoji {
[key: string]: string;
}
const commitStatusStateEmojis: ICommitStatusEmoji = {

Copilot uses AI. Check for mistakes.
Comment on lines +8 to +12
interface ICommitStatuseEmoji {
[key: string]: string;
}

const commitStatusStateEmojis: ICommitStatuseEmoji = {
Copy link

Copilot AI Oct 4, 2025

Choose a reason for hiding this comment

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

Interface name should be corrected to 'ICommitStatusEmoji' to match the fix above.

Suggested change
interface ICommitStatuseEmoji {
[key: string]: string;
}
const commitStatusStateEmojis: ICommitStatuseEmoji = {
interface ICommitStatusEmoji {
[key: string]: string;
}
const commitStatusStateEmojis: ICommitStatusEmoji = {

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,3 @@
## Filtering by Commit Status

There are some nuances to be aware of when it comes to filtering by commit statuses using this action. No newline at end of file
Copy link

Copilot AI Oct 4, 2025

Choose a reason for hiding this comment

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

The documentation file is incomplete. It only contains a header with no actual content explaining the nuances of filtering by commit statuses.

Suggested change
There are some nuances to be aware of when it comes to filtering by commit statuses using this action.
Filtering by commit status allows you to select commits based on the state of their associated status checks (such as CI/CD pipelines, code quality checks, or other automated processes). This can be useful for automating workflows that depend on the success or failure of these checks.
### What is a Commit Status?
A commit status is a label (such as `success`, `failure`, or `pending`) attached to a commit by external systems (like continuous integration services). Each status is associated with a context (e.g., `ci/travis`, `codecov/project`) and a state.
### Nuances and Caveats
- **Multiple Status Contexts:** A single commit can have multiple status contexts. When filtering, you may need to specify which context(s) you care about, or whether you want all statuses to be successful.
- **Status vs. Check Runs:** Some platforms distinguish between "statuses" and "check runs." Make sure you are filtering the correct type for your use case.
- **Pending Statuses:** If a status is `pending`, it may not be safe to assume the commit is ready for further action. Consider whether to include or exclude pending statuses in your filter.
- **Timing Issues:** Statuses may be updated asynchronously. A commit that initially has a `pending` status may later be updated to `success` or `failure`. Ensure your workflow accounts for this delay.
- **Required Statuses:** Some repositories enforce required status checks before allowing merges. Filtering by commit status can help enforce these policies programmatically.
### Example Usage
To filter commits that have passed all required status checks:
```yaml
- uses: actions/checkout@v3
- name: Filter commits by status
uses: your-org/filter-commits-by-status@v1
with:
status: success
context: ci/travis

In this example, only commits with a success status in the ci/travis context will be selected.

Best Practices

  • Always specify the status context if your repository uses multiple CI/CD systems.
  • Consider re-checking commit statuses if your workflow is triggered by events that may occur before all statuses are available.
  • Document which statuses are required for your workflow to avoid confusion.

Copilot uses AI. Check for mistakes.
- Updated tests for checks filtering functions to improve readability and consistency.
- Added comprehensive tests for `getMostRecentStatusPerContextAndCreator` to ensure correct behavior with multiple contexts and creators.
- Introduced new tests for `mapStatusesToChecksModel` to validate mapping of various status states and ensure preservation of original status fields.
- Implemented tests for `getAllStatusCommits` to verify API interaction and error handling.
- Added tests for constants related to commit status to ensure correct emoji representation and state validation.
@wechuli wechuli requested a review from Copilot October 5, 2025 03:40
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 27 out of 54 changed files in this pull request and generated no new comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@wechuli wechuli merged commit 105c017 into main Oct 5, 2025
4 checks passed
@wechuli wechuli deleted the wechuli/support-status-commits branch October 5, 2025 03:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for commit statuses

2 participants