diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml new file mode 100644 index 0000000000..fbd227af2b --- /dev/null +++ b/.github/workflows/tests.yaml @@ -0,0 +1,29 @@ +name: Unit tests + +on: + pull_request: + branches: [ master ] + +jobs: + test: + runs-on: ubuntu-latest + container: fedora:37 + steps: + - name: Install packages + run: dnf install -y gcc krb5-devel git + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: recursive + - name: Set up Python 3.8 + uses: actions/setup-python@v4 + with: + python-version: '3.8' + - name: Create venv and install dependencies + run: | + cd pyartcd + make venv + - name: Run tests + run: | + cd pyartcd + make test diff --git a/pyartcd/Makefile b/pyartcd/Makefile index 2e6327d06a..faa25209a2 100644 --- a/pyartcd/Makefile +++ b/pyartcd/Makefile @@ -2,6 +2,9 @@ venv: python3.8 -m venv venv + ./venv/bin/pip install --upgrade pip + ./venv/bin/pip install -e ../art-tools/doozer/ + ./venv/bin/pip install -e ../art-tools/elliott/ ./venv/bin/pip install -r requirements-dev.txt -r requirements.txt # source venv/bin/activate diff --git a/pyartcd/pyartcd/pipelines/advisory_drop.py b/pyartcd/pyartcd/pipelines/advisory_drop.py index 85652806e7..34750c38e0 100644 --- a/pyartcd/pyartcd/pipelines/advisory_drop.py +++ b/pyartcd/pyartcd/pipelines/advisory_drop.py @@ -15,21 +15,21 @@ async def advisory_drop(runtime: Runtime, group: str, advisory: str, comment: str): # repair-bugs cmd = [ - 'elliott', - '--group', group, - 'repair-bugs', - '--advisory', advisory, - '--auto', - '--comment', comment, - '--close-placeholder', - '--from', 'RELEASE_PENDING', - '--to', 'VERIFIED', - ] + 'elliott', + '--group', group, + 'repair-bugs', + '--advisory', advisory, + '--auto', + '--comment', comment, + '--close-placeholder', + '--from', 'RELEASE_PENDING', + '--to', 'VERIFIED', + ] await exectools.cmd_assert_async(cmd, env=os.environ.copy()) # drop advisory cmd = [ - 'elliott', - '--group', group, - 'advisory-drop', advisory, - ] + 'elliott', + '--group', group, + 'advisory-drop', advisory, + ] await exectools.cmd_assert_async(cmd, env=os.environ.copy()) diff --git a/pyartcd/pyartcd/pipelines/build_microshift.py b/pyartcd/pyartcd/pipelines/build_microshift.py index 3ca2dc8ff9..bfeb499b6e 100644 --- a/pyartcd/pyartcd/pipelines/build_microshift.py +++ b/pyartcd/pyartcd/pipelines/build_microshift.py @@ -396,12 +396,12 @@ async def _create_or_update_pull_request(self, nvrs: List[str]): if not existing_prs.items: result = api.pulls.create(head=head, base=base, title=title, body=body, maintainer_can_modify=True) api.pulls.merge(owner=owner, repo=repo, pull_number=result.number, merge_method="squash") - api.git.delete_ref(owner=owner,repo=repo,ref=f"heads/{branch}") + api.git.delete_ref(owner=owner, repo=repo, ref=f"heads/{branch}") else: pull_number = existing_prs.items[0].number result = api.pulls.update(pull_number=pull_number, title=title, body=body) api.pulls.merge(owner=owner, repo=repo, pull_number=pull_number, merge_method="squash") - api.git.delete_ref(owner=owner,repo=repo,ref=f"heads/{branch}") + api.git.delete_ref(owner=owner, repo=repo, ref=f"heads/{branch}") else: self._logger.warning("PR is not created: Nothing to commit.") return result diff --git a/pyartcd/pyartcd/pipelines/ocp4.py b/pyartcd/pyartcd/pipelines/ocp4.py index 7babb1b5fc..efec379f56 100644 --- a/pyartcd/pyartcd/pipelines/ocp4.py +++ b/pyartcd/pyartcd/pipelines/ocp4.py @@ -7,7 +7,7 @@ import yaml from aioredlock import LockError -from pyartcd import locks, util, plashets, exectools, constants,\ +from pyartcd import locks, util, plashets, exectools, constants, \ run_details, jenkins, record as record_util, oc from pyartcd.cli import cli, pass_runtime, click_coroutine from pyartcd.runtime import Runtime @@ -584,7 +584,7 @@ async def _mass_rebuild(self, doozer_cmd: list): ) # Try to acquire mass-rebuild lock for build version - lock_name = f'mass-rebuild-serializer' + lock_name = 'mass-rebuild-serializer' try: async with await lock_manager.lock(lock_name): self.runtime.logger.info('Running command: %s', doozer_cmd) diff --git a/pyartcd/pyartcd/pipelines/promote.py b/pyartcd/pyartcd/pipelines/promote.py index 0be32fcf7d..da6b0459be 100644 --- a/pyartcd/pyartcd/pipelines/promote.py +++ b/pyartcd/pyartcd/pipelines/promote.py @@ -26,7 +26,7 @@ from pyartcd.exceptions import VerificationError from pyartcd.jira import JIRAClient from pyartcd.s3 import sync_dir_to_s3_mirror -from pyartcd.oc import get_release_image_info, get_release_image_pullspec, extract_release_binary,\ +from pyartcd.oc import get_release_image_info, get_release_image_pullspec, extract_release_binary, \ extract_release_client_tools, get_release_image_info_from_pullspec, extract_baremetal_installer from pyartcd.runtime import Runtime from ruamel.yaml import YAML @@ -105,7 +105,7 @@ async def run(self): assembly_type = util.get_assembly_type(releases_config, self.assembly) release_name = util.get_release_name_for_assembly(self.group, releases_config, self.assembly) # Ensure release name is valid - if not VersionInfo.isvalid(release_name): + if not VersionInfo.is_valid(release_name): raise ValueError(f"Release name `{release_name}` is not a valid semver.") logger.info("Release name: %s", release_name) @@ -129,7 +129,7 @@ async def run(self): raise ValueError(f"Group config for assembly {self.assembly} is missing the required `upgrades` field. If no upgrade edges are expected, please explicitly set the `upgrades` field to empty string.") previous_list = list(map(lambda s: s.strip(), upgrades_str.split(","))) if upgrades_str else [] # Ensure all versions in previous list are valid semvers. - if any(map(lambda version: not VersionInfo.isvalid(version), previous_list)): + if any(map(lambda version: not VersionInfo.is_valid(version), previous_list)): raise ValueError("Previous list (`upgrades` field in group config) has an invalid semver.") impetus_advisories = group_config.get("advisories", {}) diff --git a/pyartcd/requirements.txt b/pyartcd/requirements.txt index 31074165ce..41e29a4519 100644 --- a/pyartcd/requirements.txt +++ b/pyartcd/requirements.txt @@ -3,16 +3,13 @@ aiofiles aioredlock >= 0.7.3 click contextvars -errata_tool -errata-tool @ git+https://github.com/red-hat-storage/errata-tool@v1.31.0 +errata-tool ~= 1.31.0 ghapi jenkinsapi >= 0.3.13 # https://github.com/pycontribs/jenkinsapi/issues/833 Jinja2 jira >= 3.4.1 # https://github.com/pycontribs/jira/issues/1486 openshift-client pygit2 == 1.10.1 # https://github.com/libgit2/pygit2/issues/1176 -rh-elliott -rh-doozer ruamel.yaml semver >= 2.13.0 slack_sdk >= 3.13.0