33 pull_request :
44 branches :
55 - " main"
6- - " refactor"
76 paths-ignore :
87 - " docs/**"
98 - " **.md"
@@ -21,8 +20,44 @@ concurrency:
2120 cancel-in-progress : true
2221
2322jobs :
23+ detect_changes :
24+ runs-on : ubuntu-latest
25+ outputs :
26+ only_rl : ${{ steps.filter.outputs.only_rl }}
27+ steps :
28+ - uses : actions/checkout@v3
29+ with :
30+ fetch-depth : 0
31+ - id : filter
32+ name : Detect changed paths
33+ run : |
34+ if ! changed_files="$(git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}" 2>/dev/null)"; then
35+ changed_files="$(git diff --name-only HEAD^1 HEAD)"
36+ fi
37+ only_rl=true
38+
39+ if [ -z "$changed_files" ]; then
40+ only_rl=false
41+ else
42+ while IFS= read -r file; do
43+ case "$file" in
44+ xtuner/v1/rl/*)
45+ ;;
46+ *)
47+ only_rl=false
48+ break
49+ ;;
50+ esac
51+ done <<< "$changed_files"
52+ fi
53+
54+ echo "$changed_files"
55+ echo "only_rl=$only_rl"
56+ echo "only_rl=$only_rl" >> "$GITHUB_OUTPUT"
57+
2458 lint :
2559 runs-on : ubuntu-latest
60+ needs : detect_changes
2661 steps :
2762 - uses : actions/checkout@v2
2863 - name : Set up Python 3.12
@@ -34,11 +69,19 @@ jobs:
3469 pip install pre-commit
3570 pre-commit install
3671 - name : Linting
37- run : pre-commit run --files $(find xtuner/v1)
72+ run : |
73+ if [ "${{ needs.detect_changes.outputs.only_rl }}" = "true" ]; then
74+ lint_target="xtuner/v1/rl"
75+ else
76+ lint_target="xtuner/v1"
77+ fi
78+ pre-commit run --files $(find "$lint_target" -type f)
3879
3980 unit_test :
4081 runs-on : [h_cluster]
41- needs : lint
82+ needs :
83+ - detect_changes
84+ - lint
4285 steps :
4386 - name : mask env
4487 run : |
5093 - name : unit-test
5194 run : |
5295 export PYTHONPYCACHEPREFIX=/tmp
53- python ci/scripts/xtuner_unittest.py "$IMAGE_INNER/$IMAGE" "source ${{env.WORKSPACE_PREFIX}}/BASE_ENV.sh;source ci/scripts/CI_ENV.sh" "pytest tests"
96+ if [ "${{ needs.detect_changes.outputs.only_rl }}" = "true" ]; then
97+ test_target="tests/rl"
98+ else
99+ test_target="tests"
100+ fi
101+ echo "test_target=$test_target"
102+ python ci/scripts/xtuner_unittest.py "$IMAGE_INNER/$IMAGE" "source ${{env.WORKSPACE_PREFIX}}/BASE_ENV.sh;source ci/scripts/CI_ENV.sh" "pytest $test_target"
0 commit comments