Skip to content

Commit 83f8b37

Browse files
[cienet-private] Enable workflow checks for the primary working branches
1 parent f361f4b commit 83f8b37

6 files changed

Lines changed: 40 additions & 14 deletions

File tree

.github/workflows/dag-check.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ name: DAG Check
33

44
on:
55
pull_request:
6-
branches: [master]
76
types: [opened, synchronize, edited]
87

98
push:

.github/workflows/pyink-check.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ name: Formatter
22

33
on:
44
pull_request:
5-
branches: [master]
65
types: [opened, synchronize, edited]
76
push:
87
branches: [master]
98

9+
workflow_dispatch: {}
10+
1011
jobs:
1112
format_check:
1213
runs-on: ubuntu-latest

.github/workflows/pylint-check.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ name: Linter
22

33
on:
44
pull_request:
5-
branches: [master]
65
types: [opened, synchronize, edited]
76

87
push:
98
branches: [master]
109

10+
workflow_dispatch: {}
11+
1112
jobs:
1213
linting_check:
1314
runs-on: ubuntu-latest

.github/workflows/require-checklist.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@ name: Require Checklist
22
on:
33
pull_request:
44
types: [opened, edited, synchronize]
5+
6+
workflow_dispatch: {}
7+
58
jobs:
69
check_pr_body:
710
runs-on: ubuntu-latest
811
steps:
912
- uses: mheap/require-checklist-action@v2
1013
with:
11-
requireChecklist: false # If this is true and there are no checklists detected, the action will fail
14+
requireChecklist: false # If this is true and there are no checklists detected, the action will fail

.github/workflows/unit-test.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ name: Unit Test
33

44
on:
55
pull_request:
6-
branches: [master]
76
types: [opened, synchronize, edited]
87

98
push:

scripts/code-style.sh

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,37 @@ set -e
1919

2020
FOLDERS_TO_FORMAT=("dags" "xlml")
2121

22-
for folder in "${FOLDERS_TO_FORMAT[@]}"
23-
do
24-
pyink "$folder" --pyink-indentation=2 --pyink-use-majority-quotes --line-length=80 --check --diff
25-
done
26-
27-
for folder in "${FOLDERS_TO_FORMAT[@]}"
28-
do
29-
pylint "./$folder" --fail-under=9.6
30-
done
22+
HEAD_SHA="$(git rev-parse HEAD)"
23+
BASE_BRANCH="dev"
24+
25+
if ! git rev-parse --verify "$BASE_BRANCH" >/dev/null 2>&1; then
26+
git fetch origin "$BASE_BRANCH":"$BASE_BRANCH" || {
27+
echo "[code-style] base branch '$BASE_BRANCH' not found, skip diff-based check."
28+
exit 0
29+
}
30+
fi
31+
32+
CHANGED_PY_FILES="$(
33+
git diff --name-only --diff-filter=ACM "${BASE_BRANCH}" "${HEAD_SHA}" \
34+
| grep '\.py$' \
35+
| while read -r f; do
36+
for folder in "${FOLDERS_TO_FORMAT[@]}"; do
37+
if [[ "$f" == "$folder/"* ]]; then
38+
echo "$f"
39+
break
40+
fi
41+
done
42+
done \
43+
| sort -u
44+
)"
45+
46+
if [[ -z "${CHANGED_PY_FILES}" ]]; then
47+
echo "[pre-push hook] no changed files detected between ${HEAD_SHA} and ${BASE_BRANCH}"
48+
exit 1
49+
fi
50+
51+
pyink ${CHANGED_PY_FILES} --pyink-indentation=2 --pyink-use-majority-quotes --line-length=80 --check --diff
52+
53+
pylint ${CHANGED_PY_FILES} --fail-under=9.6 --disable=E1123
3154

3255
echo "Successfully clean up all codes."

0 commit comments

Comments
 (0)