Skip to content

Commit 71b8d8a

Browse files
[cienet-private] Enable workflow checks for the primary working branches
1 parent 7f2b30d commit 71b8d8a

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
@@ -22,14 +22,37 @@ FOLDERS_TO_FORMAT=("dags" "xlml")
2222
echo "[code-style] Running Semgrep static analysis..."
2323
semgrep --config scripts/semgrep-rules.yaml --error
2424

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

3558
echo "Successfully clean up all codes."

0 commit comments

Comments
 (0)