-
Notifications
You must be signed in to change notification settings - Fork 0
115 lines (101 loc) · 3.79 KB
/
Copy pathtest.yml
File metadata and controls
115 lines (101 loc) · 3.79 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
name: Test
on:
push:
branches: [ main ]
tags-ignore: [ '**' ]
pull_request:
branches: [ main, master ]
workflow_call:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
jobs:
test:
runs-on: ubuntu-24.04
timeout-minutes: 30
steps:
- name: Checkout cmlxc
uses: actions/checkout@v6
with:
path: cmlxc
- name: Install Incus (Zabbly)
run: |
sudo mkdir -p /etc/apt/keyrings
sudo curl -fsSL https://pkgs.zabbly.com/key.asc -o /etc/apt/keyrings/zabbly.asc
echo "deb [signed-by=/etc/apt/keyrings/zabbly.asc] https://pkgs.zabbly.com/incus/stable $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/zabbly-incus.list
sudo apt-get update
sudo apt-get install -y incus-base
- name: Initialise Incus
run: |
# Stop docker to avoid iptables/nftables conflicts with Incus bridges
sudo systemctl stop docker.socket docker || true
sudo iptables -P FORWARD ACCEPT
sudo sysctl -w fs.inotify.max_user_instances=65535
sudo sysctl -w fs.inotify.max_user_watches=65535
sudo incus admin init --auto
# Allow runner to access Incus without 'sg' or 'sudo'
sudo chmod 666 /var/lib/incus/unix.socket
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.10"
- name: Install cmlxc
run: |
python -m pip install --upgrade pip
pip install -e ./cmlxc
pip install pytest ruff
- name: Cache Incus images
id: cache-images
uses: actions/cache@v5
with:
path: |
/tmp/incus-cache
key: incus-images-v7-${{ runner.os }}-${{ hashFiles('cmlxc/src/cmlxc/incus.py') }}
restore-keys: |
incus-images-v7-${{ runner.os }}-
- name: Import cached images
run: |
mkdir -p /tmp/incus-cache
for alias in localchat-base localchat-builder; do
if [ -f /tmp/incus-cache/$alias.tar.gz ]; then
echo "Importing cached image: $alias"
incus image import /tmp/incus-cache/$alias.tar.gz --alias $alias || true
fi
done
- name: Run linting
working-directory: cmlxc
run: ruff check src/ tests/
- name: Run unit tests
working-directory: cmlxc
run: pytest tests/test_incus.py tests/test_cli.py -v
- name: Run fullrun tests
working-directory: cmlxc
run: pytest tests/fullrun.py
- name: Export images for cache
if: always() && steps.cache-images.outputs.cache-hit != 'true'
run: |
mkdir -p /tmp/incus-cache
# Export the builder as a reusable image if it's running
if incus list -c n --format csv | grep -q builder-localchat; then
incus exec builder-localchat -- rm -rf /root/relays /root/minitest-venv /root/.ssh/config*
echo "Publishing builder container as image ..."
incus publish builder-localchat --alias localchat-builder --force || true
fi
for alias in localchat-base localchat-builder; do
if incus image list --format csv -c l | grep -q "^$alias$"; then
echo "Exporting image for cache: $alias"
incus image export $alias /tmp/incus-cache/$alias || true
# incus may append .tar.gz itself; ensure consistent name
if [ -f /tmp/incus-cache/$alias ] && [ ! -f /tmp/incus-cache/$alias.tar.gz ]; then
mv /tmp/incus-cache/$alias /tmp/incus-cache/$alias.tar.gz
fi
fi
done
- name: Show container logs on failure
if: failure()
run: |
for c in $(incus list -c n --format csv); do
echo "::group::Logs for $c"
incus exec "$c" -- journalctl -p warning --no-pager -n 100 || true
echo "::endgroup::"
done