diff --git a/.github/workflows/test-wheel.yml b/.github/workflows/test-wheel.yml index 1b191435..4b25133a 100644 --- a/.github/workflows/test-wheel.yml +++ b/.github/workflows/test-wheel.yml @@ -37,7 +37,7 @@ jobs: run: poetry config virtualenvs.in-project true - name: Set up cache - uses: actions/cache@v3 + uses: actions/cache@v4 id: cache with: path: .venv @@ -74,4 +74,44 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: + python-version: ${{ matrix.python-version }} + + - name: Download Artifact + uses: actions/download-artifact@v4 + with: + name: built-wheel + + - name: Install Wheel + run: | + pip install --user dist/*.whl + pip install --user dist/*.whl[dev] + + - name: Run Tests + run: make test + + - name: Start server in the background + run: | + nemoguardrails server & + echo "SERVER_PID=$!" >> $GITHUB_ENV + + - name: Wait for server to be up + run: | + echo "Waiting for server to start..." + while ! curl --output /dev/null --silent --head --fail http://localhost:8000; do + printf '.' + sleep 1 + done + echo "Server is up!" + + - name: Check server status + run: | + RESPONSE_CODE=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8000/v1/rails/configs) + if [ "$RESPONSE_CODE" -ne 200 ]; then + echo "Server responded with code $RESPONSE_CODE." + exit 1 + fi + + - name: Stop server + if: ${{ success() }} + run: | + kill $SERVER_PID