Skip to content

Commit

Permalink
Merge pull request #161 from hibiya-itchief/testについて
Browse files Browse the repository at this point in the history
Testについて
  • Loading branch information
aozoraUS authored Mar 26, 2024
2 parents fd6691f + a52c88a commit e17f0d0
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 46 deletions.
86 changes: 42 additions & 44 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
@@ -1,60 +1,58 @@
# This is a basic workflow to help you get started with Actions

#name: pytest
name: pytest

#permissions: write-all
permissions: write-all

# Controls when the workflow will run
#on:
# Triggers the workflow on push or pull request events but only for the "develop" branch
# push:
# branches: ["develop", "main"]
# pull_request:
# branches: ["develop", "main"]
on:
# Triggers the workflow on push or pull request events but only for the "develop" branch
push:
branches: ["develop", "main"]
pull_request:
branches: ["develop", "main"]

# Allows you to run this workflow manually from the Actions tab
# workflow_dispatch:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
#jobs:
# This workflow contains a single job called "pytest"
# pytest:
# The type of runner that the job will run on
# runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
# steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
# - uses: actions/checkout@v3

# - name: Test with pytest on Docker
# run: |
# touch ./app/.env
# echo DB_HOST=db >> ./app/.env
# echo MYSQL_USER=docker_dev >> ./app/.env
# echo MYSQL_PASSWORD=cRH1eL4GbNZkFXlk >> ./app/.env
# echo BIND-ADDRESS=0.0.0.0 >> ./app/.env
# echo MYSQL_RANDOM_ROOT_PASSWORD=yes >> ./app/.env
# echo MYSQL_DATABASE=quaint-app >> ./app/.env
# docker-compose up -d
# docker-compose exec -T app bash
# ./wait-for-it.sh

# - name: Create Coverage Comment
# id: coverageComment
# uses: MishaKav/pytest-coverage-comment@main
# with:
# pytest-coverage-path: ./pytest-coverage.txt
# junitxml-path: ./app/test/pytest.xml

jobs:
# This workflow contains a single job called "pytest"
pytest:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3

- name: Test with pytest on Docker
run: |
touch ./app/.env
echo DB_HOST=db >> ./app/.env
echo MYSQL_USER=docker_dev >> ./app/.env
echo MYSQL_PASSWORD=cRH1eL4GbNZkFXlk >> ./app/.env
echo BIND-ADDRESS=0.0.0.0 >> ./app/.env
echo MYSQL_RANDOM_ROOT_PASSWORD=yes >> ./app/.env
echo MYSQL_DATABASE=quaint-app >> ./app/.env
docker-compose up -d
sleep 60s
docker-compose exec -T app bash /workspace/wait-for-it.sh db:3306 -t 60 -- pytest ./workspace/app/test --cov --junitxml=/app/app/test/pytest.xml --cov-report=term-missing:skip-covered > ./pytest-coverage.txt
- name: Create Coverage Comment
id: coverageComment
uses: MishaKav/pytest-coverage-comment@main
with:
pytest-coverage-path: ./pytest-coverage.txt
junitxml-path: ./app/test/pytest.xml
# - name: Create Coverage Badge
# uses: schneegans/[email protected]
# with:
# auth: ${{ secrets.BADGE_GIST }} # 名前は適宜変更:手順5で決めたトークン名
# gistID: 81370c9284b6c64224021c2c6520c2e3 #先ほど控えたGist ID
# 以降はコピペ可
# cerverageCommentはPytest Coverage CommentのID
# 書き換えた場合は変更が必要
# # 以降はコピペ可
# # cerverageCommentはPytest Coverage CommentのID
# # 書き換えた場合は変更が必要
# filename: pytest-coverage-comment.json
# label: Coverage
# message: ${{ steps.coverageComment.outputs.coverage }}
Expand Down
5 changes: 5 additions & 0 deletions app/config.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import datetime
import os
from dotenv import load_dotenv

from pydantic import BaseSettings

load_dotenv()

class Parameters(BaseSettings):
person_per_user:int=3 # 1つのユーザーで同時入場できる人数
Expand Down Expand Up @@ -66,3 +68,6 @@ class Config:

params=Parameters()
settings= Settings()

print("config")
print(settings.mysql_user)
3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ services:
- .:/workspace:cached
ports:
- "8000:8000"
command: /bin/bash /workspace/docker_startup.sh
command: >
/bin/sh -c 'chmod +x /workspace/docker_startup.sh && /workspace/docker_startup.sh'
redis:
image: "redis:latest"
Expand Down
1 change: 1 addition & 0 deletions docker_startup.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
cd workspace
python3 -m pip install --upgrade pip
pip install -r ./requirements.txt
wait
chmod +x ./wait-for-it.sh
bash ./wait-for-it.sh db:3306 -t 60 -- alembic upgrade head
uvicorn app.main:app --host 0.0.0.0 --reload
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ hashids==1.3.1
jose==1.0.0
passlib==1.7.4
pydantic==1.10.6
pytest==7.1.2
pytest
python_jose==3.3.0
requests
SQLAlchemy==1.4.37
Expand Down

1 comment on commit e17f0d0

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
workspace/app
   auth.py23017026%30–39, 45–59, 62–63, 66–71, 75–79, 83–89, 91–94, 96–102, 104–107, 109–115, 117–120, 123–129, 131–134, 137, 139, 141, 143, 146–152, 154–157, 160–166, 168–171, 173–179, 181–184, 186–190, 192–195, 197–200, 202–205, 207–210, 212–215, 217, 220–223, 225, 228–231, 233, 235–238, 240, 242–245, 249–282
   crud.py29624119%18–21, 24–28, 31–33, 35–36, 38–42, 44–50, 53–54, 57–61, 64–82, 85–98, 101–105, 108–112, 115–128, 130–137, 140–142, 144–145, 148–152, 154–155, 157–158, 160–162, 166–175, 177–193, 195–211, 213–214, 218–222, 227–257, 259–263, 265–269, 271–272, 274–278, 280–286, 288–292, 294–300, 304–308, 310–311, 313–314, 316–322, 324–329, 334–341, 344–345, 348–354, 357, 359, 361–371, 373–383
   db.py221150%19–30
   ga.py261831%16–32, 34–45
   main.py37726131%31, 102, 110–114, 123, 131, 139, 147–150, 157–160, 170–173, 181–189, 198–205, 215–221, 232–243, 252–261, 269–278, 287–294, 305–308, 318–323, 333–339, 352–363, 371–379, 388–395, 405–413, 421–423, 434–452, 462–473, 482–489, 499–502, 510–513, 522–530, 537–545, 555–569, 578–583, 592–595, 606–609, 617, 626–629, 638–641, 649–652, 662, 673–677, 687–691, 699–703, 713, 723
   models.py78495%75–78
   msgraph.py311939%14, 16–42, 44–47, 50–63
   redis_possible.py211624%9–16, 18–25
   schemas.py151199%180
   storage.py644628%19, 30–46, 49–65, 68–73, 76–79, 82–86
workspace/app/test
   conftest.py19763%16–23
workspace/app/test/utils
   overrides.py15473%15–19
TOTAL150879847% 

Please sign in to comment.