Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CI for pytest #5

Merged
merged 10 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/publish_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,30 @@ name: Publish Python 🐍 distribution 📦 to PyPI
on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11"]
package: ["happtiq_commons_gen_ai", "happtiq_commons_google_cloud"]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
cd packages/${{ matrix.package }}
python -m pip install --upgrade pip
pip install -e '.'
pip install -e '.[dev]'
- name: Test with pytest
run: |
cd packages/${{ matrix.package }}
pytest
build:
name: Build distribution 📦
runs-on: ubuntu-latest
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Test with pytest

on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11"]
package: ["happtiq_commons_gen_ai", "happtiq_commons_google_cloud"]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
cd packages/${{ matrix.package }}
python -m pip install --upgrade pip
pip install -e '.'
pip install -e '.[dev]'
- name: Test with pytest
run: |
cd packages/${{ matrix.package }}
pytest
mab-happtiq marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

@pytest.fixture
def vertex_ai_service(monkeypatch):
monkeypatch.setattr("google.auth.default", MagicMock(return_value=(MagicMock(),MagicMock())))
monkeypatch.setattr("vertexai.init", MagicMock())
return GeminiService(project_id="some-project", location="some-location", model_id="some-model")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
from happtiq_commons_google_cloud.gcs_api_service import GcsApiService

@pytest.fixture
def gcs_api_service():
def gcs_api_service(monkeypatch):
monkeypatch.setattr("google.auth.default", MagicMock(return_value=(MagicMock(universe_domain="googleapis.com"),"some-proje")))
return GcsApiService(timeout=30)

def mock_storage_client():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@


@pytest.fixture
def pubsub_api_service():
def pubsub_api_service(monkeypatch):
monkeypatch.setattr("google.auth.default", MagicMock(return_value=(MagicMock(),"some-proje")))
return PubsubApiService()

def test_publish_message(pubsub_api_service, monkeypatch):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
from unittest.mock import MagicMock, patch

@pytest.fixture
def secret_manager_api_service():
def secret_manager_api_service(monkeypatch):
monkeypatch.setattr("google.auth.default", MagicMock(return_value=(MagicMock(),"some-proje")))
return SecretManagerApiService()

def test_read_secret(secret_manager_api_service, monkeypatch):
Expand Down
Loading