fix: test script
This commit is contained in:
parent
3725ca1a02
commit
149934b730
2 changed files with 28 additions and 18 deletions
|
|
@ -4,18 +4,29 @@ on:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
jobs:
|
jobs:
|
||||||
|
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Tests auf Infomaniak VM
|
||||||
uses: actions/checkout@v4
|
env:
|
||||||
|
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||||
- name: Dependencies installieren
|
run: |
|
||||||
run: pip3 install -r requirements.txt --no-cache-dir
|
mkdir -p ~/.ssh
|
||||||
|
echo "$SSH_PRIVATE_KEY" > ~/.ssh/deploy_key
|
||||||
- name: Tests ausführen
|
chmod 600 ~/.ssh/deploy_key
|
||||||
run: pytest tests/ -v
|
echo "StrictHostKeyChecking=no" >> ~/.ssh/config
|
||||||
|
echo "UserKnownHostsFile=/dev/null" >> ~/.ssh/config
|
||||||
|
ssh -i ~/.ssh/deploy_key ubuntu@api.poweron.swiss "
|
||||||
|
set -e
|
||||||
|
cd /srv/gateway/current
|
||||||
|
git remote set-url origin ssh://git@git.poweron.swiss:2222/PowerOn/plattform-core.git
|
||||||
|
git pull
|
||||||
|
cp env-gateway-prod-forgejo.env .env
|
||||||
|
rm -f env-*.env
|
||||||
|
source .venv/bin/activate
|
||||||
|
pip install -r requirements.txt --no-cache-dir
|
||||||
|
python -m pytest tests/ -v
|
||||||
|
"
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
@ -31,12 +42,13 @@ jobs:
|
||||||
echo "StrictHostKeyChecking=no" >> ~/.ssh/config
|
echo "StrictHostKeyChecking=no" >> ~/.ssh/config
|
||||||
echo "UserKnownHostsFile=/dev/null" >> ~/.ssh/config
|
echo "UserKnownHostsFile=/dev/null" >> ~/.ssh/config
|
||||||
ssh -i ~/.ssh/deploy_key ubuntu@api.poweron.swiss "
|
ssh -i ~/.ssh/deploy_key ubuntu@api.poweron.swiss "
|
||||||
cd /srv/gateway/current &&
|
set -e
|
||||||
git remote set-url origin ssh://git@git.poweron.swiss:2222/PowerOn/plattform-core.git &&
|
cd /srv/gateway/current
|
||||||
git pull &&
|
git remote set-url origin ssh://git@git.poweron.swiss:2222/PowerOn/plattform-core.git
|
||||||
cp env-gateway-prod-forgejo.env .env &&
|
git pull
|
||||||
rm -f env-*.env &&
|
cp env-gateway-prod-forgejo.env .env
|
||||||
source .venv/bin/activate &&
|
rm -f env-*.env
|
||||||
pip install -r requirements.txt --no-cache-dir &&
|
source .venv/bin/activate
|
||||||
|
pip install -r requirements.txt --no-cache-dir
|
||||||
sudo systemctl restart gateway
|
sudo systemctl restart gateway
|
||||||
"
|
"
|
||||||
|
|
@ -6,11 +6,9 @@ Ensures proper Python path setup for importing modules.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
# Add gateway directory to Python path
|
# Add gateway directory to Python path
|
||||||
gateway_dir = Path(__file__).parent.parent
|
gateway_dir = Path(__file__).parent.parent
|
||||||
if str(gateway_dir) not in sys.path:
|
if str(gateway_dir) not in sys.path:
|
||||||
sys.path.insert(0, str(gateway_dir))
|
sys.path.insert(0, str(gateway_dir))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue