Skip to content

Commit

Permalink
Move package dependencies from optional section
Browse files Browse the repository at this point in the history
Dependencies marked as optional were not really optional and it is
better to have them as a required dependencies.

Signed-off-by: Ales Raszka <[email protected]>
  • Loading branch information
Allda committed Feb 9, 2024
1 parent aaaadac commit b671883
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 55 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ jobs:
with:
python-version: "3.11"

- name: Install non-python dependencies
run: |
sudo apt-get install -y libkrb5-dev
- name: Install Hadolint via Brew
run: |
NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Expand Down
4 changes: 1 addition & 3 deletions operator-pipeline-images/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,12 @@ RUN pip3 install --no-cache-dir --upgrade pip setuptools wheel && pip3 install -
# install dependencies in virtual environment
COPY ./pdm.lock ./pyproject.toml ./README.md ./
RUN pdm venv create 3.11 && pdm install --no-lock --no-editable \
--group operatorcert \
--group operatorcert-dev

ENV VIRTUAL_ENV=/home/user/.venv
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

# set dir ownership
RUN chgrp -R 0 /home/user /etc/passwd
RUN chmod -R g=u /home/user /etc/passwd
RUN chgrp -R 0 /home/user /etc/passwd && chmod -R g=u /home/user /etc/passwd

USER "${USER_UID}"
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def main() -> None:
log_level = "DEBUG"
setup_logger(level=log_level)

github_auth = Auth.Token(os.environ.get("GITHUB_TOKEN"))
github_auth = Auth.Token(os.environ.get("GITHUB_TOKEN") or "")
github = Github(auth=github_auth)
configure_test_suite(args, github)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def main() -> None:
log_level = "DEBUG" if args.verbose else "INFO"
setup_logger(level=log_level)

github_auth = Auth.Token(os.environ.get("GITHUB_TOKEN"))
github_auth = Auth.Token(os.environ.get("GITHUB_TOKEN") or "")
github = Github(auth=github_auth)
gist = create_github_gist(github, args.input_path)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def main() -> None:
log_level = "DEBUG"
setup_logger(level=log_level)

github_auth = Auth.Token(os.environ.get("GITHUB_TOKEN"))
github_auth = Auth.Token(os.environ.get("GITHUB_TOKEN") or "")
github = Github(auth=github_auth)

add_or_remove_labels(
Expand Down
5 changes: 3 additions & 2 deletions operator-pipeline-images/operatorcert/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from typing import Any, Dict, List, Optional

import requests
from github import Github, Label, PullRequest
from github import Github, Label, PaginatedList, PullRequest
from operatorcert.utils import add_session_retries

LOGGER = logging.getLogger("operator-cert")
Expand Down Expand Up @@ -172,7 +172,8 @@ def remove_labels_from_pull_request(


def detect_namespace_labels(
current_labels: List[Label.Label], label_namespaces: List[str]
current_labels: PaginatedList.PaginatedList[Label.Label],
label_namespaces: List[str],
) -> List[str]:
"""
Return a list of current labels that match the given namespaces.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def test_wait_on_pr_labels_success(
capsys: Any,
) -> None:
mock_get_pr_labels.side_effect = pr_labels_sequence
assert wait_on_pr_labels(None, 1, wait_conditions, 5, 0.1)
assert wait_on_pr_labels(MagicMock(), 1, wait_conditions, 5, 0.1)

captured_stdout, _ = capsys.readouterr()
assert captured_stdout == str.join("\n", pr_labels_sequence[-1]) + "\n"
Expand All @@ -267,7 +267,7 @@ def test_wait_on_pr_labels_timeout(
wait_conditions: list[WaitCondition],
) -> None:
mock_get_pr_labels.return_value = pr_labels
assert not wait_on_pr_labels(None, 1, wait_conditions, 1, 0.1)
assert not wait_on_pr_labels(MagicMock(), 1, wait_conditions, 1, 0.1)


@patch("operatorcert.entrypoints.github_wait_labels.sys.exit")
Expand Down
49 changes: 25 additions & 24 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 16 additions & 17 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,22 @@ authors = [
requires-python = ">=3.10"
readme = "README.md"
license = { text = "GPLv3" }
dependencies = [
"python-magic>=0.4.24",
"pyyaml>=5.4.1",
"requests>=2.31.0",
"yq>=2.12.2",
"giturlparse>=0.10.0",
"python-dateutil>=2.8.2",
"humanize>=3.12.0",
"stomp-py>=8.0.1",
"requests-kerberos>=0.14.0",
"PyGithub<2.0,>=1.59.0",
"GitPython>=3.1.37",
"semver>=3.0.1",
"operator-repo @ git+https://github.com/mporrato/[email protected]",
"urllib3>=2.0.7",
]

[project.scripts]
apply-test-waivers = "operatorcert.entrypoints.apply_test_waivers:main"
Expand Down Expand Up @@ -69,23 +85,6 @@ verify-pr-title = "operatorcert.entrypoints.verify_pr_title:main"
verify-pr-uniqueness = "operatorcert.entrypoints.verify_pr_uniqueness:main"
verify-pr-user = "operatorcert.entrypoints.verify_pr_user:main"

[project.optional-dependencies]
operatorcert = [
"python-magic>=0.4.24",
"pyyaml>=5.4.1",
"requests>=2.31.0",
"yq>=2.12.2",
"giturlparse>=0.10.0",
"python-dateutil>=2.8.2",
"humanize>=3.12.0",
"stomp-py>=8.0.1",
"requests-kerberos>=0.14.0",
"PyGithub>=1.59.0",
"GitPython>=3.1.37",
"semver>=3.0.1",
"operator-repo @ git+https://github.com/mporrato/[email protected]",
"urllib3>=2.0.7",
]

[build-system]
requires = ["pdm-pep517>=1.0"]
Expand Down
6 changes: 2 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ skipsdist = True
extras = dev

[testenv:test]
groups = operatorcert
operatorcert-dev
groups = operatorcert-dev
commands = pytest -v \
--cov {[vars]OPERATOR_MODULE} \
--cov-report term-missing \
Expand All @@ -44,14 +43,13 @@ commands = mypy {[vars]MYPY_SOURCE_ARGS} {[vars]OPERATOR_MODULE}
[testenv:pylint]
groups =
operatorcert-dev
operatorcert
commands = pylint {[vars]OPERATOR_MODULE} \
--min-similarity-lines 9 \
-d fixme

[testenv:yamllint]
basepython = python3.11
groups = operatorcert-dev, operatorcert
groups = operatorcert-dev
files =
.
commands =
Expand Down

0 comments on commit b671883

Please sign in to comment.