Skip to content

Commit

Permalink
Save changes on Wed Apr 10 15:32:25 WIB 2024
Browse files Browse the repository at this point in the history
  • Loading branch information
goFrendiAsgard committed Apr 10, 2024
1 parent 25bc115 commit 6485e8c
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/_zrb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
Run-command:
runs-on: ubuntu-latest
container:
image: stalchmst/zrb:0.11.3
image: stalchmst/zrb:0.12.0
steps:
- name: Check out repository code
uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ keywords = []

[tool.poetry.dependencies]
python = ">=3.10.0,<4.0.0"
zrb = ">=0.11.2"
zrb = ">=0.12.0"

[tool.poetry.dev-dependencies]
flake8 = "~7.0.0"
Expand Down
19 changes: 9 additions & 10 deletions src/zrb_noto/lint.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
import os
from typing import Any

from zrb import Task, python_task, runner
from zrb import CmdTask, runner

from ._env import LOCAL_REPO_DIR_ENV
from ._group import noto_group
from ._helper import run_cmd_path

_CURRENT_DIR = os.path.dirname(__file__)


@python_task(
name="lint", group=noto_group, description="Lint code", envs=[LOCAL_REPO_DIR_ENV]
lint_noto = CmdTask(
name="lint",
group=noto_group,
description="Lint code",
envs=[LOCAL_REPO_DIR_ENV],
cmd_path=os.path.join(_CURRENT_DIR, "lint.sh"),
should_show_cmd=False,
should_print_cmd_result=False
)
async def lint_noto(*args: Any, **kwargs: Any):
task: Task = kwargs.get("_task")
await run_cmd_path(task, os.path.join(_CURRENT_DIR, "lint.sh"))


runner.register(lint_noto)
29 changes: 15 additions & 14 deletions src/zrb_noto/sync.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import os
from typing import Any, List, Optional
from typing import List, Optional

from zrb import Group, Task, python_task, runner
from zrb import Env, Group, Task, CmdTask, runner

from ._env import LOCAL_REPO_DIR_ENV, REMOTE_GIT_URL_ENV
from ._group import noto_group
from ._helper import run_cmd_path

_CURRENT_DIR = os.path.dirname(__file__)

Expand All @@ -16,24 +15,26 @@ def create_sync_noto_task(
ignore_error: bool = True,
upstreams: List[Task] = [],
) -> Task:
@python_task(
sync_noto = CmdTask(
name="sync",
group=group,
description="Sync noto",
upstreams=upstreams,
envs=[LOCAL_REPO_DIR_ENV, REMOTE_GIT_URL_ENV],
envs=[
LOCAL_REPO_DIR_ENV, REMOTE_GIT_URL_ENV,
Env(
name="IGNORE_ERROR",
os_name="",
default="1" if ignore_error else "0"
),
],
retry=retry,
cmd_path=os.path.join(_CURRENT_DIR, "sync.sh"),
should_show_cmd=False,
should_print_cmd_result=False
)
async def sync_noto(*args: Any, **kwargs: Any):
task: Task = kwargs.get("_task")
try:
await run_cmd_path(task, os.path.join(_CURRENT_DIR, "sync.sh"))
except Exception as e:
if not ignore_error:
raise e

return sync_noto


sync_noto = create_sync_noto_task(group=noto_group, ignore_error=False, retry=3)
sync_noto = create_sync_noto_task(group=noto_group, ignore_error=False, retry=2)
runner.register(sync_noto)
10 changes: 10 additions & 0 deletions src/zrb_noto/sync.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
set -e

if [ "${IGNORE_ERROR}" = "1" ]
then
# Define cleanup operations or override commands here
cleanup() {
exit 0 # Override the exit code
}
# Trap the EXIT signal
trap cleanup EXIT
fi

if [ ! -d "${LOCAL_REPO_DIR}" ]
then
echo "Local repository not found, cloning..."
Expand Down

0 comments on commit 6485e8c

Please sign in to comment.