|
| 1 | +# E2E integration tests with Lightspeed Core |
| 2 | +name: E2E Lightspeed Evaluation Integration Tests |
| 3 | + |
| 4 | +on: [push, pull_request] |
| 5 | + |
| 6 | +jobs: |
| 7 | + ########## |
| 8 | + e2e_tests: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + |
| 11 | + #name: "Lightspeed-stack setup" |
| 12 | + |
| 13 | + strategy: |
| 14 | + # For local testing use matrix with just one variant, "act" doesn't separate runs |
| 15 | + matrix: |
| 16 | + mode: ["query", "streaming"] |
| 17 | + eval-data: ["tests/integration/test_evaluation_data.yaml"] |
| 18 | + lsc_image_path: ["quay.io/lightspeed-core/lightspeed-stack:latest"] |
| 19 | + |
| 20 | + name: "E2E Lightspeed Evaluation Test, mode: ${{ matrix.mode }}" |
| 21 | + |
| 22 | + env: |
| 23 | + LSC_IMAGE_NAME: "lightspeed-stack-test-mode-${{ matrix.mode }}" |
| 24 | + |
| 25 | + steps: |
| 26 | + # Stolen from lightspeed-stack |
| 27 | + - uses: actions/checkout@v4 |
| 28 | + with: |
| 29 | + # On PR_TARGET → the fork (or same repo) that opened the PR. |
| 30 | + # On push → falls back to the current repository. |
| 31 | + repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }} |
| 32 | + |
| 33 | + # On PR_TARGET → the PR head *commit* (reproducible). |
| 34 | + # On push → the pushed commit that triggered the workflow. |
| 35 | + ref: ${{ github.event.pull_request.head.ref || github.sha }} |
| 36 | + |
| 37 | + # Don’t keep credentials when running untrusted PR code under PR_TARGET. |
| 38 | + persist-credentials: ${{ github.event_name != 'pull_request_target' }} |
| 39 | + |
| 40 | + - name: Verify actual git checkout result |
| 41 | + run: | |
| 42 | + echo "=== Git Status After Checkout ===" |
| 43 | + echo "Remote URLs:" |
| 44 | + git remote -v |
| 45 | + echo "" |
| 46 | + echo "Current branch: $(git branch --show-current 2>/dev/null || echo 'detached HEAD')" |
| 47 | + echo "Current commit: $(git rev-parse HEAD)" |
| 48 | + echo "Current commit message: $(git log -1 --oneline)" |
| 49 | + echo "" |
| 50 | + echo "=== Recent commits ===" |
| 51 | + git log --oneline -5 |
| 52 | +
|
| 53 | + # Run LSC |
| 54 | + # Can't be in onetime separate job -- networking is not shared between jobs |
| 55 | + - name: Run Lightspeed Stack (LSC) |
| 56 | + env: |
| 57 | + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} |
| 58 | + run: | |
| 59 | + echo "==========Running Lightspeed Core=======" |
| 60 | + docker run \ |
| 61 | + --name $LSC_IMAGE_NAME \ |
| 62 | + -p 8080:8080 \ |
| 63 | + -v $(pwd)/tests/integration/lightspeed-stack.yaml:/app-root/lightspeed-stack.yaml:Z \ |
| 64 | + -v $(pwd)/tests/integration/run.yaml:/app-root/run.yaml:Z \ |
| 65 | + -e OPENAI_API_KEY="${OPENAI_API_KEY}" \ |
| 66 | + --detach \ |
| 67 | + ${{ matrix.lsc_image_path }} |
| 68 | + echo "==========Running Lightspeed Core Done=======" |
| 69 | +
|
| 70 | + - name: Show logs from the LSC |
| 71 | + run: | |
| 72 | + sleep 2 |
| 73 | + docker container ls -a |
| 74 | + docker logs $LSC_IMAGE_NAME |
| 75 | +
|
| 76 | + # Wait for LSC |
| 77 | + - name: Wait for the LSC |
| 78 | + run: | |
| 79 | + echo "Waiting for service on port 8080..." |
| 80 | + for i in {1..30}; do |
| 81 | + if curl --output /dev/null --fail http://localhost:8080/v1/models ; then |
| 82 | + echo "Service is up!" |
| 83 | + exit 0 |
| 84 | + fi |
| 85 | + docker logs -n 10 $LSC_IMAGE_NAME |
| 86 | + echo "Still waiting..." |
| 87 | + sleep 2 |
| 88 | + done |
| 89 | +
|
| 90 | + echo "Service did not start in time" |
| 91 | + exit 1 |
| 92 | +
|
| 93 | + # Query mode |
| 94 | + - name: Set query mode |
| 95 | + if: matrix.mode == 'query' |
| 96 | + run: | |
| 97 | + echo "CONFIG=./tests/integration/system-config-query.yaml" >> $GITHUB_ENV |
| 98 | +
|
| 99 | + - name: Set streaming mode |
| 100 | + if: matrix.mode == 'streaming' |
| 101 | + run: | |
| 102 | + echo "CONFIG=./tests/integration/system-config-streaming.yaml" >> $GITHUB_ENV |
| 103 | +
|
| 104 | + # Dependencies |
| 105 | + - name: Install dependencies for Lightspeed Evaluation |
| 106 | + env: |
| 107 | + TERM: xterm-256color |
| 108 | + FORCE_COLOR: 1 |
| 109 | + run: | |
| 110 | + echo "Installing e2e tests dependencies" |
| 111 | + pip install --break-system-packages uv |
| 112 | + uv sync |
| 113 | + |
| 114 | + # Run the tests |
| 115 | + - name: Run the tests |
| 116 | + env: |
| 117 | + TERM: xterm-256color |
| 118 | + FORCE_COLOR: 1 |
| 119 | + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} |
| 120 | + run: | |
| 121 | + echo "=============================" |
| 122 | + echo "Running..." |
| 123 | + echo " config: ${CONFIG}" |
| 124 | + echo " LSC image: ${{ matrix.lsc_image_path }}" |
| 125 | + echo "=============================" |
| 126 | + uv run lightspeed-eval --system-config "${CONFIG}" --eval-data "${{ matrix.eval-data }}" |
| 127 | + |
| 128 | + # Check the result |
| 129 | + - name: Check test result |
| 130 | + run: | |
| 131 | + OUT_FILES=( eval_output/evaluation_*_summary.json ) |
| 132 | + if [ ${#OUT_FILES[@]} != 1 ] ; then |
| 133 | + echo "Multiple output files: " eval_output/evaluation_*_summary.json |
| 134 | + exit 1 |
| 135 | + fi |
| 136 | + OUT_FILE=${OUT_FILES[0]} |
| 137 | + PASS=$( jq .summary_stats.overall.PASS $OUT_FILE ) |
| 138 | + EXPECTED="1" |
| 139 | + if [ ${PASS} != ${EXPECTED} ] ; then |
| 140 | + echo "============" |
| 141 | + echo "Wrong PASS number in ${OUT_FILE}: got ${PASS}, expected ${EXPECTED}" |
| 142 | + echo "============" |
| 143 | + exit 1 |
| 144 | + fi |
| 145 | +
|
| 146 | +
|
| 147 | + # Cleanup |
| 148 | + - name: Stop the LSC if in local devel |
| 149 | + if: ${{ always() && env.ACT }} |
| 150 | + run: | |
| 151 | + echo "Stopping LSC container $LSC_IMAGE_NAME" |
| 152 | + echo "++++++++++++++++++++++" |
| 153 | + docker stop $LSC_IMAGE_NAME || true |
| 154 | + docker rm $LSC_IMAGE_NAME || true |
0 commit comments