Skip to content

Commit

Permalink
Add test setup for new baselines (#665)
Browse files Browse the repository at this point in the history
Co-authored-by: Pedro Porto Buarque de Gusmão <[email protected]>
  • Loading branch information
tanertopal and pedropgusmao authored Mar 8, 2021
1 parent d440891 commit 3fc784d
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 3 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/baselines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Test Baselines

on:
push:
branches:
- main
pull_request:
branches:
- main

defaults:
run:
working-directory: baselines

jobs:
test:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8.3
- name: Install build tools
run: |
python -m pip install -U pip==21.0.1
python -m pip install -U setuptools==49.3.1
python -m pip install -U poetry==1.0.10
poetry config virtualenvs.create false
- name: Install dependencies
run: |
python -m poetry install
- name: Lint + Test (isort/black/mypy/pylint/pytest)
run: ./dev/test.sh
7 changes: 7 additions & 0 deletions baselines/dev/format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
set -e
cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"/../

python -m isort flwr_baselines
python -m black -q flwr_baselines
python -m docformatter -i -r flwr_baselines
12 changes: 12 additions & 0 deletions baselines/dev/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
set -e
cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"/../

echo "=== test.sh ==="

python -m isort --check-only flwr_baselines && echo "- isort: done" &&
python -m black --check flwr_baselines && echo "- black: done" &&
python -m mypy flwr_baselines && echo "- mypy: done" &&
python -m pylint flwr_baselines && echo "- pylint: done" &&
python -m pytest --durations=0 -v flwr_baselines && echo "- pytest: done" &&
echo "- All Python checks passed"
18 changes: 18 additions & 0 deletions baselines/flwr_baselines/example_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"""Placeholder to ensure test setup is working correctly.
Should be removed when first real code has tests.
"""

import unittest


class TestStringMethods(unittest.TestCase):
"""Test string methods."""

def test_upper(self):
"""Testing upper method."""
self.assertEqual("foo".upper(), "FOO")


if __name__ == "__main__":
unittest.main()
6 changes: 3 additions & 3 deletions baselines/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ classifiers = [
]

[tool.poetry.dependencies]
python = "^3.8.6"
python = "^3.8.3"
# Mandatory dependencies
flwr = "^0.14.0" # For development: { path = "../../", develop = true }
torch = "^1.7.1"
torchvision = "^0.8.1"
torch = "^1.8.0"
torchvision = "^0.9.0"

[tool.poetry.dev-dependencies]
isort = "==5.7.0"
Expand Down

0 comments on commit 3fc784d

Please sign in to comment.