Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add codecov to tests #1283

Merged
merged 8 commits into from
May 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,6 @@ jobs:
EVENTBRITE_API_PUBLIC_TOKEN: ${{ secrets.EVENTBRITE_PUBLIC_TOKEN }}
SOCIAL_AUTH_OPENSTAX_KEY: ${{ secrets.SOCIAL_AUTH_OPENSTAX_KEY }}
SOCIAL_AUTH_OPENSTAX_SECRET: ${{ secrets.SOCIAL_AUTH_OPENSTAX_SECRET }}
- uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
33 changes: 31 additions & 2 deletions manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,38 @@
import os
import sys

if __name__ == "__main__":
def main():
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "openstax.settings")

from django.core.management import execute_from_command_line
# run coverage.py around tests automatically
try:
command = sys.argv[1]
except IndexError:
command = "help"

running_tests = command == "test"
if running_tests:
from coverage import Coverage

cov = Coverage()
cov.erase()
cov.start()

try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)

if running_tests:
cov.stop()
cov.save()
covered = cov.report()


if __name__ == "__main__":
main()
3 changes: 2 additions & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ CacheControl==0.12.5
certifi==2020.11.8
cffi>=1.15.0
chardet==3.0.4
cryptography>=35.0.0
coverage==6.2
cryptography>=36.0.0
defusedxml==0.6.0
distro==1.5.0
Django==3.2.5
Expand Down