chore: initialize monorepo with project scaffolding, configs, and CI setup
This commit is contained in:
30
scripts/ci/run_python_tests.sh
Executable file
30
scripts/ci/run_python_tests.sh
Executable file
@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
# Uncomment for debugging
|
||||
# set -x
|
||||
|
||||
PROJECT_ROOT=$(cd "$(dirname "$0")/../.." && pwd)
|
||||
PKG_PATHS="${PROJECT_ROOT}/packages/py/aitbc-crypto/src:${PROJECT_ROOT}/packages/py/aitbc-sdk/src"
|
||||
|
||||
cd "${PROJECT_ROOT}"
|
||||
|
||||
if command -v poetry >/dev/null 2>&1; then
|
||||
RUNNER=(poetry run)
|
||||
else
|
||||
RUNNER=()
|
||||
fi
|
||||
|
||||
run_pytest() {
|
||||
local py_path=$1
|
||||
shift
|
||||
if [ ${#RUNNER[@]} -gt 0 ]; then
|
||||
PYTHONPATH="$py_path" "${RUNNER[@]}" python -m pytest "$@"
|
||||
else
|
||||
PYTHONPATH="$py_path" python -m pytest "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
run_pytest "${PROJECT_ROOT}/apps/coordinator-api/src:${PKG_PATHS}" apps/coordinator-api/tests -q
|
||||
run_pytest "${PKG_PATHS}" packages/py/aitbc-sdk/tests -q
|
||||
run_pytest "${PROJECT_ROOT}/apps/miner-node/src:${PKG_PATHS}" apps/miner-node/tests -q
|
||||
run_pytest "${PROJECT_ROOT}/apps/wallet-daemon/src:${PKG_PATHS}" apps/wallet-daemon/tests -q
|
||||
33
scripts/ops/install_miner_systemd.sh
Executable file
33
scripts/ops/install_miner_systemd.sh
Executable file
@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SERVICE_NAME="aitbc-miner"
|
||||
APP_DIR="/opt/aitbc/apps/miner-node"
|
||||
VENV_DIR="$APP_DIR/.venv"
|
||||
LOG_DIR="/var/log/aitbc"
|
||||
SYSTEMD_PATH="/etc/systemd/system/${SERVICE_NAME}.service"
|
||||
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
echo "This script must be run as root" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
install -d "$APP_DIR" "$LOG_DIR"
|
||||
install -d "/etc/aitbc"
|
||||
|
||||
if [[ ! -d "$VENV_DIR" ]]; then
|
||||
python3 -m venv "$VENV_DIR"
|
||||
fi
|
||||
source "$VENV_DIR/bin/activate"
|
||||
|
||||
pip install --upgrade pip
|
||||
pip install -r "$APP_DIR/requirements.txt" || true
|
||||
|
||||
deactivate
|
||||
|
||||
install -m 644 "$(pwd)/configs/systemd/${SERVICE_NAME}.service" "$SYSTEMD_PATH"
|
||||
|
||||
systemctl daemon-reload
|
||||
systemctl enable --now "$SERVICE_NAME"
|
||||
|
||||
echo "${SERVICE_NAME} systemd unit installed and started."
|
||||
Reference in New Issue
Block a user