-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from Svtter:feat/task-api
add task api. Feat.
- Loading branch information
Showing
7 changed files
with
83 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
checker | ||
======== | ||
|
||
用于检查 git 仓库是否干净。 | ||
|
||
Usage | ||
------ | ||
|
||
.. code-block:: python | ||
from easybuilder.checker import check_clean | ||
check_clean() # 检查 git 仓库是否干净 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
API | ||
===== | ||
|
||
.. toctree:: | ||
:maxdepth: 2 | ||
|
||
task | ||
checker |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Task | ||
====== | ||
|
||
We create task api to define the task of easybuilder. | ||
|
||
预定义的 task 是 :class:`CheckCleanTask`。如果想要替换预定义的 task,可以修改 Worker 的 ``default_tasks``。 | ||
|
||
Usage | ||
----------- | ||
|
||
如果想要定义自己的 task,可以通过以下方式进行。 | ||
|
||
.. code-block:: python | ||
from easybuilder.task import Task | ||
class MyTask(Task): | ||
pass | ||
class MyWorker(Worker): | ||
prev_tasks = [MyTask] | ||
def main(self): | ||
pass | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,4 +23,5 @@ Install easybuilder | |
:caption: Contents: | ||
|
||
usage | ||
api/index | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import abc | ||
import os | ||
|
||
from easybuilder.checker import check_clean | ||
|
||
|
||
class Task(abc.ABC): | ||
@abc.abstractmethod | ||
def action(self): | ||
pass | ||
|
||
|
||
class PdmLockTask(Task): | ||
"""test if pdm.lock is latest""" | ||
|
||
def action(self): | ||
ret = os.system("pdm lock --check") | ||
if ret != 0: | ||
print("pdm.lock is not up to date, please run 'pdm lock' first") | ||
exit(1) | ||
|
||
|
||
class CheckCleanTask(Task): | ||
"""check if git repo is clean""" | ||
|
||
def action(self): | ||
check_clean() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters