ome / scc

OME tools for managing the Git(Hub) workflow
https://pypi.org/project/scc/
GNU General Public License v2.0
0 stars 15 forks source link

Refactor status filter logic to handle both Status and Checks API #266

Closed sbesson closed 3 years ago

sbesson commented 3 years ago

Summary

As the CI/CD of our organizational repositories are getting migrated to using GitHub Actions, changes are required at the level of scc to handle the output of these runs. Unlike Travis CI which uses the Status API, GitHub Actions use the recent Check API in order to report the outcome.

This PR makes the minimal amount of change to re-use the existing semantics of the merge command but apply the status filter to both existing check_suites as well as the status.

The status reading logic is also updated to use the count of get_statuses() to determine whether a status exists and then use the combined status API to return a single state.

The check-suite logic uses the count of get_check_suites() to determine whether a check-suite has been executed and the tests the conclusion of each check-suite.

The state filtering is also updated to handle the skipped conclusion as a successful one.

Requirements

This PR depends on the check suite API introduced in PyGithub 1.54. This raises the minimum version of Python to 3.5.

Testing

To test this feature, install it in a virtual environment

python3 -m venv venv
venv/bin/pip install git+https://github.com/ome/scc@refs/pull/266/merge

Then run scc merge --info master -S success-only against a few repository including a combination of Travis CI, GitHUb Actions only or a mixture of Travis CI/GitHub actions tested PRs. A few examples I used: omero-py, omero-web, omero-iviewer, bioformats,

joshmoore commented 3 years ago

:+1: for the new API usage. Code looks good. Results with released scc:

(base) /tmp/omero-py.before $scc merge --info master -S success-only
2020-11-30 12:19:26,414 [   scc.merge] INFO  Listing Pull Request(s) based on master
2020-11-30 12:19:26,414 [   scc.merge] INFO  Including Pull Request(s) opened by any public member of the organization
2020-11-30 12:19:26,415 [   scc.merge] INFO  Including Pull Request(s) labelled as include
2020-11-30 12:19:26,415 [   scc.merge] INFO  Excluding Pull Request(s) labelled as exclude or breaking
2020-11-30 12:19:26,415 [   scc.merge] INFO  Excluding Pull Request(s) without successful status
2020-11-30 12:19:40,454 [   scc.merge] INFO  Repository: ome/omero-py
2020-11-30 12:19:40,454 [   scc.merge] INFO  Excluded PRs:
2020-11-30 12:19:40,455 [   scc.merge] INFO    - PR 266 joshmoore 'errors: use raise_error from cli plugins' (status: )
2020-11-30 12:19:40,455 [   scc.merge] INFO    - PR 184 manics 'Auto-format code with black' (exclude comment)
2020-11-30 12:19:40,455 [   scc.merge] INFO    - PR 160 manics 'prefs.py: config throw if OMERODIR not set' (exclude comment)
2020-11-30 12:19:40,455 [   scc.merge] INFO    - PR 129 dominikl 'Add option to create new ThumbnailStore connection' (exclude comment)
2020-11-30 12:19:40,456 [   scc.merge] INFO    - PR 115 manics 'Remove omero_ext.argparse' (exclude comment)
2020-11-30 12:19:40,456 [   scc.merge] INFO  Candidate PRs:
2020-11-30 12:19:40,456 [   scc.merge] INFO    - PR 189 manics 'BlitzGateway defaults to secure=True'
2020-11-30 12:19:40,456 [   scc.merge] INFO    - PR 194 manics 'Support Python 3 asyncio concurrency'
2020-11-30 12:19:40,456 [   scc.merge] INFO    - PR 199 joshmoore 'user: allow setting default group'
2020-11-30 12:19:40,457 [   scc.merge] INFO    - PR 205 will-moore 'api order by ID'
2020-11-30 12:19:40,457 [   scc.merge] INFO    - PR 207 manics 'BlitzGateway.connect raise on error'

Using your branch:

(base) /tmp/omero-py.after $../scc.checks/bin/scc merge --info master -S success-only
2020-11-30 12:21:44,891 [   scc.merge] INFO  Listing Pull Request(s) based on master
2020-11-30 12:21:44,892 [   scc.merge] INFO  Including Pull Request(s) opened by any public member of the organization
2020-11-30 12:21:44,893 [   scc.merge] INFO  Including Pull Request(s) labelled as include or dependencies
2020-11-30 12:21:44,893 [   scc.merge] INFO  Excluding Pull Request(s) labelled as exclude or breaking
2020-11-30 12:21:44,893 [   scc.merge] INFO  Excluding Pull Request(s) without successful status
2020-11-30 12:21:56,605 [   scc.merge] INFO  Repository: ome/omero-py
2020-11-30 12:21:56,605 [   scc.merge] INFO  Excluded PRs:
2020-11-30 12:21:56,605 [   scc.merge] INFO    - PR 184 manics 'Auto-format code with black' (exclude comment)
2020-11-30 12:21:56,605 [   scc.merge] INFO    - PR 160 manics 'prefs.py: config throw if OMERODIR not set' (exclude comment)
2020-11-30 12:21:56,606 [   scc.merge] INFO    - PR 129 dominikl 'Add option to create new ThumbnailStore connection' (exclude comment)
2020-11-30 12:21:56,606 [   scc.merge] INFO    - PR 115 manics 'Remove omero_ext.argparse' (exclude comment)
2020-11-30 12:21:56,606 [   scc.merge] INFO  Candidate PRs:
2020-11-30 12:21:56,606 [   scc.merge] INFO    - PR 189 manics 'BlitzGateway defaults to secure=True'
2020-11-30 12:21:56,606 [   scc.merge] INFO    - PR 194 manics 'Support Python 3 asyncio concurrency'
2020-11-30 12:21:56,607 [   scc.merge] INFO    - PR 199 joshmoore 'user: allow setting default group'
2020-11-30 12:21:56,607 [   scc.merge] INFO    - PR 205 will-moore 'api order by ID'
2020-11-30 12:21:56,607 [   scc.merge] INFO    - PR 207 manics 'BlitzGateway.connect raise on error'
2020-11-30 12:21:56,607 [   scc.merge] INFO    - PR 266 joshmoore 'errors: use raise_error from cli plugins'
2020-11-30 12:21:56,607 [   scc.merge] INFO

My PR (266) gets added which is green.

sbesson commented 3 years ago

Thanks. Merging, tagging and releasing to confirm this fixes the daily integration workflow for all repositories that have been already migrating to GH actions /cc @jburel