Skip to content

Commit

Permalink
Merge pull request #1686 from locustio/github-actions-tests
Browse files Browse the repository at this point in the history
Use Github Actions for CI
  • Loading branch information
heyman authored Jan 22, 2021
2 parents 048bd90 + cb56d64 commit b000d5f
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 13 deletions.
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

0 comments on commit b000d5f

Please sign in to comment.