|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main ] |
| 6 | + pull_request: |
| 7 | + branches: [ main ] |
| 8 | + |
| 9 | +jobs: |
| 10 | + test: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + |
| 13 | + services: |
| 14 | + postgres: |
| 15 | + image: postgres:15 |
| 16 | + env: |
| 17 | + POSTGRES_DB: lucidata_test |
| 18 | + POSTGRES_USER: lucidata |
| 19 | + POSTGRES_PASSWORD: password |
| 20 | + ports: |
| 21 | + - 5432:5432 |
| 22 | + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 |
| 23 | + |
| 24 | + steps: |
| 25 | + - uses: actions/checkout@v3 |
| 26 | + |
| 27 | + # API tests |
| 28 | + - name: Set up Rust |
| 29 | + uses: actions-rs/toolchain@v1 |
| 30 | + with: |
| 31 | + toolchain: stable |
| 32 | + override: true |
| 33 | + components: rustfmt, clippy |
| 34 | + |
| 35 | + - name: Check formatting |
| 36 | + working-directory: ./api |
| 37 | + run: cargo fmt -- --check |
| 38 | + |
| 39 | + - name: Lint |
| 40 | + working-directory: ./api |
| 41 | + run: cargo clippy -- -D warnings |
| 42 | + |
| 43 | + - name: Test |
| 44 | + working-directory: ./api |
| 45 | + run: cargo test |
| 46 | + env: |
| 47 | + DATABASE_URL: postgres://lucidata:password@localhost:5432/lucidata_test |
| 48 | + |
| 49 | + # Frontend tests |
| 50 | + - name: Set up Node.js |
| 51 | + uses: actions/setup-node@v3 |
| 52 | + with: |
| 53 | + node-version: '18' |
| 54 | + |
| 55 | + - name: Install frontend dependencies |
| 56 | + working-directory: ./frontend |
| 57 | + run: npm ci |
| 58 | + |
| 59 | + - name: Lint frontend |
| 60 | + working-directory: ./frontend |
| 61 | + run: npm run lint |
| 62 | + |
| 63 | + - name: Test frontend |
| 64 | + working-directory: ./frontend |
| 65 | + run: npm test |
| 66 | + |
| 67 | + # Python services tests |
| 68 | + - name: Set up Python |
| 69 | + uses: actions/setup-python@v4 |
| 70 | + with: |
| 71 | + python-version: '3.10' |
| 72 | + |
| 73 | + - name: Install pytest |
| 74 | + run: pip install pytest |
| 75 | + |
| 76 | + - name: Test LLM Engine |
| 77 | + working-directory: ./llm_engine |
| 78 | + run: | |
| 79 | + pip install -r requirements.txt |
| 80 | + pytest |
| 81 | + |
| 82 | + - name: Test Query Runner |
| 83 | + working-directory: ./query_runner |
| 84 | + run: | |
| 85 | + pip install -r requirements.txt |
| 86 | + pytest |
| 87 | + |
| 88 | + - name: Test Response Formatter |
| 89 | + working-directory: ./response_formatter |
| 90 | + run: | |
| 91 | + pip install -r requirements.txt |
| 92 | + pytest |
| 93 | +
|
| 94 | + build: |
| 95 | + runs-on: ubuntu-latest |
| 96 | + needs: test |
| 97 | + |
| 98 | + steps: |
| 99 | + - uses: actions/checkout@v3 |
| 100 | + |
| 101 | + - name: Set up Docker Buildx |
| 102 | + uses: docker/setup-buildx-action@v2 |
| 103 | + |
| 104 | + - name: Build API |
| 105 | + uses: docker/build-push-action@v4 |
| 106 | + with: |
| 107 | + context: ./api |
| 108 | + push: false |
| 109 | + load: true |
| 110 | + tags: lucidata-api:latest |
| 111 | + |
| 112 | + - name: Build Frontend |
| 113 | + uses: docker/build-push-action@v4 |
| 114 | + with: |
| 115 | + context: ./frontend |
| 116 | + push: false |
| 117 | + load: true |
| 118 | + tags: lucidata-frontend:latest |
| 119 | + |
| 120 | + - name: Build LLM Engine |
| 121 | + uses: docker/build-push-action@v4 |
| 122 | + with: |
| 123 | + context: ./llm_engine |
| 124 | + push: false |
| 125 | + load: true |
| 126 | + tags: lucidata-llm:latest |
| 127 | + |
| 128 | + - name: Build Query Runner |
| 129 | + uses: docker/build-push-action@v4 |
| 130 | + with: |
| 131 | + context: ./query_runner |
| 132 | + push: false |
| 133 | + load: true |
| 134 | + tags: lucidata-query-runner:latest |
| 135 | + |
| 136 | + - name: Build Response Formatter |
| 137 | + uses: docker/build-push-action@v4 |
| 138 | + with: |
| 139 | + context: ./response_formatter |
| 140 | + push: false |
| 141 | + load: true |
| 142 | + tags: lucidata-response-formatter:latest |
0 commit comments