Skip to content

ci: modernise

ci: modernise #224

Workflow file for this run

name: Build and test
on:
pull_request:
types: [opened, synchronize, reopened]
push:
branches:
- master
- develop
jobs:
build:
runs-on: ubuntu-latest
env:
RM_TS_DIR: "/tmp/rmlint-unit-testdir"
scons_ARGS: 'VERBOSE=1 DEBUG=1 O=release'
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- name: "Prepare build environment"
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
scons gettext python3-setuptools libblkid-dev \
libelf-dev libglib2.0-dev libjson-glib-dev \
python3-pip python3-cffi python3-dev libffi-dev \
py-cpuinfo
pip3 install -r tests/requirements.txt -r docs/requirements.txt
- name: "Build"
run: |
scons config $scons_ARGS
scons $scons_ARGS
- name: "Check need for testing"
# TODO: also include skipping build but allow docs to be processed
run: |
if git diff --exit-code --name-only origin/$GITHUB_BASE_REF...$GITHUB_SHA ':!.gitignore' ':!docs' ':!*.md' ':!*.txt' ':!*.rst'; then
echo "RUN_TEST=false" >> "$GITHUB_ENV"
echo "RUN_TEST = false"
else
echo "RUN_TEST=true" >> "$GITHUB_ENV"
echo "RUN_TEST = true"
fi
- name: "Prepare test environment"
if: ${{ env.RUN_TEST == 'true' }}
# 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 it"
if: ${{ env.RUN_TEST == 'true' }}
run: |
RM_TS_PRINT_CMD=0 RM_TS_PEDANTIC=0 python -m pytest -s -v
- name: CoW tests
if: ${{ env.RUN_TEST == 'true' }}
shell: bash
run: |
sudo umount "${RM_TS_DIR}"
sudo modprobe brd rd_nr=1 rd_size=12582912
sudo mkfs.btrfs -f /dev/ram0
sudo mount /dev/ram0 "${RM_TS_DIR}"
sudo chmod 0777 "${RM_TS_DIR}"
cat <<'EOF' >> tests/conftest.py
def pytest_collection_modifyitems(items, config):
selected_items = []
deselected_items = []
for item in items:
if "needs_reflink_fs" in getattr(item, "fixturenames", ()):
selected_items.append(item)
else:
deselected_items.append(item)
config.hook.pytest_deselected(items=deselected_items)
items[:] = selected_items
EOF
RM_TS_PRINT_CMD=0 RM_TS_PEDANTIC=0 python -m pytest -s -v
- name: "Cleanup"
if: ${{ env.RUN_TEST == 'true' }}
run: |
sudo umount "${RM_TS_DIR}"
sudo rmdir "${RM_TS_DIR}"