Skip to content

Add "created" filter for Repository Workflow runs#2389

Closed
joshuataylor wants to merge 1 commit intoPyGithub:mainfrom
joshuataylor:feature/add-workflow-created
Closed

Add "created" filter for Repository Workflow runs#2389
joshuataylor wants to merge 1 commit intoPyGithub:mainfrom
joshuataylor:feature/add-workflow-created

Conversation

@joshuataylor
Copy link
Copy Markdown
Contributor

This created filter, which allows filtering for workflow runs created within the given date-time range. For more information on the syntax, see "Understanding the search syntax." API Docs here.

Example usage:

  1. Filtering for workflow runs by created on a repository level (all workflows):
g = Github("access_token")
g.get_repo("PyGithub/PyGithub").get_workflow_runs(created="2022-12-24")
  1. Filtering for workflow runs by created for a specific workflow
g = Github("access_token")
workflow = g.get_repo("PyGithub/PyGithub").get_workflow("ci.yml")
workflow.get_runs(created="2022-12-24")

FYI - check.yml doesn't exist anymore in the repository, the tests should be changed to ci.yml.

branch: Union[Branch, _NotSetType] = ...,
event: Union[str, _NotSetType] = ...,
status: Union[str, _NotSetType] = ...,
created: Union[datetime, _NotSetType] = ...,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Should this be Union[str, _NotSetType] ? since the parameter created is a string as mentioned in GitHub Docs
https://docs.github.com/en/rest/actions/workflow-runs?apiVersion=2022-11-28#list-workflow-runs-for-a-repository

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we can use str or datetime, if using datetime, we can convert it to str internally

Also need to keep pyi synced with py.

@AnderUstarroz
Copy link
Copy Markdown

AnderUstarroz commented Jul 31, 2023

As mentioned here, there are multiple missing fields on the get_workflow_runs() method. I think this would be a great opportunity to add the following missing params:

  • per_page (integer): The number of results per page, defaults to 30 (max 100).
  • page (integer): Page number of the results to fetch, default 1.
  • created (string): Returns workflow runs created within the given date-time range. For more information on the syntax, see "Understanding the search syntax." (datetime would be awesome here as mentioned by @trim21 )
  • check_suite_id (integer): Returns workflow runs with the check_suite_id that you specify.

@EnricoMi
Copy link
Copy Markdown
Collaborator

EnricoMi commented Aug 9, 2023

You can set per_page when creating the github.GitHub instance. The page parameter is set while iterating over the PaginatedList. So no need to add these explicitly to get_workflow_runs.

I agree that check_suite_id should be added as well.

@EnricoMi
Copy link
Copy Markdown
Collaborator

@joshuataylor @akumar1-godaddy @AnderUstarroz who volunteers continuing this pull request?

@joshuataylor
Copy link
Copy Markdown
Contributor Author

Sorry for the delay, the last few months have been crazy here.

I'll take a look a this PR and hopefully polish it up this week. :)

@RuneStone0
Copy link
Copy Markdown

RuneStone0 commented Sep 9, 2023

@joshuataylor any updates on pushing this to main? I tested the code and it works great.

@msaperst
Copy link
Copy Markdown

any updates on this fix?

@EnricoMi
Copy link
Copy Markdown
Collaborator

This is open to the community to pick up and continue. Above comments are still valid and not yet addressed.

@EnricoMi
Copy link
Copy Markdown
Collaborator

Closed in favour of #2891.

@EnricoMi EnricoMi closed this Mar 14, 2024
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.

7 participants