Skip to content

Commit 02b36a3

Browse files
authored
New scripts location and wiki upload (#6)
1 parent 275f0a0 commit 02b36a3

File tree

6 files changed

+40
-25
lines changed

6 files changed

+40
-25
lines changed

.github/workflows/main.yml

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ on: [push]
55
jobs:
66
test:
77
runs-on: ubuntu-20.04
8-
98
steps:
109
- uses: actions/checkout@v2
1110
- name: Set up Python
@@ -26,4 +25,29 @@ jobs:
2625
- name: Run unit tests
2726
run: >
2827
pipenv run python3 -m unittest discover -v homework_checker/tests/
28+
- name: Upload result md file
29+
uses: actions/upload-artifact@v2
30+
with:
31+
name: homework_result
32+
path: results.md
33+
upload_to_wiki:
34+
needs: test
35+
runs-on: ubuntu-20.04
36+
steps:
37+
- uses: actions/checkout@v2
38+
with:
39+
repository: ${{ github.repository }}.wiki
40+
path: wiki
41+
- name: Download result md file
42+
uses: actions/download-artifact@v2
43+
with:
44+
name: homework_result
45+
- run: |
46+
mv results.md wiki/Home.md
47+
cd wiki
48+
git config user.name github-actions
49+
git config user.email github-actions@github.com
50+
git add .
51+
git commit -m "generated"
52+
git push
2953

homework_checker/check_homework.py renamed to check_homework.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import argparse
44
import logging
55

6-
from .checker import Checker
7-
from .md_writer import MdWriter
6+
from homework_checker.checker import Checker
7+
from homework_checker.md_writer import MdWriter
88

99

1010
logging.basicConfig()

homework_checker/__init__.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +0,0 @@
1-
"""Homework checker module."""
2-
3-
name = "homework_checker"
4-
5-
__all__ = (
6-
"check_homework",
7-
"checker",
8-
"md_writer",
9-
"schema_manager",
10-
"schema_tags",
11-
"tasks" "tools" "tests",
12-
)

homework_checker/tests/__init__.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +0,0 @@
1-
"""These are the tests for the package."""
2-
3-
__all__ = ("test_checker", "test_task", "test_tools")

homework_checker/tests/test_checker.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
import unittest
66

7+
from pathlib import Path
78
from homework_checker.checker import Checker
9+
from homework_checker.md_writer import MdWriter
810
from homework_checker import tools
911

1012

@@ -37,3 +39,7 @@ def test_everything(self: TestChecker):
3739
self.assertIn("Return number task", results["Homework where things go wrong"])
3840
self.assertIn("While loop task", results["Homework where things go wrong"])
3941
self.assertNotIn("Non existing task", results["Homework where things go wrong"])
42+
43+
writer = MdWriter()
44+
writer.update(results)
45+
writer.write_md_file(Path("results.md"))

homework_checker/print_repo_name.py renamed to print_repo_name.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
"""A script to parse an input git url and get it's wiki counterpart.
33
44
Attributes:
5-
wiki_repo_mask (str): mask of wiki git repo
5+
WIKI_REPO_MASK (str): mask of wiki git repo
66
"""
77
import sys
88

9-
from .tools import parse_git_url
9+
from homework_checker.tools import parse_git_url
1010

11-
wiki_repo_mask = "git@{domain}:{user}/{project}.wiki.git"
12-
repo_mask = "git@{domain}:{user}/{project}.git"
11+
WIKI_REPO_MASK = "git@{domain}:{user}/{project}.wiki.git"
12+
REPO_MASK = "git@{domain}:{user}/{project}.git"
1313

1414

1515
def main():
@@ -30,15 +30,15 @@ def main():
3030
type="code",
3131
)
3232
)
33-
exit(1)
33+
sys.exit(1)
3434
if len(sys.argv) == 3:
3535
repo = sys.argv[1]
3636
domain, user, project = parse_git_url(repo)
3737
repo_type = sys.argv[2]
3838
if repo_type == "wiki":
39-
print(wiki_repo_mask.format(domain=domain, user=user, project=project))
39+
print(WIKI_REPO_MASK.format(domain=domain, user=user, project=project))
4040
elif repo_type == "code":
41-
print(repo_mask.format(domain=domain, user=user, project=project))
41+
print(REPO_MASK.format(domain=domain, user=user, project=project))
4242
else:
4343
print('ERROR: type "{}" is not "wiki" or "code"'.format(repo_type))
4444

0 commit comments

Comments
 (0)