Repository: turettn/fastapi_offline (language: python)

Issue:
Add CI
GitHub actions could be used to add CI for future commits and PRs. There is a Python-specific action that does most of the initial setup needed: https://github.com/marketplace/actions/setup-python


Discussion / hints:

Fix patch:
diff --git a/.coverage b/.coverage
new file mode 100644
index 0000000..c703031
Binary files /dev/null and b/.coverage differ
diff --git a/.flake8 b/.flake8
new file mode 100644
index 0000000..2bcd70e
--- /dev/null
+++ b/.flake8
@@ -0,0 +1,2 @@
+[flake8]
+max-line-length = 88
diff --git a/.gitignore b/.gitignore
index ed7545f..a200eec 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,4 +2,6 @@
 /fastapi_offline/static/*
 build/
 dist/
-*/__pycache__/
\ No newline at end of file
+*/__pycache__/
+coverage.xml
+venv/
\ No newline at end of file
diff --git a/.mypy.ini b/.mypy.ini
new file mode 100644
index 0000000..b1efbe8
--- /dev/null
+++ b/.mypy.ini
@@ -0,0 +1,2 @@
+[mypy]
+strict = True
diff --git a/README.md b/README.md
index e583b3e..f5cd640 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,8 @@
 # Overview
 
 [![](https://img.shields.io/pypi/v/fastapi-offline.svg)](https://pypi.python.org/pypi/fastapi-offline/)
+[![Test](https://github.com/turettn/fastapi_offline/actions/workflows/test.yml/badge.svg)](https://github.com/turettn/fastapi_offline/actions/workflows/test.yml)
+[![codecov](https://codecov.io/gh/turettn/fastapi_offline/branch/main/graph/badge.svg)](https://codecov.io/gh/turettn/fastapi_offline)
 
 [FastAPI](https://fastapi.tiangolo.com/) is awesome, but the documentation pages (Swagger or Redoc) all depend on external CDNs, which is problematic if you want to run on disconnected networks.
 
diff --git a/fastapi_offline/core.py b/fastapi_offline/core.py
index f28d305..7976c2e 100644
--- a/fastapi_offline/core.py
+++ b/fastapi_offline/core.py
@@ -10,7 +10,7 @@
 from fastapi.staticfiles import StaticFiles
 
 if TYPE_CHECKING:
-    from fastapi import Response
+    from fastapi import Response  # pragma: no cover
 
 _STATIC_PATH = Path(__file__).parent / "static"
 


Test patch:
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
new file mode 100644
index 0000000..50de19c
--- /dev/null
+++ b/.github/workflows/test.yml
@@ -0,0 +1,42 @@
+name: Test
+
+on:
+  push:
+  pull_request:
+    types: [opened, synchronize]
+
+jobs:
+  test:
+    runs-on: ubuntu-latest
+    strategy:
+      matrix:
+        python-version: [3.6, 3.7, 3.8]
+      fail-fast: false
+    
+    steps:
+      - uses: actions/checkout@v2
+      - name: Set up Python
+        uses: actions/setup-python@v2
+        with:
+          python-version: ${{ matrix.python-version }}
+      - name: Install Dependencies
+        run: pip install flit
+      - name: Install package, dependencies, and test tools
+        run: |
+          python setup.py sdist
+          python -m pip install dist/*.tar.gz
+          python -m pip install pytest pytest-cov flake8 black mypy
+      - name: Check black compliance
+        run : |
+          black --check fastapi_offline
+      - name: Run linters
+        run : |
+          flake8 fastapi_offline
+          mypy fastapi_offline
+      - name: Run unit tests
+        run: |
+          pytest tests --cov=fastapi_offline --cov-report=term-missing --cov-report=xml
+      - name: Upload coverage
+        uses: codecov/codecov-action@v1
+        with:
+          token: ${{ secrets.CODECOV_TOKEN }}
\ No newline at end of file