]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
CI: use self-hosted runner to run tests
authorKinga Stefaniuk <kinga.stefaniuk@intel.com>
Tue, 12 Nov 2024 16:06:38 +0000 (17:06 +0100)
committerMariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Thu, 14 Nov 2024 07:56:28 +0000 (08:56 +0100)
Use prepared VM machine in GitHub actions to run mdadm tests on it.

Signed-off-by: Kinga Stefaniuk <kinga.stefaniuk@intel.com>
.github/tools/run_mdadm_tests.sh [new file with mode: 0755]
.github/workflows/tests.yml [new file with mode: 0644]

diff --git a/.github/tools/run_mdadm_tests.sh b/.github/tools/run_mdadm_tests.sh
new file mode 100755 (executable)
index 0000000..404fcc1
--- /dev/null
@@ -0,0 +1,10 @@
+#!/usr/bin/bash
+
+sudo make clean
+sudo make -j$(nproc)
+sudo make install
+sudo mdadm -Ss
+sudo ./test setup
+ret=$(sudo ./test --skip-broken --no-error --disable-integrity --disable-multipath --disable-linear --keep-going)
+sudo ./test cleanup
+exit $ret
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
new file mode 100644 (file)
index 0000000..8dc12fb
--- /dev/null
@@ -0,0 +1,58 @@
+name: tests
+on:
+  schedule:
+    - cron: "0 0 * * *"
+  pull_request:
+    paths:
+      - '*.c'
+      - '*.h'
+jobs:
+  upstream_tests:
+     if: ${{ github.repository == 'md-raid-utilities/mdadm' }}
+     runs-on: self-hosted
+     timeout-minutes: 150
+     name: upstream tests
+     steps:
+     - uses: actions/checkout@v4
+       if: ${{ github.event_name == 'pull_request' }}
+       with:
+        ref: ${{ github.event.pull_request.head.sha }}
+        fetch-depth: 0
+     - uses: actions/checkout@v4
+       if: ${{ github.event_name == 'schedule' }}
+       with:
+        ref: main
+        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"
+     - name: 'Copy logs to host machine'
+       run: |
+          cd ..
+          vagrant ssh -c "sudo mkdir -p /home/vagrant/host/logs && sudo mv /var/tmp/*.log /home/vagrant/host/logs"
+     - name: "Save artifacts"
+       uses: actions/upload-artifact@v4
+       with:
+         name: "Logs from failed tests"
+         path: /home/ci/actions-runner/_work/mdadm/logs/*.log
+     - name: "Clean logs"
+       run: |
+          cd ..
+          sudo rm /home/ci/actions-runner/_work/mdadm/logs/*.log
+  cleanup:
+    runs-on: self-hosted
+    needs: [upstream_tests]
+    steps:
+      - name: Restore clean VM
+        run:  |
+          cd ..
+          vagrant up
+          vagrant ssh -c "sudo mdadm -Ss"
+          vagrant halt