-
Notifications
You must be signed in to change notification settings - Fork 0
140 lines (133 loc) · 6.18 KB
/
build.yaml
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
137
138
139
140
name: Build
on:
push:
branches-ignore:
- main
jobs:
restvirt:
name: Restvirt
runs-on: self-hosted
steps:
- name: Set up Python 3.10.6
id: python
uses: actions/setup-python@v4
with:
python-version: 3.10.6
- name: Check out code
uses: actions/checkout@v3
- name: Install dependencies
run: |
sudo apt update
sudo apt install -y libvirt-dev rebar3
pip install -r requirements.txt -r requirements-dev.txt
- name: Lint
run: |
black --check --diff --color ./
isort --check --diff --color ./
- name: Unit Tests
run: |
tmp_dir=$(mktemp -d)
chmod -R 0711 "${tmp_dir}"
sudo iptables -P FORWARD ACCEPT
sudo ${{ steps.python.outputs.python-path }} -m pytest tests/unit
- name: Build Snap
run: |
sudo snap install --classic snapcraft
sudo usermod --append --groups lxd $(whoami)
sudo lxd init --auto
snapcraft --use-lxd
- name: Setup Virtuerl
working-directory: virtuerl
run: |
sudo apt install -y g++
sudo rebar3 release
cat << EOF | sudo tee -a /etc/systemd/system/virtuerl.service
[Unit]
Description=Virtuerl
After=network.target
[Service]
Environment="SHELL=/bin/sh"
WorkingDirectory=${PWD}/_build/default/rel/virtuerl/
ExecStart=${PWD}/_build/default/rel/virtuerl/bin/virtuerl foreground
Restart=always
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl --now enable virtuerl
- name: Integration Tests
run: |
sudo snap install --dangerous minivirt*.snap
sudo snap connect minivirt:network-control
sudo snap connect minivirt:firewall-control
sudo snap connect minivirt:libvirt
cat << EOF | sudo tee -a /var/snap/minivirt/common/ca.crt
-----BEGIN CERTIFICATE-----
MIICCjCCAY+gAwIBAgIUSl7KWjtgvG9rNMz7hhYRKy5LsB8wCgYIKoZIzj0EAwIw
RDELMAkGA1UEBhMCREUxDzANBgNVBAgMBkJlcmxpbjERMA8GA1UECgwIbWluaXZp
cnQxETAPBgNVBAMMCG1pbml2aXJ0MB4XDTIzMDcwODIzMjUyMFoXDTMzMDcwNTIz
MjUyMFowRDELMAkGA1UEBhMCREUxDzANBgNVBAgMBkJlcmxpbjERMA8GA1UECgwI
bWluaXZpcnQxETAPBgNVBAMMCG1pbml2aXJ0MHYwEAYHKoZIzj0CAQYFK4EEACID
YgAEI3nOFzsWO3w8qGLSjDSiX3OWCH7qBRcTjt/luPjXLqe3DVcFQPLYN31PaggR
o0jCjrKklxqtzHmmMdMRnyoRPbQOQPRa9N177a2s97M5ZJQVkeFL8WRUf7x1P0Cd
SZvco0IwQDAdBgNVHQ4EFgQUde9ormRTZys4Nt81qAPcSm1qQWMwDwYDVR0TAQH/
BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAYYwCgYIKoZIzj0EAwIDaQAwZgIxAJTpUOUz
RJwMLNUEa4qIgdamMuqyl5h6ghT9zX5BLsX3cFs+MqJ/J0HcKDJd81lVlQIxAPCG
hy/zgj6wy28S8GWe8KdbZ73BJtC5MyOu6hHD9EpZ1hT8K3q0VIwMEyUMmbv3Xw==
-----END CERTIFICATE-----
EOF
cat << EOF | sudo tee -a /var/snap/minivirt/common/server.crt
-----BEGIN CERTIFICATE-----
MIICeTCCAf+gAwIBAgIUVG1gWhFwRQ5kzxwRzF6V5h6D8ZYwCgYIKoZIzj0EAwIw
RDELMAkGA1UEBhMCREUxDzANBgNVBAgMBkJlcmxpbjERMA8GA1UECgwIbWluaXZp
cnQxETAPBgNVBAMMCG1pbml2aXJ0MB4XDTIzMDcwODIzMzA0MloXDTI1MDcwNzIz
MzA0MlowRDELMAkGA1UEBhMCREUxDzANBgNVBAgMBkJlcmxpbjERMA8GA1UECgwI
bWluaXZpcnQxETAPBgNVBAMMCG1pbml2aXJ0MHYwEAYHKoZIzj0CAQYFK4EEACID
YgAEHWV9eL3/egpqcgTaMDPWga2xpfTZCc66yNxkVGPsw5BWE/EXvWtuUCjDmHWo
HOdrbt7iI9lA9VnSwlC9PeIvX4lK2dXNOpn3GJlZ8JkjpZZBg0mxaUt6vQMyGSco
cOOAo4GxMIGuMB8GA1UdIwQYMBaAFHXvaK5kU2crODbfNagD3EptakFjMAwGA1Ud
EwEB/wQCMAAwDgYDVR0PAQH/BAQDAgWgMCAGA1UdJQEB/wQWMBQGCCsGAQUFBwMB
BggrBgEFBQcDAjAsBgNVHREEJTAjgglsb2NhbGhvc3SHBH8AAAGHEAAAAAAAAAAA
AAAAAAAAAAEwHQYDVR0OBBYEFDtlzMapZ4eV0/m8ina1GM3biELeMAoGCCqGSM49
BAMCA2gAMGUCMECXLmHsWMTaFRK+qWaBRZMLuhFNixMsSmmHHIqGlvIrWFa5MiN6
RaZ7aTGa/HMKZAIxAPRJZ11Vp1BNBszSiswk32hsck4JP9h1hn00IMu33iK0+q22
Jv73oZy3l4gQmLlCDg==
-----END CERTIFICATE-----
EOF
cat << EOF | sudo tee -a /var/snap/minivirt/common/server.key
-----BEGIN PRIVATE KEY-----
MIG2AgEAMBAGByqGSM49AgEGBSuBBAAiBIGeMIGbAgEBBDCIJQuTNENeEnhjCtdV
GXoFgh69LQ+Ms5B/i0jWMSqMALL26uG6NNM4nvHgIMbChKGhZANiAAQdZX14vf96
CmpyBNowM9aBrbGl9NkJzrrI3GRUY+zDkFYT8Re9a25QKMOYdagc52tu3uIj2UD1
WdLCUL094i9fiUrZ1c06mfcYmVnwmSOllkGDSbFpS3q9AzIZJyhw44A=
-----END PRIVATE KEY-----
EOF
sudo snap set minivirt controller.args='--debug -b :8093 -c $SNAP_COMMON --server-cert $SNAP_COMMON/server.crt --server-key $SNAP_COMMON/server.key --client-ca-cert $SNAP_COMMON/ca.crt'
sudo snap start --enable minivirt.unbound
sudo snap start --enable minivirt.controller
sleep 5
sudo minivirt.register -a 127.0.0.1:8093 --name default -b 127.0.0.1:8099 --client-cert /var/snap/minivirt/common/server.crt --client-key /var/snap/minivirt/common/server.key --server-ca-cert /var/snap/minivirt/common/ca.crt
sudo snap set minivirt daemon.args='--debug -a 127.0.0.1:8093 -b 127.0.0.1:8099 -c $SNAP_COMMON --client-cert $SNAP_COMMON/server.crt --client-key $SNAP_COMMON/server.key --server-ca-cert $SNAP_COMMON/ca.crt'
sudo snap start --enable minivirt.daemon
sleep 10
if ! sudo ${{ steps.python.outputs.python-path }} -m pytest tests/integration ; then
sudo journalctl
exit 1
fi
# sleep 5
# snap services minivirt
# sudo journalctl -e
# sudo apt install -y net-tools
# sudo netstat -tulpen
# sudo ${{ steps.python.outputs.python-path }} -m pytest tests/integration
# sudo journalctl -e
# sudo netstat -tulpen
# - name: Build
# run: |
# docker build --target test -t restvirt-tests .
# docker build -t restvirt .
# - name: Test
# run: |
# tmp_dir=$(mktemp -d)
# chmod -R 0711 "${tmp_dir}"
# iptables -P FORWARD ACCEPT
# docker run --rm --cap-add=NET_ADMIN --network host -t -v /var/run/libvirt:/var/run/libvirt -v "${tmp_dir}":/data/restvirt/images restvirt-tests --pool-dir "${tmp_dir}"