-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from MinaFoundation/add-cicd-test
Add cicd test
- Loading branch information
Showing
16 changed files
with
174 additions
and
48 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Smoke Tests | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
smoke-tests: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.10' | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
pip install pytest pytest-asyncio httpx | ||
- name: Run Smoke Tests | ||
run: invoke smoke | ||
|
||
- name: Archive test reports | ||
if: always() | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: test-reports | ||
path: reports/ |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[pytest] | ||
env = | ||
OPENAI_API_KEY=sk-mock_value, | ||
MONGO_HOST= mongodb://localhost:27017/, | ||
MONGO_DB=test_db, | ||
MONGO_COLLECTION=my_collection | ||
SHARED_SECRET=123 | ||
|
||
filterwarnings = | ||
ignore::DeprecationWarning | ||
markers = | ||
smoke: mark test as a smoke test. | ||
|
||
asyncio_mode = auto |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,6 @@ | |
|
||
setup( | ||
name="pgt_leaderbot", | ||
version="0.4.0", | ||
version="0.4.1", | ||
packages=find_packages(), | ||
) |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import os | ||
import sys | ||
|
||
import pytest | ||
|
||
project_root = os.path.abspath( | ||
os.path.join(os.path.dirname(__file__), "..", "..", "..") | ||
) | ||
if project_root not in sys.path: | ||
sys.path.insert(0, project_root) |
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import os | ||
import sys | ||
from fastapi.testclient import TestClient | ||
import pytest | ||
from unittest import mock | ||
|
||
from httpx import AsyncClient, ASGITransport | ||
|
||
project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..")) | ||
if project_root not in sys.path: | ||
sys.path.insert(0, project_root) | ||
|
||
from github_tracker_bot.bot import app | ||
|
||
client = TestClient(app) | ||
|
||
|
||
@pytest.mark.smoke | ||
@pytest.mark.asyncio | ||
async def test_authentication_required(): | ||
headers = {"Authorization": "Bearer invalid_token"} | ||
response = client.post("/run-task", headers=headers) | ||
assert response.status_code == 401 | ||
assert response.json()["message"] == "Unauthorized" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from fastapi.testclient import TestClient | ||
import pytest | ||
import os | ||
import sys | ||
from unittest import mock | ||
|
||
project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..")) | ||
if project_root not in sys.path: | ||
sys.path.insert(0, project_root) | ||
|
||
from github_tracker_bot.bot import app | ||
|
||
|
||
@pytest.mark.smoke | ||
def test_scheduler_exists(): | ||
assert hasattr(app.state, "scheduler_task") |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import sys | ||
import os | ||
import pytest | ||
from httpx import AsyncClient, ASGITransport | ||
from unittest import mock | ||
|
||
project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..")) | ||
if project_root not in sys.path: | ||
sys.path.insert(0, project_root) | ||
|
||
with mock.patch("github_tracker_bot.ai_decide_commits.OpenAI") as mock_openai_client: | ||
from github_tracker_bot.bot import app | ||
|
||
|
||
@pytest.mark.smoke | ||
@pytest.mark.asyncio | ||
async def test_app_startup(): | ||
transport = ASGITransport(app=app) | ||
shared_secret = os.environ.get("SHARED_SECRET") | ||
headers = {"Authorization": f"Bearer {shared_secret}"} | ||
|
||
async with AsyncClient(transport=transport, base_url="http://test") as client: | ||
response = await client.get("/non-existing-endpoint", headers=headers) | ||
assert response.status_code == 401 | ||
|
||
|
||
@pytest.mark.smoke | ||
@pytest.mark.asyncio | ||
async def test_app_health_check(): | ||
async with AsyncClient(app=app, base_url="http://test") as client: | ||
response = await client.get("/health") | ||
assert response.status_code == 200 | ||
assert response.json() == {"status": "OK"} |
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
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
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