fix test wheel #5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test Python Wheel | |
on: | |
push: | |
branches: ["feature/poetry"] | |
pull_request: | |
branches: ["feature/poetry"] | |
jobs: | |
test-wheel: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ["3.9", "3.10", "3.11"] | |
steps: | |
# Call reusable `_test.yml` workflow for setup and dependency installation | |
- name: Run reusable test workflow | |
uses: ./.github/workflows/_test.yml | |
with: | |
os: ubuntu-latest | |
python-version: ${{ matrix.python-version }} | |
# Extract the version tag from the release | |
- name: Extract Version Tag | |
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV | |
# Download the built wheel artifact from the `build-wheel` job | |
- name: Download Artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: nemoguardrails-${{ env.VERSION }}.whl | |
- name: Install Wheel | |
run: | | |
pip install --user nemoguardrails-${{ env.VERSION }}-py3-none-any.whl | |
pip install --user nemoguardrails-${{ env.VERSION }}-py3-none-any.whl[dev] | |
# Run additional tests as needed | |
- name: Run Tests | |
run: make test | |
# Start the server and test its functionality | |
- 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 | |
# Stop the server if tests succeed | |
- name: Stop server | |
if: ${{ success() }} | |
run: | | |
kill $SERVER_PID |