aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: bf0ea2ff5214776139b1cac4c389404c990118b4 (plain)
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
# Makefile for archangel ISO build and testing
#
# Usage:
#   make build          - Build the ISO
#   make lint           - Run shellcheck on all scripts
#   make bats           - Run bats unit tests (tests/unit/)
#   make test           - Run lint + bats
#   make test-install   - Run all automated install tests in VMs (slow)
#   make release        - Full test + build + deploy
#
# Manual VM testing:
#   make test-vm        - Boot ISO in a single-disk VM
#   make test-multi     - Boot ISO in a 2-disk VM (mirror/RAID)
#   make test-multi3    - Boot ISO in a 3-disk VM (raidz1)
#   make test-boot      - Boot from installed disk (after install)
#   make test-clean     - Remove VM disks and OVMF vars
#
#   make clean          - Clean build artifacts
#   make distclean      - Clean everything including releases
#
# Test configurations are in scripts/test-configs/

.PHONY: test test-install test-vm test-multi test-multi3 test-boot test-clean build release clean distclean lint bats

# Lint all bash scripts
lint:
	@echo "==> Running shellcheck..."
	@shellcheck -x build.sh scripts/*.sh installer/archangel installer/zfsrollback installer/zfssnapshot installer/lib/*.sh
	@echo "==> Shellcheck complete"

# Run bats unit tests
bats:
	@command -v bats >/dev/null 2>&1 || { echo "bats not installed. Install: sudo pacman -S bats (Arch), brew install bats-core (macOS), apt install bats (Debian/Ubuntu)"; exit 1; }
	@echo "==> Running bats unit tests..."
	@bats tests/unit/
	@echo "==> Bats tests complete"

# Build the ISO (requires sudo)
build:
	@echo "==> Building ISO..."
	sudo ./build.sh

# Integration tests (runs VMs, slow)
test-install: build
	@echo "==> Running install tests..."
	./scripts/test-install.sh

# All fast tests (lint + bats — VM integration tests via test-install)
test: lint bats

# Full release: test everything, build, deploy
release: test test-install
	@echo "==> Deploying ISO..."
	@# Move old ISOs to archive
	@mkdir -p archive
	@mv -f archangel-*.iso archive/ 2>/dev/null || true
	@# Copy new ISO to project root
	@cp out/archangel-*.iso .
	@echo "==> Release complete:"
	@ls -lh archangel-*.iso

# --- Manual VM testing ---

# Boot ISO in a single-disk VM
test-vm:
	./scripts/test-vm.sh

# Boot ISO in a 2-disk VM (for mirror/RAID testing)
test-multi:
	./scripts/test-vm.sh --multi-disk

# Boot ISO in a 3-disk VM (for raidz1 testing)
test-multi3:
	./scripts/test-vm.sh --multi-disk=3

# Boot from installed disk (after running install in VM)
test-boot:
	./scripts/test-vm.sh --boot-disk

# Remove VM disks and start fresh
test-clean:
	./scripts/test-vm.sh --clean

# --- Cleanup ---

# Clean build artifacts
clean:
	@echo "==> Cleaning..."
	sudo rm -rf work out profile
	rm -rf vm/*.qcow2
	@echo "==> Clean complete"

# Clean everything including releases
distclean: clean
	rm -rf archive
	rm -f archangel-*.iso