mirror of
https://github.com/rommapp/romm.git
synced 2026-12-02 10:08:40 +01:00
Add pytest for PRs
Install poetry explicit
This commit is contained in:
69
.github/workflows/pytest.yml
vendored
Normal file
69
.github/workflows/pytest.yml
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
name: pytest
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types:
|
||||
- "opened"
|
||||
- "synchronize"
|
||||
paths-ignore:
|
||||
- "docker/**"
|
||||
- "examples/*"
|
||||
- "frontend/**"
|
||||
push:
|
||||
branches:
|
||||
- "master"
|
||||
paths-ignore:
|
||||
- "docker/**"
|
||||
- "examples/*"
|
||||
- "frontend/**"
|
||||
|
||||
jobs:
|
||||
pytest:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
checks: write
|
||||
pull-requests: write
|
||||
services:
|
||||
mariadb:
|
||||
image: mariadb:10.11
|
||||
ports:
|
||||
- 3306
|
||||
env:
|
||||
MYSQL_USER: romm_test
|
||||
MYSQL_PASSWORD: passwd
|
||||
MYSQL_DATABASE: romm_test
|
||||
MYSQL_ROOT_PASSWORD: passwd
|
||||
options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
- name: Install mariadb connectors
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libmariadb3 libmariadb-dev
|
||||
- name: Install poetry
|
||||
run: pipx install poetry
|
||||
- name: Set up Python 3.10
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.10'
|
||||
cache: 'poetry'
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
poetry install --sync
|
||||
- name: Initiate database
|
||||
run: |
|
||||
mysql --host 127.0.0.1 --port ${{ job.services.mariadb.ports['3306'] }} -uroot -ppasswd -e "GRANT ALL PRIVILEGES ON romm_test.* TO 'romm_test'@'%' WITH GRANT OPTION; FLUSH PRIVILEGES;"
|
||||
- name: Run python tests
|
||||
env:
|
||||
DB_HOST: 127.0.0.1
|
||||
DB_PORT: ${{ job.services.mariadb.ports['3306'] }}
|
||||
run: |
|
||||
cd backend
|
||||
poetry run pytest -vv --maxfail=10 --junitxml=pytest-report.xml .
|
||||
- name: Publish test results
|
||||
uses: EnricoMi/publish-unit-test-result-action/composite@v2
|
||||
if: always()
|
||||
with:
|
||||
files: |
|
||||
backend/pytest-report.xml
|
||||
@@ -27,9 +27,9 @@ class ConfigLoader:
|
||||
@staticmethod
|
||||
def get_db_engine() -> str:
|
||||
if ROMM_DB_DRIVER == "mariadb":
|
||||
DB_HOST: str = os.environ.get("DB_HOST")
|
||||
DB_HOST: str = os.environ.get("DB_HOST", "127.0.0.1")
|
||||
try:
|
||||
DB_PORT: int = int(os.environ.get("DB_PORT"))
|
||||
DB_PORT: int = int(os.environ.get("DB_PORT", 3306))
|
||||
except TypeError:
|
||||
log.critical("DB_PORT variable not set properly")
|
||||
sys.exit(3)
|
||||
|
||||
@@ -252,6 +252,9 @@ class TwitchAuth:
|
||||
log.info("Twitch token fetched!")
|
||||
|
||||
def get_oauth_token(self) -> str:
|
||||
if "pytest" in sys.modules:
|
||||
return "test_token"
|
||||
|
||||
if not self._is_token_valid():
|
||||
log.warning("Twitch token invalid: fetching a new one...")
|
||||
self._update_twitch_token()
|
||||
|
||||
@@ -7,9 +7,9 @@ interactions:
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Authorization:
|
||||
- Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
- Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Client-ID:
|
||||
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
@@ -77,9 +77,9 @@ interactions:
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Authorization:
|
||||
- Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
- Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Client-ID:
|
||||
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
|
||||
12
backend/utils/tests/cassettes/test_scan_rom.yaml
generated
12
backend/utils/tests/cassettes/test_scan_rom.yaml
generated
@@ -9,9 +9,9 @@ interactions:
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Authorization:
|
||||
- Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
- Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Client-ID:
|
||||
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
@@ -135,9 +135,9 @@ interactions:
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Authorization:
|
||||
- Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
- Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Client-ID:
|
||||
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
@@ -206,9 +206,9 @@ interactions:
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Authorization:
|
||||
- Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
- Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Client-ID:
|
||||
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
|
||||
Reference in New Issue
Block a user