|
| 1 | +name: Validate Dependencies |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: [main] |
| 6 | + push: |
| 7 | + branches: [main] |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: write |
| 11 | + |
| 12 | +jobs: |
| 13 | + sync-requirements: |
| 14 | + name: Auto-sync requirements.txt |
| 15 | + if: github.event_name == 'pull_request' |
| 16 | + runs-on: ubuntu-latest |
| 17 | + |
| 18 | + steps: |
| 19 | + - name: Checkout PR branch |
| 20 | + uses: actions/checkout@v4 |
| 21 | + with: |
| 22 | + ref: ${{ github.head_ref }} |
| 23 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 24 | + |
| 25 | + - name: Set up Python |
| 26 | + uses: actions/setup-python@v4 |
| 27 | + with: |
| 28 | + python-version: '3.12' |
| 29 | + |
| 30 | + - name: Install uv |
| 31 | + run: python -m pip install --upgrade pip uv |
| 32 | + |
| 33 | + - name: Regenerate requirements.txt |
| 34 | + run: | |
| 35 | + uv pip compile \ |
| 36 | + --python-platform linux \ |
| 37 | + --extra inline \ |
| 38 | + --emit-index-url \ |
| 39 | + --default-index https://console.redhat.com/api/pypi/public-rhai/rhoai/3.4/cpu-ubi9-test/simple/ \ |
| 40 | + pyproject.toml \ |
| 41 | + --index-url https://console.redhat.com/api/pypi/public-rhai/rhoai/3.4/cpu-ubi9-test/simple/ \ |
| 42 | + -o requirements.txt |
| 43 | +
|
| 44 | + - name: Commit if changed |
| 45 | + run: | |
| 46 | + git diff --quiet requirements.txt && exit 0 |
| 47 | + git config user.name "github-actions[bot]" |
| 48 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 49 | + git add requirements.txt |
| 50 | + git commit -m "chore: auto-sync requirements.txt from pyproject.toml" |
| 51 | + git push |
| 52 | +
|
| 53 | + check-garak-drift: |
| 54 | + name: Check garak midstream version drift |
| 55 | + runs-on: ubuntu-latest |
| 56 | + |
| 57 | + steps: |
| 58 | + - name: Checkout code |
| 59 | + uses: actions/checkout@v4 |
| 60 | + |
| 61 | + - name: Compare pyproject.toml garak version with latest midstream tag |
| 62 | + run: | |
| 63 | + PYPROJECT_VER=$(grep -oP 'garak==\K[^\s"]+' pyproject.toml) |
| 64 | + echo "pyproject.toml garak version: $PYPROJECT_VER" |
| 65 | +
|
| 66 | + LATEST_TAG=$(git ls-remote --tags \ |
| 67 | + https://github.com/trustyai-explainability/garak.git \ |
| 68 | + | grep 'refs/tags/v' \ |
| 69 | + | grep -v '\^{}' \ |
| 70 | + | sed 's|.*refs/tags/v||' \ |
| 71 | + | sort -V \ |
| 72 | + | tail -1) |
| 73 | + echo "Latest midstream tag: $LATEST_TAG" |
| 74 | +
|
| 75 | + if [ "$PYPROJECT_VER" != "$LATEST_TAG" ]; then |
| 76 | + echo "::error::Garak version drift detected!" |
| 77 | + echo " pyproject.toml pins: $PYPROJECT_VER" |
| 78 | + echo " Latest midstream: $LATEST_TAG" |
| 79 | + echo "Update pyproject.toml, regenerate requirements.txt, and commit." |
| 80 | + exit 1 |
| 81 | + fi |
| 82 | +
|
| 83 | + echo "Garak version is up-to-date with midstream." |
| 84 | +
|
| 85 | + container-build: |
| 86 | + name: Container Build + Import Validation |
| 87 | + runs-on: ubuntu-latest |
| 88 | + |
| 89 | + steps: |
| 90 | + - name: Checkout code |
| 91 | + uses: actions/checkout@v4 |
| 92 | + |
| 93 | + - name: Build container image |
| 94 | + run: | |
| 95 | + docker build -f Containerfile -t provider-smoke-test:ci . |
| 96 | +
|
| 97 | + - name: Verify full import chain |
| 98 | + run: | |
| 99 | + docker run --rm provider-smoke-test:ci bash -c "\ |
| 100 | + python -c \"import numpy; print('numpy OK')\" && \ |
| 101 | + python -c \"import pandas; print('pandas OK')\" && \ |
| 102 | + python -c \"import garak; print('garak OK')\" && \ |
| 103 | + python -c \"import sdg_hub; print('sdg-hub OK')\" && \ |
| 104 | + python -c \"import llama_stack_provider_trustyai_garak; print('provider OK')\"" |
| 105 | +
|
| 106 | + - name: Verify garak version matches pyproject.toml |
| 107 | + run: | |
| 108 | + EXPECTED=$(grep -oP 'garak==\K[^\s"]+' pyproject.toml) |
| 109 | + INSTALLED=$(docker run --rm provider-smoke-test:ci python -c "from importlib.metadata import version; print(version('garak'))") |
| 110 | + echo "Expected: $EXPECTED" |
| 111 | + echo "Installed: $INSTALLED" |
| 112 | + if [ "$EXPECTED" != "$INSTALLED" ]; then |
| 113 | + echo "::error::Garak version mismatch! Containerfile installs $INSTALLED but pyproject.toml expects $EXPECTED" |
| 114 | + exit 1 |
| 115 | + fi |
| 116 | + echo "Garak version in container matches pyproject.toml." |
0 commit comments