@@ -17,19 +17,22 @@ jobs:
1717
1818 steps :
1919 - name : Checkout code
20- uses : actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
20+ uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2121 with :
2222 ref : ${{ github.event.pull_request.head.sha }}
2323 fetch-depth : 0
2424 path : pr-branch
2525
26- # Checkout the master branch into a subdirectory
27- - name : Checkout master branch
28- uses : actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
26+ - name : Checkout mathlib-ci
27+ 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+ repository : leanprover-community/mathlib-ci
30+ ref : 7c2dcf950607e48029aec2a614e840f2a14ae7e1
31+ fetch-depth : 1
32+ path : ci-tools
33+
34+ - name : Set up CI scripts paths
35+ uses : ./ci-tools/.github/actions/setup-ci-scripts
3336
3437 - name : Update the merge-conflict label
3538 run : |
6063 fi
6164
6265 - name : Set up Python
63- uses : actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1 .0
66+ uses : actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2 .0
6467 with :
6568 python-version : 3.12
6669
7982 echo "Saving the changed files to 'changed_files.txt'..."
8083 git diff --name-only origin/${{ github.base_ref }}... | tee changed_files.txt
8184
85+ # Get all newly added files.
86+ echo "Checking for added files..."
87+ git diff --name-only --diff-filter A origin/${{ github.base_ref }}... | tee added_files.txt
88+
8289 # Get all files which were removed or renamed.
8390 echo "Checking for removed files..."
8491
@@ -152,13 +159,13 @@ jobs:
152159 printf 'currentHash=%s\n' "${currentHash}"
153160
154161 echo "Compute the counts for the HEAD of the PR"
155- python ../master-branch/scripts/ count-trans-deps.py "Mathlib/" > head.json
162+ python "${CI_SCRIPTS_DIR}/pr_summary/ count-trans-deps.py" "Mathlib/" > head.json
156163
157164 # Checkout the merge base
158165 git checkout "$(git merge-base master ${{ github.event.pull_request.head.sha }})"
159166
160167 echo "Compute the counts for the merge base"
161- python ../master-branch/scripts/ count-trans-deps.py "Mathlib/" > base.json
168+ python "${CI_SCRIPTS_DIR}/pr_summary/ count-trans-deps.py" "Mathlib/" > base.json
162169
163170 # switch back to the current branch: the `declarations_diff` script should be here
164171 git checkout "${currentHash}" --
@@ -173,12 +180,12 @@ jobs:
173180 PR="${{ github.event.pull_request.number }}"
174181 title="### PR summary"
175182
176- graphAndHighPercentReports=$(python ../master-branch/scripts/ import-graph-report.py base.json head.json changed_files.txt)
183+ graphAndHighPercentReports=$(python "${CI_SCRIPTS_DIR}/pr_summary/ import-graph-report.py" base.json head.json changed_files.txt)
177184
178185 echo "Produce import count comment"
179186 importCount=$(
180187 printf '%s\n' "${graphAndHighPercentReports}" | sed '/^Import changes exceeding/Q'
181- ../master-branch/scripts/ import_trans_difference.sh
188+ "${CI_SCRIPTS_DIR}/pr_summary/ import_trans_difference.sh"
182189 )
183190
184191 echo "Produce high percentage imports"
@@ -202,7 +209,7 @@ jobs:
202209 fi
203210
204211 echo "Compute Declarations' diff comment"
205- declDiff=$(../master-branch/scripts/ declarations_diff.sh)
212+ declDiff=$("${CI_SCRIPTS_DIR}/pr_summary/ declarations_diff.sh" )
206213 if [ "$(printf '%s' "${declDiff}" | wc -l)" -gt 15 ]
207214 then
208215 declDiff="$(printf '<details><summary>\n\n%s\n\n</summary>\n\n%s\n\n</details>\n' "#### Declarations diff" "${declDiff}")"
@@ -214,10 +221,40 @@ jobs:
214221 printf 'hashURL: %s' "${hashURL}"
215222
216223 echo "Compute technical debt changes"
217- techDebtVar="$(../master-branch/scripts/technical-debt-metrics.sh pr_summary)"
224+ techDebtVar="$("${CI_SCRIPTS_DIR}/reporting/technical-debt-metrics.sh" pr_summary)"
225+
226+ echo "Compute documentation reminder"
227+ workflowFilesChanged="$(grep '^\.github/workflows/' changed_files.txt || true)"
228+ if [ -n "${workflowFilesChanged}" ]
229+ then
230+ # Format each changed workflow path as a Markdown bullet: "- `path`"
231+ workflowFilesChangedMarkdown="$(sed "s|^|- \`|; s|\$|\`|" <<< "${workflowFilesChanged}")"
232+ 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}")"
233+ else
234+ workflowDocsReminder=""
235+ fi
236+
237+ echo "Compute scripts-location reminder"
238+ scriptsFilesAdded="$(grep '^scripts/' added_files.txt || true)"
239+ if [ -n "${scriptsFilesAdded}" ]
240+ then
241+ # Format each added scripts path as a Markdown bullet: "- `path`"
242+ scriptsFilesAddedMarkdown="$(sed "s|^|- \`|; s|\$|\`|" <<< "${scriptsFilesAdded}")"
243+ 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\`.\n\nAdded scripts files:\n%s\n" "${scriptsFilesAddedMarkdown}")"
244+ else
245+ scriptsLocationReminder=""
246+ fi
218247
219248 # store in a file, to avoid "long arguments" error.
220249 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
250+ if [ -n "${workflowDocsReminder}" ]
251+ then
252+ printf '\n\n---\n\n%s\n' "${workflowDocsReminder}" >> please_merge_master.md
253+ fi
254+ if [ -n "${scriptsLocationReminder}" ]
255+ then
256+ printf '\n\n---\n\n%s\n' "${scriptsLocationReminder}" >> please_merge_master.md
257+ fi
221258
222259 echo "Include any errors about removed or renamed files without deprecation,"
223260 echo "as well as errors about extraneous deprecated_module additions."
@@ -233,7 +270,7 @@ jobs:
233270 fi
234271
235272 cat please_merge_master.md
236- ../master-branch/scripts/ update_PR_comment.sh please_merge_master.md "${title}" "${PR}"
273+ "${CI_SCRIPTS_DIR}/pr_summary/ update_PR_comment.sh" please_merge_master.md "${title}" "${PR}"
237274
238275 - name : Update the file-removed label
239276 run : |
0 commit comments