diff --git a/.gitlab-ci/build/gitlab-ci.yml b/.gitlab-ci/build/gitlab-ci.yml index f4948b3c16a..267de17adc5 100644 --- a/.gitlab-ci/build/gitlab-ci.yml +++ b/.gitlab-ci/build/gitlab-ci.yml @@ -212,9 +212,6 @@ debian-testing-msan: LLVM_VERSION: 15 S3_ARTIFACT_NAME: debian-build-testing script: | - section_start lava-pytest "lava-pytest" - .gitlab-ci/lava/lava-pytest.sh - section_end lava-pytest .gitlab-ci/meson/build.sh .gitlab-ci/prepare-artifacts.sh timeout: 15m diff --git a/.gitlab-ci/container/debian/x86_64_build.sh b/.gitlab-ci/container/debian/x86_64_build.sh index cc3491a4fae..2bac23b5a87 100644 --- a/.gitlab-ci/container/debian/x86_64_build.sh +++ b/.gitlab-ci/container/debian/x86_64_build.sh @@ -83,7 +83,7 @@ rm -rf $XORGMACROS_VERSION . .gitlab-ci/container/build-bindgen.sh -python3 -m pip install --break-system-packages -r .gitlab-ci/lava/requirements.txt +python3 -m pip install --break-system-packages -r bin/ci/requirements.txt ############### Uninstall the build software diff --git a/.gitlab-ci/image-tags.yml b/.gitlab-ci/image-tags.yml index b430b9c655e..64f6f19714a 100644 --- a/.gitlab-ci/image-tags.yml +++ b/.gitlab-ci/image-tags.yml @@ -16,7 +16,7 @@ variables: DEBIAN_BASE_TAG: "20240729-rustc-bump" DEBIAN_X86_64_BUILD_IMAGE_PATH: "debian/x86_64_build" - DEBIAN_BUILD_TAG: "20240909-filelock" + DEBIAN_BUILD_TAG: "20240909-pytest" DEBIAN_X86_64_TEST_BASE_IMAGE: "debian/x86_64_test-base" DEBIAN_ARM64_TEST_BASE_IMAGE: "debian/arm64_test-base" @@ -30,7 +30,7 @@ variables: DEBIAN_TEST_ANDROID_TAG: "20240906-deqp" DEBIAN_TEST_GL_TAG: "20240906-deqp" DEBIAN_TEST_VK_TAG: "20240906-deqp" - KERNEL_ROOTFS_TAG: "20240906-deqp" + KERNEL_ROOTFS_TAG: "20240909-pytest" ALPINE_X86_64_BUILD_TAG: "20240814-var" ALPINE_X86_64_LAVA_SSH_TAG: "20240401-wlproto" diff --git a/.gitlab-ci/lava/lava-pytest.sh b/.gitlab-ci/lava/lava-pytest.sh deleted file mode 100755 index 64e056e1414..00000000000 --- a/.gitlab-ci/lava/lava-pytest.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env bash -# SPDX-License-Identifier: MIT -# © Collabora Limited -# Author: Guilherme Gallo - -# This script runs unit/integration tests related with LAVA CI tools -# shellcheck disable=SC1091 # The relative paths in this file only become valid at runtime. -# shellcheck disable=SC2086 # quoting PYTEST_VERBOSE makes us pass an empty path - -set -exu - -if [ -z "${CI_PROJECT_DIR:-}" ]; then - CI_PROJECT_DIR="$(dirname "${0}")/../../" -fi - -if [ -z "${LAVA_PYTEST_VENV:-}" ]; then - LAVA_PYTEST_VENV="${CI_PROJECT_DIR}/.gitlab-ci/lava/.venv-pytest" -fi - -# Use this script in a python virtualenv for isolation -python3 -m venv "${LAVA_PYTEST_VENV}" -. "${LAVA_PYTEST_VENV}"/bin/activate -python3 -m pip install --break-system-packages -r "${CI_PROJECT_DIR}/.gitlab-ci/lava/requirements-test.txt" - -TEST_DIR=${CI_PROJECT_DIR}/.gitlab-ci/tests - -PYTHONPATH="${TEST_DIR}:${PYTHONPATH}" python3 -m \ - pytest "${TEST_DIR}" \ - -W ignore::DeprecationWarning \ - --junitxml=artifacts/ci_scripts_report.xml \ - -m 'not slow' \ - ${PYTEST_VERBOSE:-} diff --git a/.gitlab-ci/lava/requirements-test.txt b/.gitlab-ci/lava/requirements-test.txt deleted file mode 100644 index 0ff561db901..00000000000 --- a/.gitlab-ci/lava/requirements-test.txt +++ /dev/null @@ -1,6 +0,0 @@ --r requirements.txt -freezegun==1.1.0 -hypothesis==6.67.1 -pytest==7.2.1 -pytest-cov==3.0.0 -PyYAML==5.3.1 diff --git a/.gitlab-ci/lava/requirements.txt b/.gitlab-ci/lava/requirements.txt deleted file mode 100644 index e89021f3fd5..00000000000 --- a/.gitlab-ci/lava/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -lavacli==1.5.2 -fire==0.5.0 diff --git a/.gitlab-ci/run-pytest.sh b/.gitlab-ci/run-pytest.sh new file mode 100755 index 00000000000..a83a67ca098 --- /dev/null +++ b/.gitlab-ci/run-pytest.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: MIT +# © Collabora Limited +# Author: Guilherme Gallo + +# This script runs unit/integration tests related with LAVA CI tools +# shellcheck disable=SC1091 # The relative paths in this file only become valid at runtime. +# shellcheck disable=SC2086 # quoting PYTEST_VERBOSE makes us pass an empty path + +. "${SCRIPTS_DIR}/setup-test-env.sh" + +section_start pytest_setup "Setting up pytest environment" + +set -exu + +if [ -z "${CI_PROJECT_DIR:-}" ]; then + CI_PROJECT_DIR="$(dirname "${0}")/../" +fi + +if [ -z "${MESA_PYTEST_VENV:-}" ]; then + MESA_PYTEST_VENV="${CI_PROJECT_DIR}/.venv-pytest" +fi + +# Use this script in a python virtualenv for isolation +python3 -m venv "${MESA_PYTEST_VENV}" +. "${MESA_PYTEST_VENV}"/bin/activate + +python3 -m pip install --break-system-packages -r "${CI_PROJECT_DIR}/bin/ci/requirements.txt" +python3 -m pip install --break-system-packages -r "${CI_PROJECT_DIR}/bin/ci/test/requirements.txt" + +LIB_TEST_DIR=${CI_PROJECT_DIR}/.gitlab-ci/tests +SCRIPT_TEST_DIR=${CI_PROJECT_DIR}/bin/ci + +uncollapsed_section_switch pytest "Running pytest" + +PYTHONPATH="${LIB_TEST_DIR}:${SCRIPT_TEST_DIR}:${PYTHONPATH}" python3 -m \ + pytest "${LIB_TEST_DIR}" "${SCRIPT_TEST_DIR}" \ + -W ignore::DeprecationWarning \ + --junitxml=artifacts/ci_scripts_report.xml \ + -m 'not slow' \ + ${PYTEST_VERBOSE:-} + +section_end pytest diff --git a/.gitlab-ci/test/gitlab-ci.yml b/.gitlab-ci/test/gitlab-ci.yml index e2d6ca8986b..ed17e04c315 100644 --- a/.gitlab-ci/test/gitlab-ci.yml +++ b/.gitlab-ci/test/gitlab-ci.yml @@ -52,9 +52,7 @@ python-test: GIT_STRATEGY: fetch timeout: 10m script: - - cd bin/ci - - pip install --break-system-packages -r test/requirements.txt - - PYTHONPATH=. pytest -v + - .gitlab-ci/run-pytest.sh rules: - !reference [.disable-farm-mr-rules, rules] - !reference [.never-post-merge-rules, rules] diff --git a/bin/ci/requirements.txt b/bin/ci/requirements.txt index 44875ed6a30..81be9147bd4 100644 --- a/bin/ci/requirements.txt +++ b/bin/ci/requirements.txt @@ -1,13 +1,15 @@ +PyYAML==6.* colorama==0.4.* filecache==0.81 filelock==3.* +fire==0.5.0 gql==3.* kaleido==0.2.* -python-dateutil==2.* +lavacli==1.5.2 pandas==2.* plotly==5.* +python-dateutil==2.* python-gitlab==4.* -PyYAML==6.* ruamel.yaml.clib==0.2.* ruamel.yaml==0.17.* tabulate==0.9.* diff --git a/bin/ci/test/requirements.txt b/bin/ci/test/requirements.txt index f80621af285..fc6358b498b 100644 --- a/bin/ci/test/requirements.txt +++ b/bin/ci/test/requirements.txt @@ -1,5 +1,8 @@ filelock==3.12.4 fire==0.5.0 +freezegun==1.1.0 +hypothesis==6.67.1 mock==5.1.0 polars==0.19.3 pytest==7.4.2 +pytest-cov==3.0.0