|
| 1 | +# This workflow builds a Docker artifact, caches it based on the Dockerfile content, |
| 2 | +# and then runs e2e tests using that artifact. |
| 3 | + |
| 4 | +name: E2E Tests |
| 5 | + |
| 6 | +on: |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + pull_request: |
| 11 | + branches: |
| 12 | + - main |
| 13 | + workflow_dispatch: |
| 14 | + |
| 15 | +jobs: |
| 16 | + build-and-test: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + |
| 19 | + steps: |
| 20 | + - name: Check out repository |
| 21 | + uses: actions/checkout@v4 |
| 22 | + |
| 23 | + # Cache the binary artifact |
| 24 | + # The key is based on the runner's OS and the hash of the Dockerfile. |
| 25 | + # If the Dockerfile changes, the hash changes, and a new cache is created. |
| 26 | + - name: Cache vLLM-sim binary |
| 27 | + id: cache-vllm-sim |
| 28 | + uses: actions/cache@v4 |
| 29 | + with: |
| 30 | + # The path to the file you want to cache |
| 31 | + path: bin/llm-d-inference-sim |
| 32 | + # The unique key for the cache |
| 33 | + key: vllm-sim-binary-${{ runner.os }}-${{ hashFiles('tests/e2e/vllm-sim.Dockerfile') }} |
| 34 | + |
| 35 | + # Set up Docker Buildx (required for the 'docker build -o' command) |
| 36 | + - name: Set up Docker Buildx |
| 37 | + uses: docker/setup-buildx-action@v3 |
| 38 | + |
| 39 | + # Conditionally build the artifact |
| 40 | + # This step only runs if the cache step above did NOT find a match. |
| 41 | + # 'steps.cache-vllm-sim.outputs.cache-hit' will be 'true' if the cache was restored. |
| 42 | + - name: Build vLLM-sim artifact (if not cached) |
| 43 | + if: steps.cache-vllm-sim.outputs.cache-hit != 'true' |
| 44 | + run: | |
| 45 | + echo "Cache miss. Building artifact..." |
| 46 | + docker build . -f tests/e2e/vllm-sim.Dockerfile -o type=local,dest=./ |
| 47 | + shell: bash |
| 48 | + |
| 49 | + - name: Verify artifact |
| 50 | + run: | |
| 51 | + if [ -f "bin/llm-d-inference-sim" ]; then |
| 52 | + echo "Artifact found." |
| 53 | + else |
| 54 | + echo "ERROR: Artifact bin/llm-d-inference-sim not found!" |
| 55 | + exit 1 |
| 56 | + fi |
| 57 | + shell: bash |
| 58 | + |
| 59 | + - name: Set up Python |
| 60 | + uses: actions/setup-python@v5 |
| 61 | + with: |
| 62 | + python-version: ${{ matrix.python }} |
| 63 | + - name: Install dependencies |
| 64 | + run: | |
| 65 | + curl -sSL https://pdm-project.org/install-pdm.py | python3 - |
| 66 | + pip install tox tox-pdm |
| 67 | + - name: Run E2E tests |
| 68 | + run: tox -e test-e2e |
| 69 | + shell: bash |
0 commit comments