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

Use pytest on CI #252

Merged
merged 4 commits into from
Jun 10, 2021
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
27 changes: 15 additions & 12 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,23 @@ on:

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.7

- name: Checkout
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need this step?

Copy link
Contributor Author

@anjensan anjensan Jun 7, 2021

Choose a reason for hiding this comment

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

It does not add a new step, just add name to it "Run actions/checkout@v2" => "Checkout"

uses: actions/checkout@v2

- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: 3.7

- name: Setup github username
run: |
git config --global user.email "fake@example.com"
git config --global user.name "fake name"

- name: Setup docker
run: |
sudo apt install apt-transport-https ca-certificates curl software-properties-common
Expand All @@ -35,16 +39,15 @@ jobs:

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install bs4
pip install pytest
pip install bigflow
pip install -r requirements.txt
pip install -r test/requirements.txt
sudo apt install docker

- name: Tests
- name: Run unit tests
run: |
python -m unittest discover -s bigflow -t . -p '*.py'
python -m unittest discover -s test -p '*.py'
pytest --html=build/test-report.html --self-contained-html

- name: Upload test report
if: always()
uses: actions/upload-artifact@v2
with:
name: test-report
path: build/test-report.html
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.pytest.ini_options]
minversion = "6.0"
#addopts = "-ra -q"
testpaths = [
"test",
"bigflow",
]
8 changes: 7 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,10 @@
twine
freezegun
pexpect
responses
responses
bs4

pytest
pytest-html
pytest-cov
pytest-github-actions-annotate-failures
Empty file added test/cli/__init__.py
Empty file.
11 changes: 3 additions & 8 deletions test/cli/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from logging import shutdown
from mock.mock import _set_return_value
from bigflow.build.operate import build_project
from unittest import TestCase
import itertools
import mock
import shutil
import freezegun

from bigflow.testing.isolate import ForkIsolateMixin
from bigflow.cli import *

from test import mixins
Expand All @@ -16,12 +15,14 @@

class CliTestCase(
mixins.PrototypedDirMixin,
ForkIsolateMixin,
TestCase,
):
proto_dir = "bf-projects/example_project"

def setUp(self) -> None:
super().setUp()
sys.path.append(str(Path(__file__).parent))

self.project_setuppy = self.cwd / "setup.py"

Expand All @@ -30,12 +31,6 @@ def setUp(self) -> None:

bigflow.build.spec.get_project_spec.cache_clear()

def tearDown(self):
try:
import_module("test_module.Unused1").started_jobs.clear()
except ImportError:
pass

def test_should_walk_through_all_files_inside_package_tree(self):
# when
res = walk_module_files(TEST_MODULE_PATH)
Expand Down