Skip to content

feat: add CI testing workflow and Docker test suite #7

feat: add CI testing workflow and Docker test suite

feat: add CI testing workflow and Docker test suite #7

Workflow file for this run

name: CI
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build and Run Tests
env:
# Use secret if available, otherwise will be generated in run step
MTPROXY_SECRET: ${{ secrets.MTPROXY_SECRET }}
# Optional: Only set if secrets are provided (empty means skip telethon test)
TELEGRAM_API_ID: ${{ secrets.TELEGRAM_API_ID }}
TELEGRAM_API_HASH: ${{ secrets.TELEGRAM_API_HASH }}
run: |
if [ -z "$MTPROXY_SECRET" ]; then
export MTPROXY_SECRET=$(head -c 16 /dev/urandom | xxd -ps)
echo "Generated random MTPROXY_SECRET for testing"
fi
# Run tests passing env vars
make test
test-direct:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential libssl-dev zlib1g-dev git curl vim-common python3 python3-pip python3-venv netcat-openbsd
python3 -m venv .venv
source .venv/bin/activate
pip install requests telethon python-dotenv python-socks[asyncio]
- name: Build MTProxy
run: |
make clean && make -j$(nproc)
- name: Setup and Run Proxy
run: |
# Debug: Check connectivity to Telegram DC
echo "Checking connectivity to Telegram DC (149.154.175.50:443)..."
nc -zv 149.154.175.50 443 || echo "Failed to connect to Telegram DC 149.154.175.50:443"
mkdir -p mtproxy-run
cp objs/bin/mtproto-proxy mtproxy-run/
cd mtproxy-run
# Download config/secret
curl -s https://core.telegram.org/getProxySecret -o proxy-secret
curl -s https://core.telegram.org/getProxyConfig -o proxy-multi.conf
# Generate a random secret for testing using xxd (from vim-common)
SECRET=$(head -c 16 /dev/urandom | xxd -ps)
echo "Using secret: $SECRET"
# Start proxy in background
# Use port 8443 instead of 443 to avoid permission issues or conflicts on the runner
./mtproto-proxy -u nobody -p 8888 -H 8443 -S $SECRET --http-stats --aes-pwd proxy-secret proxy-multi.conf -M 1 -v -v &
# Export SECRET for the test step
echo "MTPROXY_SECRET=$SECRET" >> $GITHUB_ENV
# Wait for it to start
sleep 5
- name: Run Python Tests
env:
# Session path null for CI
TEST_SESSION_PATH: /dev/null
TELEGRAM_API_ID: ${{ secrets.TELEGRAM_API_ID }}
TELEGRAM_API_HASH: ${{ secrets.TELEGRAM_API_HASH }}
run: |
source .venv/bin/activate
# We need to tell the test script to connect to localhost since we are not in docker-compose
export MTPROXY_HOST=localhost
export MTPROXY_PORT=8443
python3 tests/test_proxy.py