Skip to content

Commit 86c0b86

Browse files
authored
[test] Setup CI with GitHub Actions (#8)
1 parent 353b7d2 commit 86c0b86

File tree

6 files changed

+56
-22
lines changed

6 files changed

+56
-22
lines changed

.flake8

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[flake8]
2+
ignore = W503,E203

.github/workflows/python-app.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# This workflow will install Python dependencies, run tests and lint with a single version of Python
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3+
4+
name: repobee-sanitizer
5+
6+
on:
7+
push:
8+
branches: [ master ]
9+
pull_request:
10+
branches: [ master ]
11+
12+
jobs:
13+
build:
14+
15+
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
python-version: [3.6, 3.7, 3.8]
19+
20+
steps:
21+
- uses: actions/checkout@v2
22+
- name: Set up Python ${{ matrix.python-version }}
23+
uses: actions/setup-python@v2
24+
with:
25+
python-version: ${{ matrix.python-version }}
26+
- name: Install dependencies
27+
run: |
28+
python -m pip install --upgrade pip
29+
pip install flake8 pytest
30+
pip install -e .[TEST]
31+
- name: Lint with flake8
32+
run: |
33+
# stop the build if there are Python syntax errors or undefined names
34+
flake8 . --count --show-source --statistics
35+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
36+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=79 --statistics
37+
- name: Test with pytest
38+
run: |
39+
pytest -vv tests/

repobee_sanitizer/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
2-
3-
from .__version import __version__
1+
from .__version import __version__ # noqa: F401

repobee_sanitizer/sanitizer.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
"""The plugin module for repobee-sanitizer.
22
33
.. module:: sanitizer
4-
:synopsis: A plugin for RepoBee to sanitize master repositories before being pushed to students.
4+
:synopsis: A plugin for RepoBee to sanitize master repositories before
5+
being pushed to students.
56
67
.. moduleauthor:: Simon Larsén
78
"""
89

9-
import pathlib
10-
import os
11-
12-
1310
import argparse
1411
import configparser
1512
from typing import List, Mapping, Optional
@@ -53,7 +50,9 @@ def _callback(
5350
# do whatever you want to do!
5451
return {
5552
PLUGIN_NAME: [
56-
plug.Result(name=PLUGIN_NAME, status=plug.Status.SUCCESS, msg=str(args))
53+
plug.Result(
54+
name=PLUGIN_NAME, status=plug.Status.SUCCESS, msg=str(args)
55+
)
5756
]
5857
}
5958

@@ -66,7 +65,9 @@ def config_hook(self, config_parser: configparser.ConfigParser) -> None:
6665
if PLUGIN_NAME not in config_parser:
6766
return
6867

69-
self._name = config_parser.get(PLUGIN_NAME, "name", fallback=self._name)
68+
self._name = config_parser.get(
69+
PLUGIN_NAME, "name", fallback=self._name
70+
)
7071
self._age = config_parser.get(PLUGIN_NAME, "age", fallback=self._age)
7172

7273
def create_extension_command(self) -> plug.ExtensionCommand:
@@ -99,4 +100,3 @@ def create_extension_command(self) -> plug.ExtensionCommand:
99100
plug.BaseParser.STUDENTS,
100101
],
101102
)
102-

setup.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@
55
readme = f.read()
66

77
# parse the version instead of importing it to avoid dependency-related crashes
8-
with open(
9-
"repobee_sanitizer/__version.py",
10-
mode="r",
11-
encoding="utf-8",
12-
) as f:
8+
with open("repobee_sanitizer/__version.py", mode="r", encoding="utf-8",) as f:
139
line = f.readline()
1410
__version__ = line.split("=")[1].strip(" '\"\n")
1511
assert re.match(r"^\d+(\.\d+){2}(-(alpha|beta|rc)(\.\d+)?)?$", __version__)
@@ -20,14 +16,13 @@
2016
setup(
2117
name="repobee-sanitizer",
2218
version=__version__,
23-
description="A plugin for RepoBee to sanitize master repositories before being pushed to students",
19+
description="A plugin for RepoBee to sanitize master repositories before "
20+
"being pushed to students",
2421
long_description=readme,
2522
long_description_content_type="text/markdown",
2623
author="Simon Larsén",
2724
author_email="[email protected]",
28-
url="https://github.com/"
29-
"repobee"
30-
"/repobee-sanitizer",
25+
url="https://github.com/" "repobee" "/repobee-sanitizer",
3126
download_url="https://github.com/"
3227
"repobee"
3328
"/repobee-sanitizer"

tests/test_file_sanitizer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ def read_valid_test_case_files(test_case_dir: pathlib.Path) -> Tuple[str, str]:
6666
"inp", INVALID_TEST_CASE_ARGS, ids=INVALID_TEST_CASE_IDS
6767
)
6868
def test_sanitize_invalid(inp: str):
69-
with pytest.Raises(plug.PlugError("Invalid marker syntax")):
70-
assert _sanitize_file.sanitize(inp)
69+
with pytest.raises(plug.PlugError):
70+
_sanitize_file.sanitize(inp)
7171

7272

7373
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)