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

Add CI with GitHub Actions #675

Merged
merged 12 commits into from
Dec 9, 2024
40 changes: 40 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@ gui/app/resources/app.gresource
rmlint.*.sh
rmlint.*.json

# JetBrains' IDE
.idea
24 changes: 0 additions & 24 deletions .travis.yml

This file was deleted.

7 changes: 7 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -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()
1 change: 1 addition & 0 deletions test-requirements.txt → tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
nose==1.3.7
pytest==8.3.4
parameterized==0.6.1
xattr==0.9.6
psutil==5.6.6
4 changes: 4 additions & 0 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading