Skip to content

Move .github self-tests to native pytest #6

Description

@comps

Currently, at least the matrix-based jobs for executors handle image building and other things, and thus are very tied to Github specifically. It's hard to run the same logic locally.

This could be abstracted with pytest and its params:

  # tests/executor/conftest.py  (new or extended)

  IMAGES = {
      "centos7": "quay.io/centos/centos:centos7.9.2009",
      "cs8": "quay.io/centos/centos:stream8",
      "cs9": "quay.io/centos/centos:stream9",
      "cs10": "quay.io/centos/centos:stream10",
      "fedora": "registry.fedoraproject.org/fedora:latest",
  }

  @pytest.fixture(scope="session", params=IMAGES.keys())
  def base_image(request):
      return pull_image(IMAGES[request.param])

  Then each sub-conftest just receives base_image as an argument:

  # tests/executor/fmf/conftest.py
  @pytest.fixture(scope="session")
  def custom_image(base_image):
      image = build_container_with_deps(base_image)
      ...

  # tests/executor/beakerlib/conftest.py
  @pytest.fixture(scope="session")
  def custom_image(base_image):
      image = build_container_with_deps(
          base_image,
          extra_pkgs=("beakerlib", "git-core", "epel-release"),
          extra_content=(...),
      )
      ...

plus image customization (fixing repos to vault.centos.org) / building in base_image() or so.

This could be then run via pytest-xdist in parallel, or selectively via ie. pytest -k cs10 tests/executor.

That also applies to other Github checks - we could have yamllint config in the repo itself (instead of inlining its config), and possibly integrate other stylistic tests as pytests themselves, doing grep / flake8 / etc. either directly on the source, or in a container (for untrusted external tooling).

Basically - it should be possible for an unprivileged user on a laptop to execute all the testing against their local codebase, easily.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions