Skip to content

Commit

Permalink
add test coverage for both local and GH action
Browse files Browse the repository at this point in the history
  • Loading branch information
merlinran committed Dec 8, 2021
1 parent b411e28 commit ae91a61
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 6 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ concurrency:

jobs:
test:
runs-on: "ubuntu-latest"
# To push new image: docker build . -t merlinran/acorn_docker --platform linux/amd64 && docker push merlinran/acorn_docker
runs-on: ubuntu-latest
# To create and push new image: docker buildx build -t merlinran/acorn_docker --platform linux/amd64,linux/arm64 --push .
container: docker://merlinran/acorn_docker:latest
strategy:
fail-fast: true
Expand All @@ -19,4 +19,7 @@ jobs:
uses: actions/checkout@v2

- name: Run tests
run: pytest
run: coverage run -m pytest

- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v1
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
**/__pycache__
**/*.swp
**/*.pyc
.coverage
error_log.txt
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ RUN apk add tmux vim mercurial
RUN python3 -m pip install adafruit-circuitpython-mcp230xx coloredlogs
RUN apk add iw
RUN apk add raspberrypi; exit 0 # Only succeeds on raspberry pi but not needed otherwise.
RUN python3 -m pip install pytest
RUN python3 -m pip install pytest coverage[toml]
RUN apk add --no-cache bash # required by codecov GH action
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[tool.coverage.run]
relative_files = true

[tool.pytest.ini_options]
minversion = "6.0"
addopts = "-ra -q"
Expand Down
2 changes: 1 addition & 1 deletion run_docker_test.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
docker-compose -f docker-compose-test.yml up --remove-orphans -d
docker exec -it acorn_vehicle pytest --log-cli-level DEBUG
docker exec -it acorn_vehicle sh -c 'coverage run -m pytest --log-cli-level DEBUG && coverage report --skip-covered --skip-empty'
2 changes: 1 addition & 1 deletion vehicle/remote_control_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ def run_once(self):
raise(e)

if not isinstance(recieved_robot_object, model.Robot):
self.logger.info("%s" % type(recieved_robot_object))
self.logger.info("Got unexpected type {}".format(type(recieved_robot_object)))
self.logger.info("Waiting for valid robot object before running remote control code.")
time.sleep(_SLOW_POLLING_SLEEP_S)
return
Expand Down

0 comments on commit ae91a61

Please sign in to comment.