Skip to content
This repository was archived by the owner on Aug 28, 2025. It is now read-only.

Commit a875f79

Browse files
committed
fix cross-branch CLI
* use source CLI * extend list_dirs * add codecov config
1 parent 400dd2a commit a875f79

File tree

4 files changed

+71
-7
lines changed

4 files changed

+71
-7
lines changed

.actions/assistant.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -640,11 +640,17 @@ def _parse_package_name(pkg: str, keys: str = " <=>[]@", egg_name: str = "#egg="
640640
yaml.safe_dump(meta, stream=open(fmeta, "w"), sort_keys=False)
641641

642642
@staticmethod
643-
def list_dirs(folder: str = ".notebooks") -> str:
643+
def list_dirs(folder: str = "", include_file_ext: str = "") -> str:
644644
"""List all sub-folders in a given tree including any ipynb."""
645-
ipynbs = glob.glob(os.path.join(folder, "*.ipynb")) + glob.glob(os.path.join(folder, "**", "*.ipynb"))
646-
ipynbs = sorted(os.path.splitext(os.path.sep.join(p.split(os.path.sep)[1:]))[0] for p in ipynbs)
647-
return os.linesep.join(ipynbs)
645+
dirs = glob.glob(os.path.join(folder, "*" + include_file_ext))
646+
dirs += glob.glob(os.path.join(folder, "**", "*" + include_file_ext))
647+
if include_file_ext:
648+
_ignore_base_dir = lambda p: os.path.sep.join(p.split(os.path.sep)[1:]) # noqa: E731
649+
# Take the notebook as a folder (notebook are on teh same level as the raw tutorial file mix)
650+
dirs = [os.path.splitext(_ignore_base_dir(p))[0] for p in dirs]
651+
else:
652+
dirs = [p for p in dirs if os.path.isdir(p)]
653+
return os.linesep.join(sorted(dirs))
648654

649655

650656
if __name__ == "__main__":

.actions/git-diff-sync.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,30 @@ printf "Detect changes for: $1 >> $2\n\n"
66
b1="${1//'/'/'_'}"
77
printf "Branch alias: $b1\n"
88
# list all dirs in source branch
9-
python -c "import os, glob ; dirs = glob.glob('*') + glob.glob('*/**') ; dirs = sorted([p for p in dirs if os.path.isdir(p)]) ; print(os.linesep.join(dirs))" > "dirs-$b1.txt"
9+
python .actions/assistant.py list_dirs > "dirs-$b1.txt"
1010
cat "dirs-$b1.txt"
1111

1212
head=$(git rev-parse origin/$2)
1313
git diff --name-only $head --output=target-diff.txt
1414
printf "\nRaw changes:\n"
1515
cat target-diff.txt
16+
# transfer the source CLI version
17+
mkdir -p _TEMP
18+
cp -r .actions/ _TEMP/.actions/
1619

1720
git checkout $2
1821
b2="${2//'/'/'_'}"
1922
printf "Branch alias: $b2\n"
23+
# recover the original CLI
24+
#rm -rf .actions && mv _TEMP/.actions .actions
2025
# list all dirs in target branch
21-
python .actions/assistant.py list_dirs > "dirs-$b2.txt"
26+
python _TEMP/.actions/assistant.py list_dirs ".notebooks" --include_file_ext=".ipynb" > "dirs-$b2.txt"
2227
cat "dirs-$b2.txt"
2328

2429
printf "\n\n"
2530
git merge --ff -s resolve origin/$1
2631

27-
python .actions/assistant.py group-folders target-diff.txt --fpath_actual_dirs "['dirs-$b1.txt', 'dirs-$b2.txt']"
32+
python _TEMP/.actions/assistant.py group-folders target-diff.txt --fpath_actual_dirs "['dirs-$b1.txt', 'dirs-$b2.txt']"
2833
printf "\n\nChanged folders:\n"
2934
cat changed-folders.txt
3035
printf "\n\nDropped folders:\n"

.actions/test_cli.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"cmd,args",
1414
[
1515
("list_dirs", []),
16+
("list_dirs", [".", ".ipynb"]),
1617
("bash_render", [_PATH_DIR_SIMPLE]),
1718
("bash_test", [_PATH_DIR_SIMPLE]),
1819
# ("group_folders", [_PATH_SIMPLE]),

.codecov.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# see https://docs.codecov.io/docs/codecov-yaml
2+
# Validation check:
3+
# $ curl --data-binary @.codecov.yml https://codecov.io/validate
4+
5+
6+
# https://docs.codecov.io/docs/codecovyml-reference
7+
codecov:
8+
bot: "codecov-io"
9+
strict_yaml_branch: "yaml-config"
10+
require_ci_to_pass: yes
11+
notify:
12+
# after_n_builds: 2
13+
wait_for_ci: yes
14+
15+
coverage:
16+
precision: 0 # 2 = xx.xx%, 0 = xx%
17+
round: nearest # how coverage is rounded: down/up/nearest
18+
range: 40...100 # custom range of coverage colors from red -> yellow -> green
19+
status:
20+
# https://codecov.readme.io/v1.0/docs/commit-status
21+
project:
22+
default:
23+
target: 95% # specify the target coverage for each commit status
24+
threshold: 30% # allow this little decrease on project
25+
# https://github.com/codecov/support/wiki/Filtering-Branches
26+
# branches: master
27+
if_ci_failed: error
28+
# https://github.com/codecov/support/wiki/Patch-Status
29+
patch:
30+
default:
31+
threshold: 50% # allow this much decrease on patch
32+
changes: false
33+
34+
# https://docs.codecov.com/docs/github-checks#disabling-github-checks-patch-annotations
35+
github_checks:
36+
annotations: false
37+
38+
parsers:
39+
gcov:
40+
branch_detection:
41+
conditional: true
42+
loop: true
43+
macro: false
44+
method: false
45+
javascript:
46+
enable_partials: false
47+
48+
comment:
49+
layout: header, diff
50+
require_changes: false
51+
behavior: default # update if exists else create new
52+
# branches: *

0 commit comments

Comments
 (0)