Skip to content

Commit

Permalink
Add klipper-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
reemo3dp committed Feb 29, 2024
1 parent e30d977 commit 3d750e3
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 8 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,13 @@ jobs:
run: poetry install
- name: Run tests
working-directory: ./packages/led_effect_tests
run: poetry run pytest -s -v
run: poetry run pytest -s -v

klipper-test:
name: Test klipper installation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Execute Klipper Test
working-directory: ./packages/klipper_tests
run: ./run.sh
14 changes: 7 additions & 7 deletions install-led_effect.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ check_folders()
link_extension()
{
echo -n "Linking extension to Klipper... "
ln -sf "${SRCDIR}/packages/led_effect" "${KLIPPER_PATH}/klippy/extras/led_effect"
ln -sf "${SRCDIR}/packages/led_effect/src/" "${KLIPPER_PATH}/klippy/extras/led_effect"
echo "[OK]"
}

Expand Down Expand Up @@ -131,15 +131,15 @@ verify_ready()
}

# Run steps
verify_ready
check_klipper
check_folders
stop_klipper
#verify_ready
#check_klipper
#check_folders
#stop_klipper
if [ ! $UNINSTALL ]; then
link_extension
add_updater
# add_updater
else
uninstall
fi
start_klipper
#start_klipper

30 changes: 30 additions & 0 deletions packages/klipper_tests/config/printer.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[mcu]
serial: /opt/printer_data/run/klipper_host_mcu.tty

[printer]
kinematics: none
max_velocity: 300
max_accel: 3000

[gcode_macro]

[led_effect sb_logo_busy]
autostart: false
frame_rate: 24
leds:
layers:
breathing 3 1 top (1,0,0)

[led_effect sb_logo_cleaning]
autostart: false
frame_rate: 24
leds:
layers:
breathing 3 1 top (0.0, 0.02, 0.5)

[led_effect sb_logo_calibrating_z]
autostart: false
frame_rate: 24
leds:
layers:
breathing 3 1 top (0.0, 0.0, 0.35)
43 changes: 43 additions & 0 deletions packages/klipper_tests/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
services:
klipper:
image: mkuf/klipper:latest
privileged: true
entrypoint:
- tail
- -f
- /dev/null
volumes:
- /dev:/dev
- ../../:/app
- ./config:/opt/printer_data/config
- log:/opt/printer_data/logs
- run:/opt/printer_data/run
hostmcu:
image: mkuf/klipper:latest-hostmcu
privileged: true
volumes:
- /dev:/dev
- run:/opt/printer_data/run
log:
image: busybox
volumes:
- log:/opt/printer_data/logs
- run:/opt/printer_data/run
entrypoint:
- /bin/sh
- -c
- |
while true; do
tail -f /opt/printer_data/logs/klippy.log || true;
sleep 1;
done
volumes:
run:
driver_opts:
type: tmpfs
device: tmpfs
log:
driver_opts:
type: tmpfs
device: tmpfs
31 changes: 31 additions & 0 deletions packages/klipper_tests/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

set -euxo pipefail

trap destroy EXIT

destroy() {
docker-compose down -t0 || true
}

run() {
docker-compose up -d
docker-compose exec -T klipper bash -c '
cd /app
./install-led_effect.sh -k /opt/klipper/
cd /opt
/opt/venv/bin/python klipper/klippy/klippy.py \
-v \
-I printer_data/run/klipper.tty \
-a printer_data/run/klipper.sock \
printer_data/config/printer.cfg \
-l printer_data/logs/klippy.log
' &
sleep 5
set +e
! docker-compose logs log 2>&1 | tee /dev/stderr | grep -q "Config error"
}



run
7 changes: 7 additions & 0 deletions packages/led_effect/src/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from . import led_effect

def load_config(config):
return led_effect.load_config(config)

def load_config_prefix(config):
return led_effect.load_config_prefix(config)
1 change: 1 addition & 0 deletions packages/led_effect/src/src

0 comments on commit 3d750e3

Please sign in to comment.