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

workflow,pytest: add new --error-on-skip for pytest #1756

Closed
wants to merge 1 commit into from

Conversation

mvo5
Copy link
Contributor

@mvo5 mvo5 commented Apr 25, 2024

To ensure we do not skip tests in GH actions that we want to run add a new explicit way to allowlist tests that are okay to skip.

This is done via a small pytest plugin and the GH action will only set "no SELinux" initially.

Followup for osbuild/containers#72 and #1755

[draft as a bunch of tests will fail because our container is missing some more binaries]

@mvo5 mvo5 requested a review from achilleas-k April 25, 2024 10:41
mvo5 added a commit to mvo5/containers that referenced this pull request Apr 25, 2024
With PR osbuild/osbuild#1756 we can now
see what packages are missing that cause test skips. Add them
here.
@mvo5 mvo5 marked this pull request as ready for review April 25, 2024 11:28
achilleas-k
achilleas-k previously approved these changes Apr 25, 2024
Copy link
Member

@achilleas-k achilleas-k left a comment

Choose a reason for hiding this comment

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

Interesting approach. We're getting really deep into pytest weirdnesses now :D

@@ -46,7 +46,7 @@ jobs:
TEST_CATEGORY="not test_stages.py and not test_assemblers.py"
fi
OSBUILD_TEST_STORE="${{ env.OSBUILD_TEST_STORE }}" \
tox -e "${{ matrix.environment }}" -- $TEST_WORKERS -k "$TEST_CATEGORY"
tox -e "${{ matrix.environment }}" -- $TEST_WORKERS -k "$TEST_CATEGORY" --error-on-skip-unless="no SELinux"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@achilleas-k suggested to use --ok-to-skip to avoid the double negative, I like it so unless someone has a better suggestion I would say let's go with that

achilleas-k pushed a commit to osbuild/containers that referenced this pull request Apr 25, 2024
With PR osbuild/osbuild#1756 we can now
see what packages are missing that cause test skips. Add them
here.
To ensure we do not skip tests in GH actions that we want to run
add a new explicit way to allowlist tests that are okay to skip.

This is done via a small pytest plugin and the GH action will
only set "no SELinux" initially.
Copy link
Member

@supakeen supakeen left a comment

Choose a reason for hiding this comment

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

This is starting to get really funky. Would it not be possible to remove skips we have and move SELinux tests into a separate module that is not selected on GitHub instead?

@mvo5
Copy link
Contributor Author

mvo5 commented Apr 29, 2024

This is starting to get really funky. Would it not be possible to remove skips we have and move SELinux tests into a separate module that is not selected on GitHub instead?

Maybe, something like this would work probably, it looks about the same to me, i have no strong opinion.

diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 0bd04444..6501bf3d 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -46,7 +46,7 @@ jobs:
               TEST_CATEGORY="not test_stages.py and not test_assemblers.py"
           fi
           OSBUILD_TEST_STORE="${{ env.OSBUILD_TEST_STORE }}" \
-          tox -e "${{ matrix.environment }}" -- $TEST_WORKERS -k "$TEST_CATEGORY" --error-on-skip --ok-to-skip="no SELinux"
+          tox -e "${{ matrix.environment }}" -- $TEST_WORKERS -k "$TEST_CATEGORY" --error-on-skip -k "not test_selinux"
 
   v1_manifests:
     name: "Assembler test (legacy)"
diff --git a/conftest.py b/conftest.py
index 83603aca..8530e56d 100644
--- a/conftest.py
+++ b/conftest.py
@@ -7,10 +7,9 @@ def pytest_runtest_makereport(item, call):
     res = outcome.get_result()
     if res.skipped:
         error_on_skip = item.config.getoption('--error-on-skip')
-        allowlist_skip = item.config.getoption('--ok-to-skip')
 
         reason = str(call.excinfo.value)
-        if error_on_skip and reason not in allowlist_skip:
+        if error_on_skip:
             res.outcome = "failed"
             res.longrepr = f"skipping not allowed: {res.longrepr}"
 
@@ -19,6 +18,3 @@ def pytest_addoption(parser):
     parser.addoption(
         '--error-on-skip', action="store_store",
     )
-    parser.addoption(
-        "--ok-to-skip", type=lambda arg: arg.split(","),
-    )

@supakeen
Copy link
Member

This is starting to get really funky. Would it not be possible to remove skips we have and move SELinux tests into a separate module that is not selected on GitHub instead?

Maybe, something like this would work probably, it looks about the same to me, i have no strong opinion.

diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 0bd04444..6501bf3d 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -46,7 +46,7 @@ jobs:
               TEST_CATEGORY="not test_stages.py and not test_assemblers.py"
           fi
           OSBUILD_TEST_STORE="${{ env.OSBUILD_TEST_STORE }}" \
-          tox -e "${{ matrix.environment }}" -- $TEST_WORKERS -k "$TEST_CATEGORY" --error-on-skip --ok-to-skip="no SELinux"
+          tox -e "${{ matrix.environment }}" -- $TEST_WORKERS -k "$TEST_CATEGORY" --error-on-skip -k "not test_selinux"
 
   v1_manifests:
     name: "Assembler test (legacy)"
diff --git a/conftest.py b/conftest.py
index 83603aca..8530e56d 100644
--- a/conftest.py
+++ b/conftest.py
@@ -7,10 +7,9 @@ def pytest_runtest_makereport(item, call):
     res = outcome.get_result()
     if res.skipped:
         error_on_skip = item.config.getoption('--error-on-skip')
-        allowlist_skip = item.config.getoption('--ok-to-skip')
 
         reason = str(call.excinfo.value)
-        if error_on_skip and reason not in allowlist_skip:
+        if error_on_skip:
             res.outcome = "failed"
             res.longrepr = f"skipping not allowed: {res.longrepr}"
 
@@ -19,6 +18,3 @@ def pytest_addoption(parser):
     parser.addoption(
         '--error-on-skip', action="store_store",
     )
-    parser.addoption(
-        "--ok-to-skip", type=lambda arg: arg.split(","),
-    )

I like this more!

@mvo5 mvo5 changed the title workflow,pytest: add new --error-on-skip-unless for pytest workflow,pytest: add new --error-on-skip for pytest Apr 29, 2024
Copy link

This PR is stale because it has been open 30 days with no activity. Remove "Stale" label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale label May 30, 2024
Copy link

github-actions bot commented Jun 7, 2024

This PR was closed because it has been stalled for 30+7 days with no activity.

@github-actions github-actions bot closed this Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants