diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml new file mode 100644 index 000000000..7b8bd93c4 --- /dev/null +++ b/.github/workflows/build-and-test.yml @@ -0,0 +1,40 @@ +name: Build and test rmlint (master) + +on: + pull_request: + types: [opened, synchronize, reopened] + push: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + env: + RM_TS_DIR: "/tmp/rmlint-unit-testdir" + steps: + - uses: actions/checkout@v4 + - name: "Prepare build environment" + run: | + sudo apt update + sudo apt install -y --no-install-recommends \ + scons python3-sphinx gettext python3-setuptools \ + libblkid-dev libelf-dev libglib2.0-dev libjson-glib-dev \ + clang python3-pip python3-cffi python3-dev libffi-dev + pip3 install -r tests/requirements.txt + - name: "Build" + # Todo: eventually run tests with valgrind (RM_TS_USE_VALGRIND) + # Todo enable slow tests in pytest + run: | + scons config + scons VERBOSE=1 DEBUG=1 O=release + - name: "Prepare test environment" + # The test suite is seriously disk-intensive. Given that linux + # instances hosted in GitHub have 16G of RAM available we will + # use it to speed up the run. + run: | + sudo mkdir "${RM_TS_DIR}" + sudo mount -o size=12G,nr_inodes=0 -t tmpfs tmpfs "${RM_TS_DIR}" + - name: "Test" + run: | + RM_TS_PRINT_CMD=1 RM_TS_PEDANTIC=0 python -m pytest -s -v diff --git a/.gitignore b/.gitignore index d8e395528..5ac20b874 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,5 @@ gui/app/resources/app.gresource rmlint.*.sh rmlint.*.json +# JetBrains' IDE +.idea diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 1b11f23e9..000000000 --- a/.travis.yml +++ /dev/null @@ -1,24 +0,0 @@ -language: c - -install: - - sudo apt-get update - - sudo apt-get install scons python3-sphinx gettext python3-setuptools - - sudo apt-get install libblkid-dev libelf-dev libglib2.0-dev libjson-glib-dev - - sudo apt-get install clang python3-pip python3-cffi libffi-dev - - sudo pip3 install -r test-requirements.txt - -compiler: - - clang - - gcc - -notifications: - email: - - sahib@online.de - - thomas_d_j@yahoo.com.au - -script: - - scons VERBOSE=1 DEBUG=1 O=release - - scons config - - export RM_TS_PRINT_CMD=1 - - export RM_TS_PEDANTIC=0 - - sudo -E nosetests -s -v -a '!slow' diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 000000000..a900bc5b9 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,7 @@ +import pytest +from tests.utils import cleanup_testdir, create_testdir + +@pytest.fixture(autouse=True) +def with_cleanup_between_runs(): + cleanup_testdir() + create_testdir() diff --git a/test-requirements.txt b/tests/requirements.txt similarity index 81% rename from test-requirements.txt rename to tests/requirements.txt index 1882435d9..79ec53709 100644 --- a/test-requirements.txt +++ b/tests/requirements.txt @@ -1,4 +1,5 @@ nose==1.3.7 +pytest==8.3.4 parameterized==0.6.1 xattr==0.9.6 psutil==5.6.6 diff --git a/tests/utils.py b/tests/utils.py index 47ade03eb..55a165e63 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -79,6 +79,10 @@ def create_testdir(*extra_path): pass +def cleanup_testdir(): + shutil.rmtree(TESTDIR_NAME, ignore_errors=True) + + def which(program): def is_exe(fpath): return os.path.isfile(fpath) and os.access(fpath, os.X_OK)