Skip to content

Commit

Permalink
CI: use self-hosted runner to run tests
Browse files Browse the repository at this point in the history
Use prepared VM machine in GitHub actions to run mdadm tests on it.

Signed-off-by: Kinga Stefaniuk <[email protected]>
  • Loading branch information
ktanska committed Oct 8, 2024
1 parent a06b956 commit 53d20e5
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 3 deletions.
9 changes: 9 additions & 0 deletions .github/tools/run_mdadm_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/bash

sudo make clean
sudo make -j$(nproc)
sudo make install
sudo mdadm -Ss
sudo ./test setup
sudo ./test --skip-broken --no-error --disable-integrity --disable-multipath --disable-linear --keep-going
sudo ./test cleanup
41 changes: 41 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: review
on:
pull_request:
paths:
- '*.c'
- '*.h'
jobs:
upstream_tests:
if: ${{ github.repository == 'md-raid-utilities/mdadm' }}
runs-on: self-hosted
timeout-minutes: 90
name: upstream tests
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: 'Prepare machine'
run: |
cd ..
vagrant halt
vagrant status
vagrant up
- name: 'Run tests'
run: |
cd ..
vagrant ssh -c "cd /home/vagrant/host/mdadm && .github/tools/run_mdadm_tests.sh"
- uses: actions/download-artifact@v4
with:
name: /var/tmp/*.log
cleanup:
runs-on: self-hosted
steps:
- name: Restore clean VM
run: |
cd ..
vagrant halt
- name: Stop md devices
run: sudo mdadm -Ss
- name: Clean logs
run: rm -rf /var/tmp/*.log
2 changes: 1 addition & 1 deletion Detail.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ int Detail(char *dev, struct context *c)
array.major_version,
array.minor_version);
}

//test
if (info && memcmp(info->uuid, uuid_zero, sizeof(int[4])) != 0)
mp = map_by_uuid(&map, info->uuid);
if (!mp)
Expand Down
7 changes: 7 additions & 0 deletions test
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ do_test() {

if [ -f "$_script" ]
then
if [ "${_basename:0:2}" == "$skip_prefix" ]; then
return
fi
if [ -f "${_script}.broken" ]; then
_broken=1
_broken_msg=$(head -n1 "${_script}.broken" | tr -d '\n')
Expand Down Expand Up @@ -162,6 +165,7 @@ do_help() {
--loop=N Run tests N times (0 to run forever)
--skip-broken Skip tests that are known to be broken
--skip-always-broken Skip tests that are known to always fail
--skip=prefix Skip group of tests starting with <prefix>

Check failure on line 168 in test

View workflow job for this annotation

GitHub Actions / checkpatch review

WARNING:EMBEDDED_FILENAME: It's generally not useful to have the filename in the file
--dev=loop|lvm|ram|disk Use loop devices (default), LVM, RAM or disk
--disks= Provide a bunch of physical devices for test
--volgroup=name LVM volume group for LVM test
Expand Down Expand Up @@ -265,6 +269,9 @@ parse_args() {
--skip-always-broken )
skipbroken=always
;;
--skip=* )
skip_prefix="${i##*=}"
;;
--disable-multipath )
unset MULTIPATH
;;
Expand Down
1 change: 1 addition & 0 deletions tests/07layouts.broken
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
always fails
1 change: 1 addition & 0 deletions tests/14imsm-r5_3d-migrate-r4_3d.broken
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
always fails
2 changes: 0 additions & 2 deletions util.c
Original file line number Diff line number Diff line change
Expand Up @@ -1159,8 +1159,6 @@ int open_dev_excl(char *devnm)
flags = O_RDONLY;
continue;
}
if (errno != EBUSY)
return fd;
sleep_for(0, MSEC_TO_NSEC(delay), true);
if (delay < 200)
delay *= 2;
Expand Down

0 comments on commit 53d20e5

Please sign in to comment.