-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
replace coverage with custom framework (#874)
Python 3.12 has a significant regression in coverage analysis. Related issue: python/cpython#107674 . This PR replaces coverage with a custom framework built using `sys.monitoring`, which is only available as of Python 3.12.
- Loading branch information
Showing
11 changed files
with
346 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from http.client import HTTPSConnection | ||
import json | ||
import os | ||
import sys | ||
|
||
_token = os.environ.get('GITHUB_TOKEN') | ||
if not _token: | ||
import getpass | ||
_token = getpass.getpass('GitHub token: ') | ||
|
||
repo = os.environ.get('GITHUB_REPOSITORY', 'evalf/nutils') | ||
|
||
host = 'api.github.com' | ||
_conn = HTTPSConnection(host) | ||
|
||
def _request(method, url, *, desired_status=200): | ||
_conn.request( | ||
method, | ||
url, | ||
headers={ | ||
'Host': host, | ||
'User-Agent': 'Nutils devtools', | ||
'Accept': 'application/vnd.github+json', | ||
'Authorization': f'Bearer {_token}', | ||
'X-GitHub-Api-Version': '2022-11-28', | ||
}, | ||
) | ||
response = _conn.getresponse() | ||
if response.status != desired_status: | ||
raise RuntimeError(f'ERROR: {method} https://{host}{url} failed: {response.status} {response.reason}') | ||
return response.read() | ||
|
||
def list_workflow_run_artifacts(run_id: str): | ||
# TODO: implement pagination: https://docs.github.com/en/rest/using-the-rest-api/using-pagination-in-the-rest-api?apiVersion=2022-11-28 | ||
return json.loads(_request('GET', f'/repos/{repo}/actions/runs/{run_id}/artifacts'))['artifacts'] | ||
|
||
def delete_artifact(artifact_id: str): | ||
_request('DELETE', f'/repos/{repo}/actions/artifacts/{artifact_id}', desired_status=204) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from . import api | ||
from .. import log | ||
import os | ||
|
||
run_id = os.environ.get('GITHUB_RUN_ID') | ||
if not run_id: | ||
raise RuntimeError('ERROR: environment variable GITHUB_RUN_ID not set') | ||
|
||
for artifact in api.list_workflow_run_artifacts(run_id): | ||
if artifact['name'].startswith('_coverage_'): | ||
log.debug(f'deleting {artifact["name"]}') | ||
api.delete_artifact(artifact['id']) |
Oops, something went wrong.