-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding an easy way for testing mqtt2kasa for pull requests. Mostly based on what is currently done in Vagrantfile Signed-off-by: Flavio Fernandes <flavio-fernandes@users.noreply.github.com>
- Loading branch information
1 parent
0f8bf3a
commit c7362b4
Showing
1 changed file
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
name: Test mqtt2kasa | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
inputs: | ||
branch_or_commit: | ||
description: 'Branch or commit to run the workflow on' | ||
required: true | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
env: | ||
VM_MEMORY: 512 | ||
VM_CPUS: 2 | ||
|
||
steps: | ||
- name: Check out the repo | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha || github.event.inputs.branch_or_commit }} | ||
|
||
- name: Set up environment | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y software-properties-common | ||
sudo add-apt-repository -y ppa:deadsnakes/ppa | ||
sudo apt-get install -y python3.10 python3.10-venv | ||
sudo ln -sf /usr/bin/python3.10 /usr/bin/python3 | ||
- name: Install Mosquitto | ||
run: | | ||
sudo apt-get install -y mosquitto mosquitto-clients | ||
echo "allow_anonymous true\nbind_address 192.168.123.123" | sudo tee /etc/mosquitto/conf.d/localbroker.conf | ||
sudo systemctl enable --now mosquitto | ||
sudo systemctl status --full --no-pager mosquitto | ||
- name: Install mqtt2kasa | ||
run: | | ||
rm -rf env | ||
./mqtt2kasa/bin/create-env.sh | ||
source env/bin/activate | ||
pip install --upgrade pip | ||
echo '[ -e env/bin/activate ] && source env/bin/activate' >> ~/.bashrc | ||
ln -s data/config.yaml.vagrant ~/mqtt2kasa.config.yaml | ||
sudo cp -v mqtt2kasa/bin/mqtt2kasa.service.vagrant /lib/systemd/system/mqtt2kasa.service | ||
sudo systemctl enable --now mqtt2kasa.service | ||
ln -s mqtt2kasa/bin/tail_log.sh ~/ | ||
ln -s mqtt2kasa/bin/reload_config.sh ~/ | ||
ln -s mqtt2kasa/tests/basic_test.sh.vagrant ~/basic_test.sh | ||
- name: Install and Run tplink-smarthome-simulator | ||
run: | | ||
if [ ! -d "tplink-smarthome-simulator" ]; then | ||
sudo apt-get install -y nodejs npm git | ||
git clone https://github.com/flavio-fernandes/tplink-smarthome-simulator.git | ||
cd tplink-smarthome-simulator | ||
npm install | ||
for x in {201..204}; do | ||
sudo ip a add 192.168.123.${x}/32 dev eth0 | ||
done | ||
sudo cp -v ../mqtt2kasa/tests/simulator.js.vagrant ./test/simulator.js | ||
sudo cp -v ../mqtt2kasa/tests/tplink-smarthome-simulator.service.vagrant /lib/systemd/system/tplink-smarthome-simulator.service | ||
fi | ||
- name: Start tplink-smarthome-simulator | ||
run: | | ||
sudo systemctl enable --now tplink-smarthome-simulator.service ||: | ||
sudo systemctl status --full --no-pager tplink-smarthome-simulator.service | ||
sudo journalctl -xeu tplink-smarthome-simulator.service | ||
- name: Run Tests | ||
run: | | ||
sudo systemctl status --full --no-pager mqtt2kasa | ||
sudo journalctl -xeu mqtt2kasa.service | ||
sleep 5 | ||
~/basic_test.sh |