-
Notifications
You must be signed in to change notification settings - Fork 0
136 lines (112 loc) · 4.03 KB
/
Copy pathintegration-tests.yml
File metadata and controls
136 lines (112 loc) · 4.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# Integration tests workflow for VMSnap
# Runs integration tests with real KVM/libvirt infrastructure
name: Integration Tests
on:
push:
branches: [main, dev]
pull_request:
branches: [main, dev]
# Allow manual trigger
workflow_dispatch:
jobs:
integration-tests:
runs-on: ubuntu-latest
# Integration tests require KVM which may not be available in all runners
# This job may need to run on a self-hosted runner with KVM support
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Check KVM availability
id: kvm-check
run: |
if [ -e /dev/kvm ]; then
echo "kvm_available=true" >> $GITHUB_OUTPUT
echo "KVM is available"
else
echo "kvm_available=false" >> $GITHUB_OUTPUT
echo "KVM is NOT available - integration tests will be skipped"
fi
- name: Setup KVM/libvirt
if: steps.kvm-check.outputs.kvm_available == 'true'
run: |
sudo apt-get update
sudo apt-get install -y \
qemu-kvm \
libvirt-daemon-system \
libvirt-clients \
virtinst \
qemu-utils
# Start libvirtd
sudo systemctl start libvirtd
sudo systemctl enable libvirtd
# Add current user to libvirt group
sudo usermod -aG kvm,libvirt $USER
# Verify libvirt connection
sudo virsh version
- name: Install virtnbdbackup
if: steps.kvm-check.outputs.kvm_available == 'true'
run: |
# Install virtnbdbackup dependencies
sudo apt-get install -y \
python3-pip \
python3-libvirt \
python3-libnbd \
libnbd-bin \
nbdkit
# Install virtnbdbackup from GitHub (not available on PyPI)
# Use sudo since tests run as root, and --break-system-packages for Ubuntu 24.04+ PEP 668
sudo pip3 install --break-system-packages git+https://github.com/abbbi/virtnbdbackup.git
# Verify installation
echo "Checking virtnbdbackup installation..."
which virtnbdbackup && virtnbdbackup --version
sudo which virtnbdbackup && sudo virtnbdbackup --version
- name: Create test directory
if: steps.kvm-check.outputs.kvm_available == 'true'
run: |
sudo mkdir -p /tmp/vmsnap-integration-test
sudo chown -R $USER:$USER /tmp/vmsnap-integration-test
- name: Create test VMs
if: steps.kvm-check.outputs.kvm_available == 'true'
run: |
sudo bash test/integration/setup/create-test-vms.sh
- name: Run integration tests
if: steps.kvm-check.outputs.kvm_available == 'true'
run: |
# Run with sudo to access libvirt
sudo -E npm run test:integration
env:
CI: true
NODE_ENV: test
- name: Cleanup test environment
if: always() && steps.kvm-check.outputs.kvm_available == 'true'
run: |
sudo bash test/integration/setup/cleanup-test-env.sh --full || true
- name: Skip notice
if: steps.kvm-check.outputs.kvm_available != 'true'
run: |
echo "::warning::Integration tests were skipped because KVM is not available on this runner."
echo "To run integration tests, use a runner with KVM support (e.g., self-hosted runner with nested virtualization)."
# Unit tests run on all pushes
unit-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run unit tests
run: npm run test:unit
- name: Run linting
run: npm run lint