summaryrefslogtreecommitdiff
path: root/.github/workflows/ci.yml
blob: c07541bd0024c09ee4ea731ded99fd99363b0004 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
name: CI

on:
  push:
    branches: [master]
  pull_request:
    branches: [master]

jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: "3.12"
      - run: pip install ruff
      - run: ruff check .
      - run: ruff format --check .

  test:
    runs-on: ubuntu-latest
    services:
      redis:
        image: redis:7-alpine
        ports: [6379:6379]
        options: >-
          --health-cmd "redis-cli ping"
          --health-interval 5s
          --health-timeout 3s
          --health-retries 5
      postgres:
        image: postgres:16-alpine
        env:
          POSTGRES_USER: trading
          POSTGRES_PASSWORD: trading
          POSTGRES_DB: trading
        ports: [5432:5432]
        options: >-
          --health-cmd pg_isready
          --health-interval 5s
          --health-timeout 3s
          --health-retries 5
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: "3.12"
      - run: |
          pip install -e shared/[dev]
          pip install -e services/strategy-engine/[dev]
          pip install -e services/data-collector/[dev]
          pip install -e services/order-executor/[dev]
          pip install -e services/portfolio-manager/[dev]
          pip install -e services/news-collector/[dev]
          pip install -e services/api/[dev]
          pip install -e services/backtester/[dev]
          pip install pytest-cov
      - run: pytest -v --cov=shared/src --cov=services --cov-report=xml --cov-report=term-missing
        env:
          DATABASE_URL: postgresql+asyncpg://trading:trading@localhost:5432/trading
          REDIS_URL: redis://localhost:6379
      - uses: actions/upload-artifact@v4
        with:
          name: coverage-report
          path: coverage.xml

  docker:
    runs-on: ubuntu-latest
    needs: [lint, test]
    if: github.ref == 'refs/heads/master'
    steps:
      - uses: actions/checkout@v4
      - run: docker compose build --quiet