@@ -23,13 +23,15 @@ jobs:
2323 fetch-depth : 0
2424 path : pr-branch
2525
26- # Checkout the master branch into a subdirectory
27- - name : Checkout master branch
26+ - name : Checkout local actions
2827 uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2928 with :
30- # When testing the scripts, comment out the "ref: master"
31- ref : master
32- path : master-branch
29+ ref : ${{ github.workflow_sha }}
30+ fetch-depth : 1
31+ sparse-checkout : .github/actions
32+ path : workflow-actions
33+ - name : Get mathlib-ci
34+ uses : ./workflow-actions/.github/actions/get-mathlib-ci
3335
3436 - name : Update the merge-conflict label
3537 run : |
7981 echo "Saving the changed files to 'changed_files.txt'..."
8082 git diff --name-only origin/${{ github.base_ref }}... | tee changed_files.txt
8183
84+ # Get all newly added files.
85+ echo "Checking for added files..."
86+ git diff --name-only --diff-filter A origin/${{ github.base_ref }}... | tee added_files.txt
87+
8288 # Get all files which were removed or renamed.
8389 echo "Checking for removed files..."
8490
@@ -152,13 +158,13 @@ jobs:
152158 printf 'currentHash=%s\n' "${currentHash}"
153159
154160 echo "Compute the counts for the HEAD of the PR"
155- python ../master-branch/scripts/ count-trans-deps.py "Mathlib/" > head.json
161+ python "${CI_SCRIPTS_DIR}/pr_summary/ count-trans-deps.py" "Mathlib/" > head.json
156162
157163 # Checkout the merge base
158164 git checkout "$(git merge-base master ${{ github.event.pull_request.head.sha }})"
159165
160166 echo "Compute the counts for the merge base"
161- python ../master-branch/scripts/ count-trans-deps.py "Mathlib/" > base.json
167+ python "${CI_SCRIPTS_DIR}/pr_summary/ count-trans-deps.py" "Mathlib/" > base.json
162168
163169 # switch back to the current branch: the `declarations_diff` script should be here
164170 git checkout "${currentHash}" --
@@ -173,12 +179,12 @@ jobs:
173179 PR="${{ github.event.pull_request.number }}"
174180 title="### PR summary"
175181
176- graphAndHighPercentReports=$(python ../master-branch/scripts/ import-graph-report.py base.json head.json changed_files.txt)
182+ graphAndHighPercentReports=$(python "${CI_SCRIPTS_DIR}/pr_summary/ import-graph-report.py" base.json head.json changed_files.txt)
177183
178184 echo "Produce import count comment"
179185 importCount=$(
180186 printf '%s\n' "${graphAndHighPercentReports}" | sed '/^Import changes exceeding/Q'
181- ../master-branch/scripts/ import_trans_difference.sh
187+ "${CI_SCRIPTS_DIR}/pr_summary/ import_trans_difference.sh"
182188 )
183189
184190 echo "Produce high percentage imports"
@@ -202,7 +208,7 @@ jobs:
202208 fi
203209
204210 echo "Compute Declarations' diff comment"
205- declDiff=$(../master-branch/scripts/ declarations_diff.sh)
211+ declDiff=$("${CI_SCRIPTS_DIR}/pr_summary/ declarations_diff.sh" )
206212 if [ "$(printf '%s' "${declDiff}" | wc -l)" -gt 15 ]
207213 then
208214 declDiff="$(printf '<details><summary>\n\n%s\n\n</summary>\n\n%s\n\n</details>\n' "#### Declarations diff" "${declDiff}")"
@@ -214,25 +220,40 @@ jobs:
214220 printf 'hashURL: %s' "${hashURL}"
215221
216222 echo "Compute technical debt changes"
217- techDebtVar="$(../master-branch/scripts/ technical-debt-metrics.sh pr_summary)"
223+ techDebtVar="$("${CI_SCRIPTS_DIR}/reporting/ technical-debt-metrics.sh" pr_summary)"
218224
219225 echo "Compute documentation reminder"
220226 workflowFilesChanged="$(grep '^\.github/workflows/' changed_files.txt || true)"
221227 if [ -n "${workflowFilesChanged}" ]
222228 then
223229 # Format each changed workflow path as a Markdown bullet: "- `path`"
224230 workflowFilesChangedMarkdown="$(sed "s|^|- \`|; s|\$|\`|" <<< "${workflowFilesChanged}")"
225- workflowDocsReminder="$(printf "### Workflow documentation reminder\nThis PR modifies files under \`.github/workflows/\`.\nPlease update \`docs/workflows.md\` if the workflow inventory, triggers, or behavior changed.\n\nModified workflow files:\n%s\n" "${workflowFilesChangedMarkdown}")"
231+ workflowDocsReminder="$(printf "### ⚠️ Workflow documentation reminder\nThis PR modifies files under \`.github/workflows/\`.\nPlease update \`docs/workflows.md\` if the workflow inventory, triggers, or behavior changed.\n\nModified workflow files:\n%s\n" "${workflowFilesChangedMarkdown}")"
226232 else
227233 workflowDocsReminder=""
228234 fi
229235
236+ echo "Compute scripts-location reminder"
237+ scriptsFilesAdded="$(grep '^scripts/' added_files.txt || true)"
238+ if [ -n "${scriptsFilesAdded}" ]
239+ then
240+ # Format each added scripts path as a Markdown bullet: "- `path`"
241+ scriptsFilesAddedMarkdown="$(sed "s|^|- \`|; s|\$|\`|" <<< "${scriptsFilesAdded}")"
242+ scriptsLocationReminder="$(printf "### ⚠️ Scripts folder reminder\nThis PR adds files under \`scripts/\`.\nPlease consider whether each added script belongs in this repository or in [\`leanprover-community/mathlib-ci\`](https://github.com/leanprover-community/mathlib-ci).\n\nA script belongs in **\`mathlib-ci\`** if it is a CI automation script that interacts with GitHub (e.g. managing labels, posting comments, triggering bots), runs from a trusted external checkout in CI, or requires access to secrets.\n\nA script belongs in **this repository** (\`scripts/\`) if it is a developer or maintainer tool to be run locally, a code maintenance or analysis utility, a style linting tool, or a data file used by the library's own linters.\n\nSee the [\`mathlib-ci\` README](https://github.com/leanprover-community/mathlib-ci) for more details.\n\nAdded scripts files:\n%s\n" "${scriptsFilesAddedMarkdown}")"
243+ else
244+ scriptsLocationReminder=""
245+ fi
246+
230247 # store in a file, to avoid "long arguments" error.
231248 printf '%s [%s](%s)%s\n\n%s\n\n---\n\n%s\n\n---\n\n%s\n' "${title}" "$(git rev-parse --short HEAD)" "${hashURL}" "${high_percentages}" "${importCount}" "${declDiff}" "${techDebtVar}" > please_merge_master.md
232249 if [ -n "${workflowDocsReminder}" ]
233250 then
234251 printf '\n\n---\n\n%s\n' "${workflowDocsReminder}" >> please_merge_master.md
235252 fi
253+ if [ -n "${scriptsLocationReminder}" ]
254+ then
255+ printf '\n\n---\n\n%s\n' "${scriptsLocationReminder}" >> please_merge_master.md
256+ fi
236257
237258 echo "Include any errors about removed or renamed files without deprecation,"
238259 echo "as well as errors about extraneous deprecated_module additions."
@@ -248,7 +269,7 @@ jobs:
248269 fi
249270
250271 cat please_merge_master.md
251- ../master-branch/scripts/ update_PR_comment.sh please_merge_master.md "${title}" "${PR}"
272+ "${CI_SCRIPTS_DIR}/pr_summary/ update_PR_comment.sh" please_merge_master.md "${title}" "${PR}"
252273
253274 - name : Update the file-removed label
254275 run : |
0 commit comments