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

Pin Python version to 3.11 #1118

Merged
merged 1 commit into from
Feb 13, 2024
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
5 changes: 5 additions & 0 deletions .github/workflows/code_quality.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,13 @@ jobs:
id: setup-python
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'poetry'

- name: Configure poetry
run: |
poetry env use "${{ steps.setup-python.outputs.python-path }}"

- run: poetry check --lock

- name: Install ruff
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/dry_run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,17 @@ jobs:

steps:
- uses: actions/checkout@v3

- name: Install Poetry
uses: snok/install-poetry@v1

- name: Set up Python
id: setup-python
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'poetry'

- name: Execute ods-ci dryrun
run: |
mv ods_ci/test-variables.yml.example ods_ci/test-variables.yml
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ and its upstream project, [Open Data Hub](https://opendatahub.io/).
# Requirements
1. Linux distribution that supports Selenium automation on top of either a Chromium/Google-Chrome web browser using [ChromeDriver](https://chromedriver.chromium.org) or Firefox web browser using [geckodriver](https://github.com/mozilla/geckodriver):
* relevant web driver binaries can be downloaded here: [ChromeDriver](https://googlechromelabs.github.io/chrome-for-testing) or [geckodriver](https://github.com/mozilla/geckodriver/releases)
* the `ChromeDriver` version must match the installed version of Chromium/Google-Chrome, for `geckodriver` see the release notes for paritcular release
* the `ChromeDriver` version must match the installed version of Chromium/Google-Chrome, for `geckodriver` see the release notes for particular release
* install your web driver so that it's visible by Robot Framework during tests execution, e.g. into `~/.local/bin` path

2. [Poetry](https://python-poetry.org/docs/#installation) tool installed and added to your `$PATH`.
Expand Down Expand Up @@ -53,7 +53,7 @@ and its upstream project, [Open Data Hub](https://opendatahub.io/).

* This run_robot_test.sh is a wrapper for creating the python virtual environment and running the Robot Framework CLI.
* The wrapper script has several arguments and you can find details in the dedicated document file. See [run_args.md](ods_ci/docs/RUN_ARGUMENTS.md)
* As alternative, you can run any of the test cases by creating the python virual environment, install the packages in [poetry.lock](poetry.lock) and running the `robot` command directly
* As alternative, you can run any of the test cases by creating the python virtual environment, install the packages in [poetry.lock](poetry.lock) and running the `robot` command directly


# Contributing
Expand Down
18 changes: 18 additions & 0 deletions ods_ci/run_robot_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@
fi

if [[ ${SKIP_INSTALL} -eq 0 ]]; then
# look for pre-created poetry .venv
virtenv="${HOME}/.local/ods-ci/.venv"
if [[ -d "${virtenv}" ]]; then
echo "Using a pre-created virtual environment in '${virtenv}' for poetry to save time."
Expand All @@ -327,6 +328,23 @@
else
echo "Pre-created virtual environment has not been found in '${virtenv}'. All dependencies will be installed from scratch."
fi
# ensure python 3.11
python=$(poetry env info --executable)
if [[ -n "${python}" ]] && ${python} -c 'import sys; sys.exit(0 if sys.version_info[0:2] == (3, 11) else 1)'; then
echo "Python '${python}' will be used"
else
echo "Python '${python}' is not of the correct version"
python311=$(which python3.11)
if [[ -n "${python311}" ]]; then
echo "Configuring poetry to use Python ${python311}"
poetry env use "${python311}"
else
echo "[ERROR] Python 3.11 was not found!"
echo "Install Python 3.11 on your machine. On Fedora, do 'sudo dnf install -y python3.11-devel'"
echo "then run 'poetry env use /path/to/python3.11' and then try running robot again"
exit 1
fi
fi

poetry --no-interaction install --sync
fi
Expand All @@ -351,7 +369,7 @@
fi


robot ${TEST_EXCLUDE_TAG} ${TEST_INCLUDE_TAG} -d ${TEST_ARTIFACT_DIR} -x xunit_test_result.xml -r test_report.html ${TEST_VARIABLES} --variablefile ${TEST_VARIABLES_FILE} --exclude TBC ${EXTRA_ROBOT_ARGS} ${TEST_CASE_FILE}

Check warning on line 372 in ods_ci/run_robot_test.sh

View workflow job for this annotation

GitHub Actions / shellcheck linter

[shellcheck] reported by reviewdog 🐶 Double quote to prevent globbing and word splitting. [SC2086](https://github.com/koalaman/shellcheck/wiki/SC2086) Raw Output: ./ods_ci/run_robot_test.sh:372:7:info:Double quote to prevent globbing and word splitting. [SC2086](https://github.com/koalaman/shellcheck/wiki/SC2086)

Check warning on line 372 in ods_ci/run_robot_test.sh

View workflow job for this annotation

GitHub Actions / shellcheck linter

[shellcheck] reported by reviewdog 🐶 Double quote to prevent globbing and word splitting. [SC2086](https://github.com/koalaman/shellcheck/wiki/SC2086) Raw Output: ./ods_ci/run_robot_test.sh:372:27:info:Double quote to prevent globbing and word splitting. [SC2086](https://github.com/koalaman/shellcheck/wiki/SC2086)

Check warning on line 372 in ods_ci/run_robot_test.sh

View workflow job for this annotation

GitHub Actions / shellcheck linter

[shellcheck] reported by reviewdog 🐶 Double quote to prevent globbing and word splitting. [SC2086](https://github.com/koalaman/shellcheck/wiki/SC2086) Raw Output: ./ods_ci/run_robot_test.sh:372:50:info:Double quote to prevent globbing and word splitting. [SC2086](https://github.com/koalaman/shellcheck/wiki/SC2086)

Check warning on line 372 in ods_ci/run_robot_test.sh

View workflow job for this annotation

GitHub Actions / shellcheck linter

[shellcheck] reported by reviewdog 🐶 Double quote to prevent globbing and word splitting. [SC2086](https://github.com/koalaman/shellcheck/wiki/SC2086) Raw Output: ./ods_ci/run_robot_test.sh:372:116:info:Double quote to prevent globbing and word splitting. [SC2086](https://github.com/koalaman/shellcheck/wiki/SC2086)

Check warning on line 372 in ods_ci/run_robot_test.sh

View workflow job for this annotation

GitHub Actions / shellcheck linter

[shellcheck] reported by reviewdog 🐶 Double quote to prevent globbing and word splitting. [SC2086](https://github.com/koalaman/shellcheck/wiki/SC2086) Raw Output: ./ods_ci/run_robot_test.sh:372:149:info:Double quote to prevent globbing and word splitting. [SC2086](https://github.com/koalaman/shellcheck/wiki/SC2086)

Check warning on line 372 in ods_ci/run_robot_test.sh

View workflow job for this annotation

GitHub Actions / shellcheck linter

[shellcheck] reported by reviewdog 🐶 Double quote to prevent globbing and word splitting. [SC2086](https://github.com/koalaman/shellcheck/wiki/SC2086) Raw Output: ./ods_ci/run_robot_test.sh:372:186:info:Double quote to prevent globbing and word splitting. [SC2086](https://github.com/koalaman/shellcheck/wiki/SC2086)

Check warning on line 372 in ods_ci/run_robot_test.sh

View workflow job for this annotation

GitHub Actions / shellcheck linter

[shellcheck] reported by reviewdog 🐶 Double quote to prevent globbing and word splitting. [SC2086](https://github.com/koalaman/shellcheck/wiki/SC2086) Raw Output: ./ods_ci/run_robot_test.sh:372:206:info:Double quote to prevent globbing and word splitting. [SC2086](https://github.com/koalaman/shellcheck/wiki/SC2086)
# shellcheck disable=SC2116
exit_status=$(echo $?)
echo "${exit_status}"
Expand All @@ -365,7 +383,7 @@
then
echo "Test results artifacts are too large for email"
rm rf_results.tar.gz
tar cvzf rf_results.tar.gz $(find "${TEST_ARTIFACT_DIR}" -regex '.*\(xml\|html\)$') &> /dev/null

Check warning on line 386 in ods_ci/run_robot_test.sh

View workflow job for this annotation

GitHub Actions / shellcheck linter

[shellcheck] reported by reviewdog 🐶 Quote this to prevent word splitting. [SC2046](https://github.com/koalaman/shellcheck/wiki/SC2046) Raw Output: ./ods_ci/run_robot_test.sh:386:40:warning:Quote this to prevent word splitting. [SC2046](https://github.com/koalaman/shellcheck/wiki/SC2046)
fi
python3 ods_ci/utils/scripts/Sender/send_report.py send_email_report -s "${EMAIL_FROM}" -r "${EMAIL_TO}" -b "ODS-CI: Run Results" \
-v "${EMAIL_SERVER}" -a "rf_results.tar.gz" -u "${EMAIL_SERVER_USER}" -p "${EMAIL_SERVER_PW}" \
Expand Down
14 changes: 7 additions & 7 deletions ods_ci/utils/scripts/Sender/EmailSender.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from email.mime.text import MIMEText
from email.utils import COMMASPACE, formatdate
from os.path import basename
from typing import Any, List, Optional
from typing import Any

from Sender import Sender

Expand All @@ -24,16 +24,16 @@ def __init__(self):
self._message = MIMEMultipart()

def prepare_payload(
self, text: str = "", attachments: Optional[List[Any]] = None
self, text: str = "", attachments: list[Any] | None = None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

linter wants this when you have a py3.11 project

at some point they made list[...] be an alias for typing.List[...], so that's a cleanup it wants

not sure about why it dislikes Optional, that should be fine imo, and | None is not a clear win in my eyes

) -> None:
self._message.attach(MIMEText(text))
if attachments is not None:
for filepath in attachments:
with open(filepath, "rb") as file:
part = MIMEApplication(file.read(), Name=basename(filepath))
part[
"Content-Disposition"
] = 'attachment; filename="%s"' % basename(filepath)
part["Content-Disposition"] = (
'attachment; filename="%s"' % basename(filepath)
)
self._message.attach(part)

def prepare_header(self):
Expand Down Expand Up @@ -67,10 +67,10 @@ def set_sender_address(self, sender_address: str) -> None:
def get_sender_address(self) -> str:
return self._sender_address

def set_receiver_addresses(self, receiver_addresses: List) -> None:
def set_receiver_addresses(self, receiver_addresses: list) -> None:
self._receiver_addresses = receiver_addresses

def get_receiver_addresses(self) -> List:
def get_receiver_addresses(self) -> list:
return self._receiver_addresses

def set_subject(self, subject: str) -> None:
Expand Down
4 changes: 2 additions & 2 deletions ods_ci/utils/scripts/Sender/Sender.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from abc import ABC, abstractmethod
from typing import Any, List, Optional
from typing import Any


class Sender(ABC):
@abstractmethod
def prepare_payload(
self, text: str = "", attachments: Optional[List[Any]] = None
self, text: str = "", attachments: list[Any] | None = None
) -> None:
pass

Expand Down
80 changes: 2 additions & 78 deletions poetry.lock

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

5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ authors = ["RHODS QE <ods-qe@redhat.com>"]
readme = "README.md"
packages = [{include = "ods_ci"}]

# https://python-poetry.org/docs/dependency-specification
[tool.poetry.dependencies]
python = "^3.8.1"
python = ">=3.11.5, <3.12.0"
reportportal-client = "^5.2.5"
robotframework = "^6"
robotframework-debuglibrary = ">=2.0.0"
Expand Down Expand Up @@ -47,7 +48,7 @@ profile = "black"
line_length = 88 # align with black's default

[tool.ruff]
target-version = "py38"
target-version = "py311"
line-length = 88 # align with black's default

# https://docs.astral.sh/ruff/rules
Expand Down
Loading