Skip to content

update test action

update test action #36

Workflow file for this run

name: Test
on:
push:
paths:
- 'backend/*'
- '.github/workflows/test.yml'
branches:
- '**'
tags-ignore:
- '**'
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: mirromutth/mysql-action@v1.1
with:
mysql database: "hermadata_test" # Optional, default value is "test". The specified database which will be create
mysql root password: "dev"
- name: Set up Python
# This is the version of the action for setting up Python, not the Python version.
uses: actions/setup-python@v5
with:
# Semantic version range syntax or exact version of a Python version
python-version: "3.x"
# Optional - x64 or x86 architecture, defaults to x64
architecture: "x64"
# You can test your matrix by printing the current Python version
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Install dependencies
run: |
cd backend
python -m pip install --upgrade pip
pip install .
pip install pytest httpx pytest-env pytest-dotenv pytest-cov
- name: Database migrations
run: |
cd backend
alembic -c tests/alembic.ini upgrade head
- name: Run tests
run: |
cd backend
mkdir tests/storage
pytest --cov=hermadata --cov-report json
mv coverage.json ../
- name: Update Coverage Badge
# GitHub actions: default branch variable
# https://stackoverflow.com/questions/64781462/github-actions-default-branch-variable
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
uses: we-cli/coverage-badge-action@main