-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
<!--⚠️ If you do not respect this template, your pull request will be closed.⚠️ Your pull request title should be short detailed and understandable for all.⚠️ Also, please add a release note file using reno if the change needs to be documented in the release notes.⚠️ If your pull request fixes an open issue, please link to the issue. - [ ] I have added the tests to cover my changes. - [ ] I have updated the documentation accordingly. - [ ] I have read the CONTRIBUTING document. --> ### Summary Clean up `manager.py` by re-organizing it by subcmd. ### Details and comments - [x] ci subcmd - [x] tests subcmd - [x] website subcmd - [x] members subcmd - [x] Update docs - [x] Update tests - [x] Update CI/tox --- Closes #230 --------- Co-authored-by: Eric Arellano <[email protected]>
- Loading branch information
1 parent
7a50000
commit a8bcecc
Showing
20 changed files
with
426 additions
and
332 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
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 |
---|---|---|
|
@@ -37,7 +37,7 @@ jobs: | |
|
||
- name: Recompile and push | ||
run: | | ||
python -m manager recompile | ||
python -m manager members recompile | ||
git config user.name github-actions | ||
git config user.email [email protected] | ||
|
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
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 |
---|---|---|
@@ -1,2 +1 @@ | ||
"""Ecosystem main module.""" | ||
from .manager import Manager |
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,5 @@ | ||
"""CLI.""" | ||
from .members import CliMembers | ||
from .website import CliWebsite | ||
from .ci import CliCI | ||
from .tests import CliTests |
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,121 @@ | ||
"""CliCI class for controlling all CLI functions.""" | ||
import os | ||
from typing import Optional | ||
|
||
import requests | ||
|
||
from ecosystem.daos import DAO | ||
from ecosystem.models import Tier | ||
from ecosystem.utils import logger, parse_submission_issue | ||
from ecosystem.utils.utils import set_actions_output | ||
|
||
|
||
class CliCI: | ||
"""CliCI class. | ||
Entrypoint for all CLI CI commands. | ||
Each public method of this class is CLI command | ||
and arguments for method are options/flags for this command. | ||
Ex: `python manager.py ci parser_issue --body="<SOME_MARKDOWN>"` | ||
""" | ||
|
||
def __init__(self, root_path: Optional[str] = None): | ||
"""CliCI class.""" | ||
self.current_dir = root_path or os.path.abspath(os.getcwd()) | ||
self.resources_dir = "{}/ecosystem/resources".format(self.current_dir) | ||
self.dao = DAO(path=self.resources_dir) | ||
self.logger = logger | ||
|
||
def dispatch_check_workflow( | ||
self, | ||
repo_url: str, | ||
branch_name: str, | ||
tier: str, | ||
token: str, | ||
owner: str = "qiskit-community", | ||
repo: str = "ecosystem", | ||
) -> bool: | ||
"""Dispatch event to trigger check workflow. | ||
Args: | ||
repo_url: url of the repo | ||
branch_name: name of the branch | ||
tier: tier of the project | ||
token: token base on the date | ||
owner: "qiskit-community" parameters | ||
repo: "ecosystem" | ||
Return: true | ||
""" | ||
url = "https://api.github.com/repos/{owner}/{repo}/dispatches".format( | ||
owner=owner, repo=repo | ||
) | ||
repo_split = repo_url.split("/") | ||
repo_name = repo_split[-1] | ||
|
||
# run each type of tests in same workflow | ||
response = requests.post( | ||
url, | ||
json={ | ||
"event_type": "check_project", | ||
"client_payload": { | ||
"repo_url": repo_url, | ||
"repo_name": repo_name, | ||
"branch_name": branch_name, | ||
"tier": tier, | ||
}, | ||
}, | ||
headers={ | ||
"Authorization": "token {}".format(token), | ||
"Accept": "application/vnd.github.v3+json", | ||
}, | ||
) | ||
if response.ok: | ||
self.logger.info("Success response on dispatch event. %s", response.text) | ||
else: | ||
self.logger.warning( | ||
"Something wend wrong with dispatch event: %s", response.text | ||
) | ||
return True | ||
|
||
def expose_all_project_to_actions(self): | ||
"""Exposes all project for github actions.""" | ||
repositories = [] | ||
tiers = [] | ||
for tier in Tier.non_main_tiers(): | ||
for repo in self.dao.get_repos_by_tier(tier): | ||
if not repo.skip_tests: | ||
repositories.append(repo.url) | ||
tiers.append(repo.tier) | ||
set_actions_output( | ||
[("repositories", ",".join(repositories)), ("tiers", ",".join(tiers))] | ||
) | ||
|
||
@staticmethod | ||
def parser_issue(body: str) -> None: | ||
"""Command for calling body issue parsing function. | ||
Args: | ||
body: body of the created issue | ||
Returns: | ||
logs output | ||
We want to give the result of the parsing issue to the GitHub action | ||
""" | ||
|
||
parsed_result = parse_submission_issue(body) | ||
|
||
to_print = [ | ||
("SUBMISSION_NAME", parsed_result.name), | ||
("SUBMISSION_REPO", parsed_result.url), | ||
("SUBMISSION_DESCRIPTION", parsed_result.description), | ||
("SUBMISSION_LICENCE", parsed_result.licence), | ||
("SUBMISSION_CONTACT", parsed_result.contact_info), | ||
("SUBMISSION_ALTERNATIVES", parsed_result.alternatives), | ||
("SUBMISSION_AFFILIATIONS", parsed_result.affiliations), | ||
("SUBMISSION_LABELS", parsed_result.labels), | ||
("SUBMISSION_WEBSITE", parsed_result.website), | ||
] | ||
|
||
set_actions_output(to_print) |
Oops, something went wrong.