@@ -19,39 +19,24 @@ jobs:
1919 python-version : ' 3.11'
2020 cache : ' pip'
2121
22- - name : Cache shellcheck
23- id : cache-shellcheck
24- uses : actions/cache@v4
25- with :
26- path : /snap/bin/shellcheck
27- key : ${{ runner.os }}-shellcheck-v1
28-
2922 - name : Install dependencies
30- env :
31- DEBIAN_FRONTEND : noninteractive
3223 run : |
33- sudo apt update -y
3424 python -m pip install --upgrade pip
3525 pip install -r requirements.txt
36- if [ "${{ steps.cache-shellcheck.outputs.cache-hit }}" != "true" ]; then
37- sudo snap install shellcheck
38- fi
3926 pip install ansible-lint
27+ # Install shellcheck from apt (faster than snap)
28+ sudo apt-get update && sudo apt-get install -y shellcheck
4029
41- - name : Checks and linters
30+ - name : Run linters
4231 run : |
43- /snap/bin/ shellcheck algo install.sh
32+ shellcheck algo install.sh
4433 ansible-playbook main.yml --syntax-check
4534 ansible-lint -x experimental,package-latest,unnamed-task -v *.yml roles/{local,cloud-*}/*/*.yml || true
4635
47- scripted-deploy :
48- runs-on : ubuntu-24.04
49- timeout-minutes : 30
36+ basic-tests :
37+ runs-on : ubuntu-22.04
5038 permissions :
5139 contents : read
52- strategy :
53- matrix :
54- UBUNTU_VERSION : ["22.04"]
5540 steps :
5641 - uses : actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
5742 with :
@@ -62,91 +47,36 @@ jobs:
6247 cache : ' pip'
6348
6449 - name : Install dependencies
65- env :
66- DEBIAN_FRONTEND : noninteractive
6750 run : |
68- sudo apt update -y
69- sudo apt install -y \
70- wireguard \
71- libxml2-utils \
72- crudini \
73- fping \
74- strongswan \
75- libstrongswan-standard-plugins
76-
77- python3 -m pip install --upgrade pip
78- python3 -m pip install -r requirements.txt
51+ python -m pip install --upgrade pip
52+ pip install -r requirements.txt
53+ sudo apt-get update && sudo apt-get install -y shellcheck
7954
80- # Install LXD on Ubuntu 24.04 (not pre-installed)
81- sudo snap install lxd
82-
83- # Fix Docker/LXD iptables conflict on Ubuntu 22.04+
84- # Docker doesn't work well with nftables, switch to iptables-legacy
85- sudo update-alternatives --set iptables /usr/sbin/iptables-legacy
86- sudo update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy
87-
88- # Initialize LXD
89- sudo lxd init --auto
90-
91- # Enable IP forwarding for container networking
92- sudo sysctl -w net.ipv4.ip_forward=1
93- sudo sysctl -w net.ipv6.conf.all.forwarding=1
55+ - name : Run basic sanity tests
56+ run : python tests/unit/test_basic_sanity.py
9457
95- - name : Provision
96- env :
97- DEPLOY : cloud-init
98- UBUNTU_VERSION : ${{ matrix.UBUNTU_VERSION }}
99- REPOSITORY : ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name || github.repository }}
100- BRANCH : ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || github.ref }}
101- run : |
102- ssh-keygen -f ~/.ssh/id_rsa -t rsa -N ''
103- # sed -i "s/^reduce_mtu:\s0$/reduce_mtu: 80/" config.cfg
104- sudo -E ./tests/pre-deploy.sh
58+ docker-build :
59+ runs-on : ubuntu-22.04
60+ permissions :
61+ contents : read
62+ steps :
63+ - uses : actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
64+ with :
65+ persist-credentials : false
10566
106- - name : Deployment
107- run : |
108- set -x
109- until sudo lxc exec algo -- test -f /var/log/cloud-init-output.log; do echo 'Log file not found, Sleep for 3 seconds'; sleep 3; done
110- ( sudo lxc exec algo -- tail -f /var/log/cloud-init-output.log & )
111- until sudo lxc exec algo -- test -f /var/lib/cloud/data/result.json; do
112- echo 'Cloud init is not finished. Sleep for 30 seconds';
113- sleep 30;
114- done
115- sudo lxc exec algo -- cat /var/log/cloud-init-output.log
116- sudo lxc exec algo -- test -f /opt/algo/configs/10.0.8.100/.config.yml
117- sudo lxc exec algo -- tar zcf /root/algo-configs.tar -C /opt/algo/configs/ .
118- sudo lxc file pull algo/root/algo-configs.tar ./
119- sudo tar -C ./configs -zxf algo-configs.tar
67+ - name : Build Docker image
68+ run : docker build -t local/algo:test .
12069
121- - name : Tests
70+ - name : Test Docker image starts
12271 run : |
123- set -x
124- # Run tests in parallel
125- sudo -E bash -x ./tests/wireguard-client.sh &
126- WG_PID=$!
127- sudo env "PATH=$PATH" ./tests/ipsec-client.sh &
128- IPSEC_PID=$!
129-
130- # Wait for all tests to complete
131- wait $WG_PID
132- WG_EXIT=$?
133- wait $IPSEC_PID
134- IPSEC_EXIT=$?
135-
136- # Check if any test failed
137- if [ $WG_EXIT -ne 0 ] || [ $IPSEC_EXIT -ne 0 ]; then
138- echo "One or more tests failed"
139- exit 1
140- fi
72+ # Just verify the image can start and show help
73+ docker run --rm local/algo:test /algo/algo --help
14174
142- docker-deploy :
143- runs-on : ubuntu-24 .04
144- timeout-minutes : 30
75+ config-generation :
76+ runs-on : ubuntu-22 .04
77+ timeout-minutes : 10
14578 permissions :
14679 contents : read
147- strategy :
148- matrix :
149- UBUNTU_VERSION : ["22.04"]
15080 steps :
15181 - uses : actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
15282 with :
@@ -157,78 +87,12 @@ jobs:
15787 cache : ' pip'
15888
15989 - name : Install dependencies
160- env :
161- DEBIAN_FRONTEND : noninteractive
162- run : |
163- set -x
164- sudo apt update -y
165- sudo apt install -y \
166- wireguard \
167- libxml2-utils \
168- crudini \
169- fping \
170- strongswan \
171- libstrongswan-standard-plugins
172-
173- python3 -m pip install --upgrade pip
174- python3 -m pip install -r requirements.txt
175-
176- # Install LXD on Ubuntu 24.04 (not pre-installed)
177- sudo snap install lxd
178-
179- # Fix Docker/LXD iptables conflict on Ubuntu 22.04+
180- # Docker doesn't work well with nftables, switch to iptables-legacy
181- sudo update-alternatives --set iptables /usr/sbin/iptables-legacy
182- sudo update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy
183-
184- # Initialize LXD
185- sudo lxd init --auto
186-
187- # Enable IP forwarding for container networking
188- sudo sysctl -w net.ipv4.ip_forward=1
189- sudo sysctl -w net.ipv6.conf.all.forwarding=1
190-
191- - name : Provision
192- env :
193- DEPLOY : docker
194- UBUNTU_VERSION : ${{ matrix.UBUNTU_VERSION }}
195- REPOSITORY : ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name || github.repository }}
196- BRANCH : ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || github.ref }}
197- run : |
198- ssh-keygen -f ~/.ssh/id_rsa -t rsa -N ''
199- sed -i "s/^reduce_mtu:\s0$/reduce_mtu: 80/" config.cfg
200- sudo -E ./tests/pre-deploy.sh
201-
202- - name : Deployment
203- env :
204- DEPLOY : docker
205- UBUNTU_VERSION : ${{ matrix.UBUNTU_VERSION }}
20690 run : |
207- docker build -t local/algo .
208- ./tests/local-deploy.sh
209- ./tests/update-users.sh
91+ python -m pip install --upgrade pip
92+ pip install -r requirements.txt
21093
211- - name : Tests
94+ - name : Test configuration generation (local mode)
21295 run : |
213- set -x
214- # Run tests in parallel
215- sudo bash -x ./tests/wireguard-client.sh &
216- WG_PID=$!
217- sudo env "PATH=$PATH" bash -x ./tests/ipsec-client.sh &
218- IPSEC_PID=$!
219- sudo bash -x ./tests/ssh-tunnel.sh &
220- SSH_PID=$!
221-
222- # Wait for all tests to complete
223- wait $WG_PID
224- WG_EXIT=$?
225- wait $IPSEC_PID
226- IPSEC_EXIT=$?
227- wait $SSH_PID
228- SSH_EXIT=$?
229-
230- # Check if any test failed
231- if [ $WG_EXIT -ne 0 ] || [ $IPSEC_EXIT -ne 0 ] || [ $SSH_EXIT -ne 0 ]; then
232- echo "One or more tests failed"
233- exit 1
234- fi
96+ # Run our simplified config test
97+ chmod +x tests/test-local-config.sh
98+ ./tests/test-local-config.sh
0 commit comments