Skip to content

Commit

Permalink
Merge pull request #670 from BoostryJP/feature/#666
Browse files Browse the repository at this point in the history
Measure test coverage
  • Loading branch information
YoshihitoAso authored Jul 30, 2024
2 parents 6e6fdc8 + 1cbc8ab commit f214bd6
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 28 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,31 @@ jobs:
name: 'Unit tests (PostgreSQL)'
runs-on: ubuntu-latest
needs: build
permissions:
actions: read
contents: read
packages: read
pull-requests: write
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-test-image
- name: Collect Workflow Telemetry
uses: catchpoint/workflow-telemetry-action@v2
with:
comment_on_pr: false
- name: Change owner of output directory
run: |
sudo chown -R runner:docker /home/runner/work/ibet-Prime/ibet-Prime/cov
sudo chmod 777 /home/runner/work/ibet-Prime/ibet-Prime/cov
- name: run unit test using postgres
run: docker compose run ibet-prime-postgres
- name: Pytest coverage comment
id: coverageComment
uses: MishaKav/pytest-coverage-comment@main
with:
pytest-xml-coverage-path: cov/coverage.xml
junitxml-path: cov/pytest.xml
report-only-changed-files: true
migration-test-postgres:
name: 'Migration tests (PostgreSQL)'
runs-on: ubuntu-latest
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@ node_modules/

# Mac
.DS_Store

# Project
cov/coverage.xml
cov/pytest.xml
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ services:
depends_on:
- postgres
- hardhat-network
volumes:
- ./cov:/app/ibet-Prime/cov
38 changes: 19 additions & 19 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ typer = "0.12.3"
aiohttp = {version = "~3.9.3", optional = true}

[tool.poetry.group.dev.dependencies]
pytest = "^7.4.4"
pytest-cov = "^4.1.0"
pytest = "^8.3.2"
pytest-cov = "^5.0.0"
pyyaml = "^6.0"
pre-commit = "^3.6.0"
ruff = "^0.5.4"
textual-dev = "^1.2.1"
pytest-alembic = "^0.10.7"
pytest-freezer = "^0.4.8"
pytest-asyncio = "0.23.3"
pytest-asyncio = "0.23.8"
pytest-aiohttp = "^1.0.5"
ruamel-yaml = "^0.18.6"
pytest-memray = "^1.6.0"
Expand Down Expand Up @@ -103,6 +103,10 @@ exclude = ["migrations/*"]
[tool.ruff.lint.isort]
combine-as-imports = true

[tool.coverage.run]
branch = true
concurrency = ["thread", "greenlet"]

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
4 changes: 1 addition & 3 deletions tests/Dockerfile_unittest
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ COPY pyproject.toml /app/ibet-Prime/pyproject.toml
COPY poetry.lock /app/ibet-Prime/poetry.lock
RUN . ~/.bash_profile \
&& cd /app/ibet-Prime \
&& poetry install --no-root --all-extras \
&& rm -f /app/ibet-Prime/pyproject.toml \
&& rm -f /app/ibet-Prime/poetry.lock
&& poetry install --no-root --all-extras

FROM ubuntu:22.04 AS runner

Expand Down
7 changes: 4 additions & 3 deletions tests/qa.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ cd /app/ibet-Prime

sleep 10

# test
pytest tests/ -v --cov=app/routers/ --cov-report=xml --cov-branch
# Test
poetry run pytest -v --cov=app/routers/ --cov=app/model/ --cov=app/utils/ --cov=batch/ --junitxml=pytest.xml --cov-report=xml --cov-report=term-missing:skip-covered --cov-branch tests/

status_code=$?

# カバレッジファイルの移動
# Move coverage files
mv coverage.xml cov/
mv pytest.xml cov/

if [ $status_code -ne 0 ]; then
exit 1
Expand Down

0 comments on commit f214bd6

Please sign in to comment.