Skip to content

Commit 2ede2e3

Browse files
authored
Merge branch 'mjs/eamxx/format-patch-in-summary' (PR #7674)
Give patch file unique name and provide text of short diffs in job summary [BFB]
2 parents a685cd4 + 416f2d7 commit 2ede2e3

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

.github/workflows/eamxx-gh-clang-format.yml

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,19 +108,44 @@ jobs:
108108
"execute \`git apply <patch-file>\` from your local E3SM " \
109109
"branch." >> "${GITHUB_STEP_SUMMARY}"
110110
echo "Then commit the changes and push to your remote branch." >> "${GITHUB_STEP_SUMMARY}"
111+
echo "" >> "${GITHUB_STEP_SUMMARY}"
112+
echo "For diffs with ***fewer than 10 files***, we also include the text of " \
113+
"the patch file in a collapsed section, below." >> "${GITHUB_STEP_SUMMARY}"
114+
if [[ $(wc -l < diffiles.txt) -lt 10 ]]; then
115+
echo "<details>" >> "${GITHUB_STEP_SUMMARY}"
116+
echo "" >> "${GITHUB_STEP_SUMMARY}"
117+
echo "<summary>" >> "${GITHUB_STEP_SUMMARY}"
118+
echo "### Contents of \`clang-format-patch.diff\`" >> "${GITHUB_STEP_SUMMARY}"
119+
echo "</summary>" >> "${GITHUB_STEP_SUMMARY}"
120+
echo "To apply this version of the patch, save the text to a local file, " \
121+
"and \`git apply <patch-file>\`, etc., as above." >> "${GITHUB_STEP_SUMMARY}"
122+
echo "" >> "${GITHUB_STEP_SUMMARY}"
123+
echo "\`\`\`" >> "${GITHUB_STEP_SUMMARY}"
124+
cat clang-format-patch.diff >> "${GITHUB_STEP_SUMMARY}"
125+
echo "\`\`\`" >> "${GITHUB_STEP_SUMMARY}"
126+
echo "" >> "${GITHUB_STEP_SUMMARY}"
127+
echo "</details>" >> "${GITHUB_STEP_SUMMARY}"
128+
fi
111129
else
112130
echo "status_fail=false" >> "${GITHUB_ENV}"
113131
echo "## Status: \`clang-format\` Check Passed!" > "${GITHUB_STEP_SUMMARY}"
114132
fi
115133
- name: diff format changes
116-
run: git diff > "components/eamxx/clang-format-patch.diff"
134+
run: |
135+
d_str=$(date +"%Y%m%d%H%M%S")
136+
fname="clang-format-patch_${{ github.event.pull_request.number || github.event_name }}-${d_str}.diff"
137+
echo "fname=${fname}" >> "${GITHUB_ENV}"
138+
git diff > "components/eamxx/${fname}"
139+
- name: debug diff
140+
run: |
141+
echo "${fname}"
142+
tail -10 "components/eamxx/${fname}"
117143
- name: upload diff patch
118144
if: ${{ env.status_fail == 'true' }}
119145
uses: actions/upload-artifact@v4
120146
with:
121-
name: clang-format-patch_${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.run_id }}.diff
122-
path: |
123-
components/eamxx/clang-format-patch.diff
147+
name: ${{ env.fname }}
148+
path: "components/eamxx/${{ env.fname }}"
124149
- name: return pass-fail status
125150
run: |
126151
if [[ ${status_fail} = true ]]; then

0 commit comments

Comments
 (0)