mirror of
https://github.com/rommapp/romm.git
synced 2026-02-04 18:48:10 +08:00
76 lines
1.9 KiB
YAML
76 lines
1.9 KiB
YAML
name: Run Pytest
|
|
|
|
on:
|
|
pull_request:
|
|
paths:
|
|
- "backend/**"
|
|
push:
|
|
branches:
|
|
- "master"
|
|
paths:
|
|
- "backend/**"
|
|
|
|
permissions: read-all
|
|
|
|
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@v4
|
|
|
|
- name: Install mariadb connectors
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y libmariadb3 libmariadb-dev
|
|
|
|
- name: Install uv
|
|
uses: astral-sh/setup-uv@v5
|
|
|
|
- name: Install python
|
|
run: |
|
|
uv python install 3.13
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
uv sync --extra test
|
|
|
|
- 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
|
|
uv run pytest -vv --maxfail=10 --junitxml=pytest-report.xml --cov --cov-report xml:coverage.xml --cov-config=.coveragerc .
|
|
|
|
- name: Publish test results
|
|
uses: EnricoMi/publish-unit-test-result-action/linux@v2
|
|
if: (!cancelled())
|
|
with:
|
|
files: |
|
|
backend/pytest-report.xml
|
|
|
|
- name: Publish coverage report
|
|
uses: orgoro/coverage@v3.2
|
|
with:
|
|
coverageFile: backend/coverage.xml
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|