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 Github Actions for CI #1686

Merged
merged 4 commits into from
Jan 22, 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
44 changes: 44 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Tests

on: [push, pull_request]

jobs:
tests:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
include:
#- {name: Linux, python: '3.9', os: ubuntu-latest, tox: py39}
#- {name: Windows, python: '3.9', os: windows-latest, tox: py39}
#- {name: Mac, python: '3.9', os: macos-latest, tox: py39}
- {name: '3.9', python: '3.9', os: ubuntu-latest, tox: py39}
- {name: '3.8', python: '3.8', os: ubuntu-latest, tox: py38}
- {name: '3.7', python: '3.7', os: ubuntu-latest, tox: py37}
- {name: '3.6', python: '3.6', os: ubuntu-latest, tox: py36}

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
- name: Update pip
run: |
pip install -U wheel
pip install -U setuptools
python -m pip install -U pip
- name: Get pip cache dir
id: pip-cache
run: echo "::set-output name=dir::$(pip cache dir)"
- name: Cache pip
uses: actions/cache@v2
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: pip|${{ runner.os }}|${{ matrix.python }}|${{ hashFiles('setup.py') }}
- name: set full Python version in PY env var
# See https://pre-commit.com/#github-actions-example
run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
- run: pip install tox codecov
- run: tox -e ${{ matrix.tox }}
2 changes: 1 addition & 1 deletion locust/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ def sig_term_handler():
main_greenlet.join()
if options.html_file:
html_report = get_html_report(environment, show_download_link=False)
with open(options.html_file, "w+") as file:
with open(options.html_file, "w", encoding="utf-8") as file:
file.write(html_report)
shutdown()
except KeyboardInterrupt:
Expand Down
22 changes: 10 additions & 12 deletions locust/test/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,17 +255,16 @@ def test_headless_spawn_options_wo_run_time(self):
self.assertIn("Shutting down (exit code 0), bye", stderr)

def test_default_headless_spawn_options_with_shape(self):
content = (
MOCK_LOUCSTFILE_CONTENT
+ """
class LoadTestShape(LoadTestShape):
def tick(self):
run_time = self.get_run_time()
if run_time < 2:
return (10, 1)

return None
"""
content = MOCK_LOUCSTFILE_CONTENT + textwrap.dedent(
"""
class LoadTestShape(LoadTestShape):
def tick(self):
run_time = self.get_run_time()
if run_time < 2:
return (10, 1)

return None
"""
)
with mock_locustfile(content=content) as mocked:
output = (
Expand All @@ -279,7 +278,6 @@ def tick(self):
)
self.assertIn("Shape test updating to 10 users at 1.00 spawn rate", output)
self.assertIn("Cleaning up runner...", output)
self.assertIn("Quitting...", output)

def test_web_options(self):
port = get_free_tcp_port()
Expand Down