@@ -45,55 +45,75 @@ jobs:
45
45
fetch-depth : 0
46
46
persist-credentials : false
47
47
48
+ - name : Determine merge base
49
+ id : merge_base
50
+ env :
51
+ BASE_REF : ${{ github.event.pull_request.base.ref || 'main' }}
52
+ run : |
53
+ sha=$(git merge-base HEAD "origin/${BASE_REF}")
54
+ echo "sha=${sha}" >> "$GITHUB_OUTPUT"
55
+
48
56
- name : Check if the parser code changed
49
57
id : check_parser
58
+ env :
59
+ MERGE_BASE : ${{ steps.merge_base.outputs.sha }}
50
60
run : |
51
- if git diff --quiet ${{ github.event.pull_request.base.sha || 'origin/main' }} ...HEAD -- ':Cargo.toml' ':Cargo.lock' ':crates/ruff_python_trivia/**' ':crates/ruff_source_file/**' ':crates/ruff_text_size/**' ':crates/ruff_python_ast/**' ':crates/ruff_python_parser/**' ':python/py-fuzzer/**' ':.github/workflows/ci.yaml'; then
61
+ if git diff --quiet "${MERGE_BASE} ...HEAD" -- ':Cargo.toml' ':Cargo.lock' ':crates/ruff_python_trivia/**' ':crates/ruff_source_file/**' ':crates/ruff_text_size/**' ':crates/ruff_python_ast/**' ':crates/ruff_python_parser/**' ':python/py-fuzzer/**' ':.github/workflows/ci.yaml'; then
52
62
echo "changed=false" >> "$GITHUB_OUTPUT"
53
63
else
54
64
echo "changed=true" >> "$GITHUB_OUTPUT"
55
65
fi
56
66
57
67
- name : Check if the linter code changed
58
68
id : check_linter
69
+ env :
70
+ MERGE_BASE : ${{ steps.merge_base.outputs.sha }}
59
71
run : |
60
- if git diff --quiet ${{ github.event.pull_request.base.sha || 'origin/main' }} ...HEAD -- ':Cargo.toml' ':Cargo.lock' ':crates/**' ':!crates/red_knot*/**' ':!crates/ruff_python_formatter/**' ':!crates/ruff_formatter/**' ':!crates/ruff_dev/**' ':!crates/ruff_db/**' ':scripts/*' ':python/**' ':.github/workflows/ci.yaml'; then
72
+ if git diff --quiet "${MERGE_BASE} ...HEAD" -- ':Cargo.toml' ':Cargo.lock' ':crates/**' ':!crates/red_knot*/**' ':!crates/ruff_python_formatter/**' ':!crates/ruff_formatter/**' ':!crates/ruff_dev/**' ':!crates/ruff_db/**' ':scripts/*' ':python/**' ':.github/workflows/ci.yaml'; then
61
73
echo "changed=false" >> "$GITHUB_OUTPUT"
62
74
else
63
75
echo "changed=true" >> "$GITHUB_OUTPUT"
64
76
fi
65
77
66
78
- name : Check if the formatter code changed
67
79
id : check_formatter
80
+ env :
81
+ MERGE_BASE : ${{ steps.merge_base.outputs.sha }}
68
82
run : |
69
- if git diff --quiet ${{ github.event.pull_request.base.sha || 'origin/main' }} ...HEAD -- ':Cargo.toml' ':Cargo.lock' ':crates/ruff_python_formatter/**' ':crates/ruff_formatter/**' ':crates/ruff_python_trivia/**' ':crates/ruff_python_ast/**' ':crates/ruff_source_file/**' ':crates/ruff_python_index/**' ':crates/ruff_python_index/**' ':crates/ruff_text_size/**' ':crates/ruff_python_parser/**' ':scripts/*' ':python/**' ':.github/workflows/ci.yaml'; then
83
+ if git diff --quiet "${MERGE_BASE} ...HEAD" -- ':Cargo.toml' ':Cargo.lock' ':crates/ruff_python_formatter/**' ':crates/ruff_formatter/**' ':crates/ruff_python_trivia/**' ':crates/ruff_python_ast/**' ':crates/ruff_source_file/**' ':crates/ruff_python_index/**' ':crates/ruff_python_index/**' ':crates/ruff_text_size/**' ':crates/ruff_python_parser/**' ':scripts/*' ':python/**' ':.github/workflows/ci.yaml'; then
70
84
echo "changed=false" >> "$GITHUB_OUTPUT"
71
85
else
72
86
echo "changed=true" >> "$GITHUB_OUTPUT"
73
87
fi
74
88
75
89
- name : Check if the fuzzer code changed
76
90
id : check_fuzzer
91
+ env :
92
+ MERGE_BASE : ${{ steps.merge_base.outputs.sha }}
77
93
run : |
78
- if git diff --quiet ${{ github.event.pull_request.base.sha || 'origin/main' }} ...HEAD -- ':Cargo.toml' ':Cargo.lock' ':fuzz/fuzz_targets/**' ':.github/workflows/ci.yaml'; then
94
+ if git diff --quiet "${MERGE_BASE} ...HEAD" -- ':Cargo.toml' ':Cargo.lock' ':fuzz/fuzz_targets/**' ':.github/workflows/ci.yaml'; then
79
95
echo "changed=false" >> "$GITHUB_OUTPUT"
80
96
else
81
97
echo "changed=true" >> "$GITHUB_OUTPUT"
82
98
fi
83
99
84
100
- name : Check if there was any code related change
85
101
id : check_code
102
+ env :
103
+ MERGE_BASE : ${{ steps.merge_base.outputs.sha }}
86
104
run : |
87
- if git diff --quiet ${{ github.event.pull_request.base.sha || 'origin/main' }} ...HEAD -- ':**/*' ':!**/*.md' ':crates/red_knot_python_semantic/resources/mdtest/**/*.md' ':!docs/**' ':!assets/**' ':.github/workflows/ci.yaml'; then
105
+ if git diff --quiet "${MERGE_BASE} ...HEAD" -- ':**/*' ':!**/*.md' ':crates/red_knot_python_semantic/resources/mdtest/**/*.md' ':!docs/**' ':!assets/**' ':.github/workflows/ci.yaml'; then
88
106
echo "changed=false" >> "$GITHUB_OUTPUT"
89
107
else
90
108
echo "changed=true" >> "$GITHUB_OUTPUT"
91
109
fi
92
110
93
111
- name : Check if there was any playground related change
94
112
id : check_playground
113
+ env :
114
+ MERGE_BASE : ${{ steps.merge_base.outputs.sha }}
95
115
run : |
96
- if git diff --quiet ${{ github.event.pull_request.base.sha || 'origin/main' }} ...HEAD -- ':playground/**'; then
116
+ if git diff --quiet "${MERGE_BASE} ...HEAD" -- ':playground/**'; then
97
117
echo "changed=false" >> "$GITHUB_OUTPUT"
98
118
else
99
119
echo "changed=true" >> "$GITHUB_OUTPUT"
0 commit comments