Migrate from rye to uv #114
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: Run tests | |
on: | |
pull_request: | |
workflow_dispatch: | |
env: | |
NATS_TOKEN: test | |
jobs: | |
test: | |
name: Run tests on Python ${{ matrix.python-version }} | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ["3.11", "3.12"] | |
steps: | |
- name: 👀 Checkout code | |
uses: actions/checkout@v2 | |
with: | |
submodules: true | |
- name: Setup apt cache | |
uses: actions/cache@v2 | |
with: | |
path: /var/cache/apt/archives | |
key: ${{ runner.os }}-apt-${{ hashFiles('/etc/apt/sources.list') }} | |
- name: 😭 Install system dependencies | |
run: | | |
sudo apt-get update && sudo apt-get install -y \ | |
netcat-traditional \ | |
unzip \ | |
libgeos-dev \ | |
libcurl4-openssl-dev \ | |
libssl-dev \ | |
binutils \ | |
curl \ | |
git \ | |
autoconf \ | |
automake \ | |
build-essential \ | |
libtool \ | |
gcc \ | |
libmagic-dev \ | |
poppler-utils \ | |
tesseract-ocr \ | |
libreoffice \ | |
libpq-dev \ | |
pandoc | |
- name: 🐍 Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: 'pip' | |
- name: 🔽 Install uv | |
run: | | |
pip install uv | |
- name: 🔽 Download and Install NATS Server | |
run: | | |
curl -L https://github.com/nats-io/nats-server/releases/download/v2.10.22/nats-server-v2.10.22-linux-amd64.zip -o nats-server.zip | |
unzip nats-server.zip -d nats-server && sudo cp nats-server/nats-server-v2.10.22-linux-amd64/nats-server /usr/bin | |
- name: 🛠️ Set up NATS arguments | |
run: | | |
nohup nats-server \ | |
--addr 0.0.0.0 \ | |
--port 4222 \ | |
--auth "$NATS_TOKEN" > nats.log 2>&1 & | |
- name: 🔍 Verify NATS Server is Running | |
run: | | |
sleep 1 # Give the server some time to start | |
if nc -zv localhost 4222; then | |
echo "✅ NATS Server is running on port 4222." | |
else | |
echo "❌ Failed to start NATS Server." | |
cat nats.log | |
exit 1 | |
fi | |
- name: 🔨 Set up uv cache | |
run: | | |
mkdir -p ~/.cache/uv | |
- name: 🔨 Create and setup virtual environment | |
run: | | |
python -m venv .venv | |
echo "VIRTUAL_ENV=$GITHUB_WORKSPACE/.venv" >> $GITHUB_ENV | |
echo "$GITHUB_WORKSPACE/.venv/bin" >> $GITHUB_PATH | |
source .venv/bin/activate | |
python -m pip install --upgrade pip setuptools wheel uv | |
- name: 🔨 Install core dependencies | |
timeout-minutes: 5 | |
run: | | |
source .venv/bin/activate | |
UV_INDEX_STRATEGY=unsafe-first-match UV_LOG=debug python -m uv pip install -v pytest pytest-cov pytest-asyncio | |
- name: 🔨 Install megaparse dependencies | |
timeout-minutes: 5 | |
run: | | |
source .venv/bin/activate | |
UV_INDEX_STRATEGY=unsafe-first-match UV_LOG=debug python -m uv pip install -v -e ./libs/megaparse[test] | |
- name: 🔨 Install megaparse_sdk dependencies | |
timeout-minutes: 5 | |
run: | | |
source .venv/bin/activate | |
UV_INDEX_STRATEGY=unsafe-first-match UV_LOG=debug python -m uv pip install -v -e ./libs/megaparse_sdk[test] | |
- name: 🔨 Verify installation | |
run: | | |
.venv/bin/python -m pip list | |
.venv/bin/python -c "import pytest; import megaparse; import megaparse_sdk; print('✅ All packages imported successfully')" | |
- name: 🚀 Run tests | |
run: | | |
.venv/bin/python -m pytest libs/megaparse_sdk/tests/ |