Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ART-6367 Run pyartcd tests #3855

Merged
merged 9 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions pyartcd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
28 changes: 14 additions & 14 deletions pyartcd/pyartcd/pipelines/advisory_drop.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
4 changes: 2 additions & 2 deletions pyartcd/pyartcd/pipelines/build_microshift.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions pyartcd/pyartcd/pipelines/ocp4.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions pyartcd/pyartcd/pipelines/promote.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand All @@ -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", {})
Expand Down
5 changes: 1 addition & 4 deletions pyartcd/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@ aiofiles
aioredlock >= 0.7.3
click
contextvars
errata_tool
errata-tool @ git+https://github.com/red-hat-storage/[email protected]
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
Expand Down