Skip to content

Commit 23372bd

Browse files
committed
add test frameworks
1 parent 43af7da commit 23372bd

File tree

12 files changed

+1101
-194
lines changed

12 files changed

+1101
-194
lines changed

.github/workflows/test.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ jobs:
2828
echo "Checking lib/storage.sh..."
2929
bash -n lib/storage.sh
3030
31+
- name: Prepare test config
32+
run: |
33+
# Use test config for validation
34+
cp tests/fixtures/config.local.test config.local
35+
3136
- name: Run ShellCheck
3237
run: |
3338
echo "ShellCheck srv-ctl.sh..."

.github/workflows/vm-tests.yml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: VM Integration Tests
2+
3+
on:
4+
push:
5+
branches: [ main, develop, v2-refactor ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
workflow_dispatch: # Manual trigger
9+
schedule:
10+
- cron: '0 2 * * 0' # Weekly on Sunday at 2 AM
11+
12+
jobs:
13+
# Fast Docker tests run first (gate for VM tests)
14+
docker-tests:
15+
name: Docker Tests (Quick Gate)
16+
runs-on: ubuntu-22.04
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Run Docker Tests
21+
run: ./tests/docker/run-docker-tests.sh
22+
23+
# Full VM tests with multiple OS versions (run in parallel)
24+
vm-tests:
25+
name: VM Tests - ${{ matrix.os }}
26+
needs: docker-tests # Only run if Docker tests pass
27+
runs-on: ubuntu-latest
28+
strategy:
29+
fail-fast: false # Continue testing other OSes even if one fails
30+
matrix:
31+
os:
32+
- ubuntu-22.04
33+
- ubuntu-24.04
34+
- debian-11
35+
- debian-12
36+
37+
steps:
38+
- uses: actions/checkout@v4
39+
40+
- name: Set up QEMU
41+
uses: docker/setup-qemu-action@v3
42+
43+
- name: Install VM dependencies
44+
run: |
45+
sudo apt-get update
46+
sudo apt-get install -y qemu-system-x86 qemu-utils cloud-image-utils
47+
48+
- name: Cache VM images
49+
uses: actions/cache@v3
50+
with:
51+
path: ~/.cache/vm-images
52+
key: vm-images-${{ matrix.os }}-${{ hashFiles('tests/vm/Vagrantfile') }}
53+
54+
- name: Download cloud image
55+
run: |
56+
mkdir -p ~/.cache/vm-images
57+
./tests/vm/download-image.sh ${{ matrix.os }}
58+
59+
- name: Run VM tests
60+
timeout-minutes: 15
61+
run: |
62+
./tests/vm/run-vm-tests.sh ${{ matrix.os }}
63+
64+
- name: Upload test results
65+
if: always()
66+
uses: actions/upload-artifact@v3
67+
with:
68+
name: vm-test-results-${{ matrix.os }}
69+
path: tests/vm/results/
70+
71+
- name: Cleanup
72+
if: always()
73+
run: ./tests/vm/cleanup.sh
74+
75+
# Summary job
76+
test-summary:
77+
name: Test Summary
78+
needs: [docker-tests, vm-tests]
79+
if: always()
80+
runs-on: ubuntu-latest
81+
steps:
82+
- name: Check test results
83+
run: |
84+
echo "Docker Tests: ${{ needs.docker-tests.result }}"
85+
echo "VM Tests: ${{ needs.vm-tests.result }}"
86+
87+
if [ "${{ needs.docker-tests.result }}" != "success" ]; then
88+
echo "❌ Docker tests failed"
89+
exit 1
90+
fi
91+
92+
if [ "${{ needs.vm-tests.result }}" != "success" ]; then
93+
echo "⚠️ Some VM tests failed (check matrix)"
94+
exit 1
95+
fi
96+
97+
echo "✅ All tests passed!"

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,37 @@ If you have an existing `config.local` from an earlier version, you'll need to u
9191
- Enhanced validation and error handling
9292

9393
Use `./srv-ctl.sh validate-config` to check your configuration after updating.
94+
95+
## Development & Testing
96+
97+
The project includes comprehensive tests with Docker and VM-based testing:
98+
99+
```bash
100+
# Run local tests (no root required)
101+
./tests/run-tests.sh
102+
103+
# Run tests in Docker (isolated, safe)
104+
./tests/docker/run-docker-tests.sh
105+
106+
# Run full VM tests (CI only, multi-OS)
107+
./tests/vm/run-vm-tests.sh ubuntu-22.04
108+
```
109+
110+
See [`tests/README.md`](tests/README.md) for detailed testing documentation.
111+
112+
## Project Structure
113+
114+
```
115+
srv-ctl/
116+
├── srv-ctl.sh # Main script
117+
├── lib/
118+
│ ├── os-utils.sh # OS-level utilities
119+
│ └── storage.sh # Storage operations
120+
├── config.local.template # Configuration template
121+
└── tests/ # Test suite
122+
```
123+
124+
## License
125+
126+
See repository for license information.
127+

0 commit comments

Comments
 (0)