-
Notifications
You must be signed in to change notification settings - Fork 78
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
ci: initial implementation of top-level pytest tests #433
Merged
openshift-merge-bot
merged 1 commit into
opendatahub-io:main
from
jiridanek:jd_2024_02_24_unittests
Jul 17, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,19 @@ | ||
[tool.poetry] | ||
name = "notebooks" | ||
version = "2024.1" | ||
authors = [] | ||
description = "Open Data Hub / OpenShift AI Notebook / Workbench images, and tests for the same in Python." | ||
readme = "README.md" | ||
package-mode = false | ||
|
||
[tool.poetry.dependencies] | ||
python = "~3.12" | ||
|
||
|
||
[tool.poetry.group.dev.dependencies] | ||
pytest = "^8.2.2" | ||
pytest-subtests = "^0.12.1" | ||
|
||
[build-system] | ||
requires = ["poetry-core"] | ||
build-backend = "poetry.core.masonry.api" |
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,17 @@ | ||
# https://docs.pytest.org/en/7.1.x/reference/reference.html#configuration-options | ||
|
||
[pytest] | ||
addopts = --strict-markers --capture=no --tb=short | ||
|
||
required_plugins = pytest-subtests | ||
|
||
junit_logging = all | ||
junit_log_passing_tests = False | ||
|
||
log_cli = True | ||
log_cli_date_format = %Y-%m-%d %H:%M:%S | ||
log_cli_format = %(asctime)s %(levelname)s %(message)s | ||
log_cli_level = INFO | ||
|
||
log_file = logs/pytest-logs.txt | ||
log_file_level = DEBUG |
Empty file.
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,22 @@ | ||
from __future__ import annotations | ||
|
||
import pathlib | ||
import tomllib | ||
from typing import TYPE_CHECKING | ||
|
||
if TYPE_CHECKING: | ||
import pytest_subtests | ||
|
||
PROJECT_ROOT = pathlib.Path(__file__).parent.parent | ||
|
||
|
||
def test_image_pipfiles(subtests: pytest_subtests.plugin.SubTests): | ||
for file in PROJECT_ROOT.glob("**/Pipfile"): | ||
with subtests.test(msg="checking Pipfile", pipfile=file): | ||
directory = file.parent # "ubi9-python-3.9" | ||
ubi, lang, python = directory.name.split("-") | ||
|
||
with open(file, "rb") as fp: | ||
pipfile = tomllib.load(fp) | ||
assert "requires" in pipfile, "Pipfile is missing a [[requires]] section" | ||
assert pipfile["requires"]["python_version"] == python, "Pipfile does not declare the expected Python version" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering whether such new python version won't collide with possible future basic functional tests to test actual python packages? Shouldn't we rather stick to what we have in 2024a branch, that means Python 3.11? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Python 3.12 is not a problem. I think that that would be a valid comment for what @paulovmr is doing in
(and he has that handled, in his PR there's a separate env for every image)
Here, if we wanted to run something inside the images, which is the only meaningful way to do functional tests of packages installed in images, then we would naturally not use the python, package version, or lock file maintained in the top level by poetry, but we'd run pip install the same way as the current makefile tests install papermill, etc.