Skip to content

Commit e6767fb

Browse files
committed
add CI coverage for Tokenserver Python tests
1 parent 2eddf6d commit e6767fb

1 file changed

Lines changed: 73 additions & 0 deletions

File tree

.github/workflows/main-workflow.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,79 @@ jobs:
385385
glob: "*.json"
386386
parent: false
387387
process_gcloudignore: false
388+
# Tokenserver Python unit tests ======
389+
tokenserver-unit-tests:
390+
needs: python-env
391+
runs-on: ubuntu-latest
392+
permissions:
393+
contents: read
394+
checks: write
395+
396+
services:
397+
mysql:
398+
image: mysql:8.0
399+
env:
400+
MYSQL_ROOT_PASSWORD: password
401+
MYSQL_USER: test
402+
MYSQL_PASSWORD: test
403+
MYSQL_DATABASE: tokenserver
404+
ports:
405+
- 3306:3306
406+
options: >-
407+
--health-cmd="mysqladmin ping -h 127.0.0.1 -u root -ppassword"
408+
--health-interval=10s
409+
--health-timeout=5s
410+
--health-retries=5
411+
412+
env:
413+
SYNC_TOKENSERVER__DATABASE_URL: mysql://test:test@127.0.0.1/tokenserver
414+
SYNC_TOKENSERVER__NODE_TYPE: mysql
415+
416+
steps:
417+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
418+
with:
419+
persist-credentials: false
420+
421+
- name: Set up Python
422+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
423+
with:
424+
python-version: ${{ env.PYTHON_VERSION }}
425+
426+
- name: Restore pip and Poetry virtualenv
427+
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5
428+
with:
429+
path: |
430+
~/.cache/pip
431+
~/.cache/pypoetry/virtualenvs
432+
key: ${{ runner.os }}-python-${{ hashFiles('pyproject.toml', 'poetry.lock') }}
433+
434+
- name: Install Poetry
435+
run: pip3 install poetry
436+
437+
- name: Create test results directory
438+
run: mkdir -p workflow/test-results
439+
440+
- name: Run Tokenserver unit tests
441+
run: |
442+
WORKFLOW=$(echo "${GITHUB_WORKFLOW}" | tr ' ' '-' | tr '[:upper:]' '[:lower:]')
443+
poetry run pytest tools/tokenserver/test_database.py tools/tokenserver/test_process_account_events.py tools/tokenserver/test_purge_old_records.py tools/tokenserver/test_scripts.py -v --junit-xml="workflow/test-results/${GITHUB_RUN_NUMBER}__$(date +%s)__$(basename ${GITHUB_REPOSITORY})__${WORKFLOW}__tokenserver_unit__results.xml"
444+
445+
- name: Publish Test Report
446+
uses: dorny/test-reporter@a810f9bf83f2344124a920a7a0a85a6716e791f0
447+
if: always()
448+
with:
449+
name: Tokenserver Unit Tests
450+
path: workflow/test-results/*.xml
451+
reporter: java-junit
452+
fail-on-error: false
453+
454+
- name: Upload test results
455+
if: always()
456+
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
457+
with:
458+
name: tokenserver-unit-test-results
459+
path: workflow/test-results/
460+
388461
# Docker build Postgres Image ======
389462
build-postgres-image:
390463
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)