-
-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ci: preliminary ci support * style: fix whitespace * ci: run some horde_sdk tests too * ci: fix use local testing API for SDK tests * ci: show all output for `pytest` invocations * ci: skip model list checking for now * style: fix
- Loading branch information
Showing
16 changed files
with
184 additions
and
46 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,84 @@ | ||
name: AI-Horde main tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- '**.py' | ||
- '**.json' | ||
- 'tox.ini' | ||
- '.github/workflows/maintests.yml' | ||
- '.github/workflows/prtests.yml' | ||
- '.github/workflows/release.yml' | ||
|
||
jobs: | ||
runner-job: | ||
runs-on: ubuntu-latest | ||
# runs-on: self-hosted | ||
env: | ||
POSTGRES_URL: "localhost:5432/horde_test" | ||
POSTGRES_PASS: "postgres" | ||
PGPASSWORD: "postgres" | ||
REDIS_IP: "localhost" | ||
REDIS_SERVERS: '["localhost"]' | ||
USE_SQLITE: 0 | ||
ADMINS: '["test_user#1"]' | ||
R2_TRANSIENT_ACCOUNT: ${{ secrets.R2_TRANSIENT_ACCOUNT }} | ||
R2_PERMANENT_ACCOUNT: ${{ secrets.R2_PERMANENT_ACCOUNT }} | ||
SHARED_AWS_ACCESS_ID: ${{ secrets.SHARED_AWS_ACCESS_ID }} | ||
SHARED_AWS_ACCESS_KEY: ${{ secrets.SHARED_AWS_ACCESS_KEY }} | ||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
KUDOS_TRUST_THRESHOLD: 100 | ||
AI_HORDE_DEV_URL: "http://localhost:7001/api/" # For horde_sdk tests | ||
|
||
services: | ||
postgres: | ||
image: postgres:15.6-bullseye | ||
env: | ||
POSTGRES_PASSWORD: postgres | ||
# Set health checks to wait until postgres has started | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
ports: | ||
- 5432:5432 | ||
|
||
redis: | ||
image: redis | ||
options: >- | ||
--health-cmd "redis-cli ping" | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
ports: | ||
- 6379:6379 | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.10' | ||
# cache: 'pip' | ||
- run: python -m pip install --upgrade pip wheel setuptools | ||
- name: Install and run lint/format checkers | ||
run: | | ||
python -m pip install -r requirements.dev.txt | ||
black --check . | ||
ruff . | ||
- name: Install and run tests | ||
run: | | ||
python -m pip install -r requirements.txt | ||
psql -h localhost -U postgres -c "CREATE DATABASE horde_test;" | ||
python server.py -vvvvi --horde stable & | ||
sleep 5 | ||
curl -X POST --data-raw 'username=test_user' http://localhost:7001/register | grep -Po '<p style="background-color:darkorange;">\K.*(?=<\/p>)' > tests/apikey.txt | ||
export AI_HORDE_DEV_APIKEY=$(cat tests/apikey.txt) | ||
pytest tests/ -s | ||
python -m pip download --no-deps --no-binary :all: horde_sdk | ||
tar -xvf horde_sdk-*.tar.gz | ||
cd horde_sdk**/ | ||
pytest tests/ --ignore-glob=*api_calls.py --ignore-glob=*test_model_meta.py -s |
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 |
---|---|---|
|
@@ -136,4 +136,10 @@ horde.log | |
horde*.bz2 | ||
horde.db | ||
/.idea | ||
/boto3oeo.py | ||
/boto3oeo.py | ||
|
||
|
||
apikey.txt | ||
.vscode/ | ||
|
||
horde_sdk** |
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
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
black==23.12.1 | ||
ruff==0.1.13 | ||
pytest==8.0.0 | ||
tox~=4.12.1 | ||
horde_sdk>=0.7.29 |
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
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,45 @@ | ||
import pathlib | ||
|
||
import pytest | ||
import requests | ||
|
||
|
||
@pytest.fixture | ||
def CIVERSION() -> str: | ||
return "0.1.1" | ||
|
||
|
||
@pytest.fixture | ||
def HORDE_URL() -> str: | ||
return "localhost:7001" | ||
|
||
|
||
@pytest.fixture | ||
def api_key() -> str: | ||
key_file = pathlib.Path(__file__).parent / "apikey.txt" | ||
if key_file.exists(): | ||
return key_file.read_text().strip() | ||
|
||
raise ValueError("No api key file found") | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
def increase_kudos(api_key: str, HORDE_URL: str, CIVERSION: str) -> None: | ||
headers = {"apikey": api_key, "Client-Agent": f"aihorde_ci_client:{CIVERSION}:(discord)db0#1625", "user_id": "1"} | ||
|
||
payload_set_to_mod = { | ||
"trusted": True, | ||
"moderator": True, | ||
} | ||
|
||
response_set_to_mod = requests.put(f"http://{HORDE_URL}/api/v2/users/1", json=payload_set_to_mod, headers=headers) | ||
|
||
assert response_set_to_mod.ok, response_set_to_mod.text | ||
|
||
payload_set_kudos = { | ||
"kudos": 10000, | ||
} | ||
|
||
response_kudos = requests.put(f"http://{HORDE_URL}/api/v2/users/1", json=payload_set_kudos, headers=headers) | ||
|
||
assert response_kudos.ok, response_kudos.text |
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
Oops, something went wrong.