Skip to content

Commit e2f0b81

Browse files
[cienet-private] Enable workflow checks for the primary working branches
1 parent 8a98414 commit e2f0b81

6 files changed

Lines changed: 60 additions & 14 deletions

File tree

.github/workflows/dag-check.yml

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

44
on:
55
pull_request:
6-
branches: [master]
6+
branch:
7+
- maxtext/dev/**
78
types: [opened, synchronize, edited]
89

910
push:

.github/workflows/pyink-check.yml

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

33
on:
44
pull_request:
5-
branches: [master]
5+
branch:
6+
- maxtext/dev/**
67
types: [opened, synchronize, edited]
78
push:
89
branches: [master]
910

11+
workflow_dispatch: {}
12+
1013
jobs:
1114
format_check:
1215
runs-on: ubuntu-latest

.github/workflows/pylint-check.yml

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

33
on:
44
pull_request:
5-
branches: [master]
5+
branch:
6+
- maxtext/dev/**
67
types: [opened, synchronize, edited]
78

89
push:
910
branches: [master]
1011

12+
workflow_dispatch: {}
13+
1114
jobs:
1215
linting_check:
1316
runs-on: ubuntu-latest
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
name: Require Checklist
22
on:
33
pull_request:
4+
branch:
5+
- maxtext/dev/**
46
types: [opened, edited, synchronize]
7+
8+
workflow_dispatch: {}
9+
510
jobs:
611
check_pr_body:
712
runs-on: ubuntu-latest
813
steps:
914
- uses: mheap/require-checklist-action@v2
1015
with:
11-
requireChecklist: false # If this is true and there are no checklists detected, the action will fail
16+
requireChecklist: false # If this is true and there are no checklists detected, the action will fail

.github/workflows/unit-test.yml

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

44
on:
55
pull_request:
6-
branches: [master]
6+
branch:
7+
- maxtext/dev/**
78
types: [opened, synchronize, edited]
89

910
push:

scripts/code-style.sh

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

3265
echo "Successfully clean up all codes."

0 commit comments

Comments
 (0)