Skip to content

Commit

Permalink
Merge pull request #125 from MycroftAI/feature/github-actions
Browse files Browse the repository at this point in the history
Run unit tests in Github Actions
  • Loading branch information
forslund authored Apr 11, 2021
2 parents 4260a85 + 68b6f9b commit a8be482
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 25 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Python package

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python setup.py install
python -m pip install -r test-requirements.txt
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
# Code style checks disabled until the style of the project is set.
./run_tests.sh lint
- name: Test with pytest
run: |
./run_tests.sh test
11 changes: 0 additions & 11 deletions .travis.yml

This file was deleted.

22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,28 @@ def register_pandora_vocab(emitter):
for match in m.groups():
register_vocab('Pandora Station', match)
```

Development
===========

Glad you'd like to help!

To install test and development requirements run

```
pip install -r test-requirements.txt
```

This will install the test-requirements as well as the runtime requirements for adapt.

To test any changes before submitting them run

```
./run_tests.sh
```

This will run the same checks as the Github actions and verify that your code should pass with flying colours.

Learn More
========

Expand Down
13 changes: 0 additions & 13 deletions run_tests.py

This file was deleted.

40 changes: 40 additions & 0 deletions run_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#! /bin/bash

ADAPT_DIR=$(dirname $0)

do_lint () {
flake8 "${ADAPT_DIR}/adapt" --select=E9,F63,F7,F82 --show-source && \
flake8 "${ADAPT_DIR}/test" --select=E9,F63,F7,F82 --show-source
}

do_test () {
pytest "${ADAPT_DIR}/test/"*
}

show_help () {
echo "Tests for adapt."
echo "If no arguments are given, both test and linting is performed."
echo "Otherwise the argument will determine which part is performed."
echo ""
echo " Usage: $0 [test/lint]"
echo ""
echo "Arguments:"
echo " test: Only run the tests."
echo " lint: Only perform codestyle and static analysis."
}

if [[ $# == 0 ]]; then
do_lint || exit $? # Exit on failure
do_test || exit $? # Exit on failure
elif [[ $# == 1 ]]; then
if [[ $1 == "lint" ]]; then
do_lint
elif [[ $1 == "test" ]]; then
do_test
else
show_help
fi
else
show_help
fi

4 changes: 3 additions & 1 deletion test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
xmlrunner==1.7.7
flake8
pytest
-r requirements.txt

0 comments on commit a8be482

Please sign in to comment.