Alice — an open-source AI trading bot covering equities, crypto, commodities, forex, and macro
| 1 | name: CI |
| 2 | |
| 3 | on: |
| 4 | push: |
| 5 | branches: [main, master] |
| 6 | pull_request: |
| 7 | branches: [main, master] |
| 8 | |
| 9 | jobs: |
| 10 | lint-and-test: |
| 11 | runs-on: ubuntu-latest |
| 12 | strategy: |
| 13 | matrix: |
| 14 | python-version: ["3.11", "3.12"] |
| 15 | |
| 16 | steps: |
| 17 | - uses: actions/checkout@v4 |
| 18 | |
| 19 | - name: Set up Python ${{ matrix.python-version }} |
| 20 | uses: actions/setup-python@v5 |
| 21 | with: |
| 22 | python-version: ${{ matrix.python-version }} |
| 23 | |
| 24 | - name: Install dependencies |
| 25 | run: | |
| 26 | python -m pip install --upgrade pip |
| 27 | pip install -e ".[dev,web]" |
| 28 | |
| 29 | - name: Lint with ruff |
| 30 | run: ruff check src tests |
| 31 | |
| 32 | - name: Type check with mypy |
| 33 | run: mypy src |
| 34 | |
| 35 | - name: Test with pytest |
| 36 | run: pytest tests/ -v --tb=short --color=yes |
| 37 | |
| 38 | - name: Upload coverage |
| 39 | if: matrix.python-version == '3.12' |
| 40 | uses: actions/upload-artifact@v4 |
| 41 | with: |
| 42 | name: coverage-report |
| 43 | path: htmlcov/ |
| 44 | |
| 45 | demo-container: |
| 46 | runs-on: ubuntu-latest |
| 47 | steps: |
| 48 | - uses: actions/checkout@v4 |
| 49 | - name: Build existing CLI/test image |
| 50 | run: docker build -t alice-cli . |
| 51 | - name: Test existing image (override alice entrypoint) |
| 52 | run: docker run --rm --entrypoint pytest alice-cli tests/ -q |
| 53 | - name: Build broker-free demo image |
| 54 | run: docker build -f Dockerfile.demo -t alice-demo . |
| 55 | - name: Start and smoke-test demo container |
| 56 | shell: bash |
| 57 | run: | |
| 58 | set -euo pipefail |
| 59 | docker run -d --name alice-demo -p 127.0.0.1:8080:8080 alice-demo |
| 60 | trap 'docker logs alice-demo; docker rm -f alice-demo' EXIT |
| 61 | for i in {1..30}; do |
| 62 | if curl -fsS http://127.0.0.1:8080/ > /tmp/dashboard.html; then break; fi |
| 63 | sleep 1 |
| 64 | done |
| 65 | grep -q 'Alice Trading Dashboard' /tmp/dashboard.html |
| 66 | curl -fsS http://127.0.0.1:8080/api/account | python -c 'import json,sys; d=json.load(sys.stdin); assert d["connected"] is False and "no saved login" in d["error"]' |
| 67 | status=$(curl -sS -o /tmp/live.json -w '%{http_code}' -H 'Content-Type: application/json' -d '{"symbol":"EURUSD","side":"buy","volume":0.01,"live":true}' http://127.0.0.1:8080/api/order) |
| 68 | test "$status" = 403 |
| 69 | python -c 'import json; d=json.load(open("/tmp/live.json")); assert d["ok"] is False and "Demo mode" in d["message"]' |
| 70 | curl -fsS -H 'Content-Type: application/json' -d '{"symbol":"EURUSD","side":"buy","volume":0.01,"live":false}' http://127.0.0.1:8080/api/order | python -c 'import json,sys; d=json.load(sys.stdin); assert d["ok"] is True and "DRY RUN" in d["message"]' |
| 71 | docker exec alice-demo python -c 'import os; from open_alice.broker import load_credentials; assert os.getenv("ALICE_DEMO") == "1"; assert os.geteuid() != 0; assert load_credentials() is None' |