@@ -22,6 +22,11 @@ concurrency:
2222 group : conda-update-${{ github.event.workflow_run.head_sha || github.ref }}
2323 cancel-in-progress : false
2424
25+ # #2030: one Discussions category holds every report with no pull request to
26+ # comment on, one thread per job; cron-vendor.yml's `discussion` job says more.
27+ env :
28+ REPORT_CATEGORY : CI reports
29+
2530jobs :
2631 # #1967: the test gate on the schedule, `verdict` on a `workflow_run`;
2732 # shared with Vendor Update and GitHub Pages.
@@ -95,9 +100,13 @@ jobs:
95100 # (#1643). An unreadable package keeps its pin, as does a pin no release
96101 # can move to (#2025) and a pin whose own release has lost a wheel while
97102 # an older one still qualifies (#2028), and each warns, as does a pin past
98- # its review-by date; none fails the step.
103+ # its review-by date; none fails the step. The log keeps those lines for
104+ # the run report (#2030); `pipefail`, so `tee` cannot hide the script's
105+ # own exit status.
99106 - name : Refresh the platform pins
100- run : python util/conda_vendor.py --refresh-pins
107+ run : |
108+ set -o pipefail
109+ python util/conda_vendor.py --refresh-pins | tee "$RUNNER_TEMP/platform-pins.log"
101110
102111 - name : Setup Conda Distribution
103112 run : |
@@ -228,6 +237,67 @@ jobs:
228237 echo "PCAPKIT_BUILD=$(cat conda/build)"
229238 } >> "$GITHUB_OUTPUT"
230239
240+ # #2030: the run's outcome for the `discussion` job to post: what the pin
241+ # refresh moved or warned about, the files the run changed, and the build
242+ # it pushed. `status=warning` where a pin warned, which is what needs a
243+ # hand. `continue-on-error` on both, so a report never fails the bump.
244+ - name : Write the run report
245+ id : run-report
246+ if : ${{ !cancelled() }}
247+ continue-on-error : true
248+ env :
249+ FILES_CHANGED : ${{ steps.verify-changed-files.outputs.files_changed }}
250+ CHANGED_FILES : ${{ steps.verify-changed-files.outputs.changed_files }}
251+ PUSH : ${{ steps.push-changes.outcome }}
252+ COMMIT : ${{ steps.push-changes.outputs.commit }}
253+ run : |
254+ pins="$RUNNER_TEMP/platform-pins.log"
255+ if grep -q '^::warning title=Platform pins::' "$pins" 2> /dev/null; then
256+ echo "status=warning" >> "$GITHUB_OUTPUT"
257+ else
258+ echo "status=success" >> "$GITHUB_OUTPUT"
259+ fi
260+ {
261+ echo '### Conda Update'
262+ echo
263+ if [ ! -f "$pins" ]; then
264+ echo '- Platform pins: not refreshed, as the job stopped first'
265+ elif grep -q '^::[a-z]* title=Platform pins::' "$pins"; then
266+ echo '- Platform pins:'
267+ # The workflow command's data escapes, undone; `%25` last.
268+ grep '^::[a-z]* title=Platform pins::' "$pins" |
269+ sed -e 's/^::\([a-z]*\) title=Platform pins::/ - \1: /' \
270+ -e 's/%0D//g' -e 's/%0A/ /g' -e 's/%25/%/g'
271+ else
272+ echo '- Platform pins: none moved, and none warned'
273+ fi
274+ if [ "$FILES_CHANGED" = true ]; then
275+ echo "- Changed: $CHANGED_FILES"
276+ elif [ "$FILES_CHANGED" = false ]; then
277+ echo '- Changed: nothing, so no build was bumped'
278+ fi
279+ # `commit` is written only beside `pushed=true`.
280+ if [ -n "$COMMIT" ]; then
281+ echo "- Pushed: build $(cat conda/build) as $COMMIT"
282+ elif [ "$PUSH" = success ]; then
283+ echo "- Pushed: nothing; Push Changes' notice says why"
284+ elif [ "$PUSH" = failure ]; then
285+ echo '- Pushed: nothing, as Push Changes failed'
286+ elif [ "$FILES_CHANGED" != false ]; then
287+ echo '- Pushed: nothing, as the job stopped first'
288+ fi
289+ } > "$RUNNER_TEMP/conda-report.md"
290+ cat "$RUNNER_TEMP/conda-report.md"
291+
292+ - name : Upload the run report
293+ if : ${{ !cancelled() }}
294+ continue-on-error : true
295+ uses : actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
296+ with :
297+ name : conda-report
298+ path : ${{ runner.temp }}/conda-report.md
299+ retention-days : 14
300+
231301 outputs :
232302 # Not `files_changed`: see Push Changes above.
233303 CONDA_CHANGED : ${{ steps.push-changes.outputs.pushed }}
@@ -237,6 +307,8 @@ jobs:
237307 PCAPKIT_CONDA_LABEL : ${{ steps.get_version.outputs.PCAPKIT_CONDA_LABEL }}
238308 PCAPKIT_BUILD : ${{ steps.get_version.outputs.PCAPKIT_BUILD }}
239309 PYTHON_CONDA : ${{ steps.python-versions.outputs.conda }}
310+ # #2030: `warning` where a platform pin warned without failing the job.
311+ status : ${{ steps.run-report.outputs.status }}
240312
241313 conda-tag :
242314 # See create-release.yml: "(update)" keeps this apart from the Conda Tag job
@@ -557,3 +629,77 @@ jobs:
557629 omitPrereleaseDuringUpdate : true
558630 tag : " v${{ needs.conda-update.outputs.PCAPKIT_VERSION }}"
559631 token : " ${{ secrets.GITHUB_TOKEN }}"
632+
633+ # #2030: posts `conda-update`'s report with the tag and upload results, and a
634+ # short one of its own where `head` failed or was cancelled, as cron-vendor.yml's
635+ # `discussion` job does, whose comment gives the rules. It waits for
636+ # `conda-dist`, so the report says whether the build reached Anaconda.
637+ discussion :
638+ name : Post the conda report
639+ needs : [ head, conda-update, conda-tag, conda-dist ]
640+ if : >-
641+ ${{ always() && (needs.conda-update.result != 'skipped' ||
642+ needs.head.result == 'failure' || needs.head.result == 'cancelled') }}
643+ runs-on : ubuntu-latest
644+ timeout-minutes : 10
645+ continue-on-error : true
646+ permissions :
647+ contents : read
648+ discussions : write
649+ steps :
650+ - uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
651+ with :
652+ persist-credentials : false
653+
654+ # A run that never wrote a report uploaded none; the script then warns.
655+ - name : Download the report
656+ if : needs.conda-update.result != 'skipped'
657+ continue-on-error : true
658+ uses : actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
659+ with :
660+ name : conda-report
661+ path : report
662+
663+ # As cron-vendor.yml's: a `workflow_run` posts as a push run, the
664+ # schedule every run. A failed tag or upload fails the report too, and a
665+ # green `conda-update` that warned reports `warning`.
666+ - name : Post the report to Discussions
667+ continue-on-error : true
668+ env :
669+ GH_TOKEN : ${{ github.token }}
670+ MODE : ${{ github.event_name == 'workflow_run' && 'push' || 'scheduled' }}
671+ HEAD_RESULT : ${{ needs.head.result }}
672+ UPDATE_RESULT : ${{ needs.conda-update.result }}
673+ UPDATE_STATUS : ${{ needs.conda-update.outputs.status }}
674+ TAG_RESULT : ${{ needs.conda-tag.result }}
675+ DIST_RESULT : ${{ needs.conda-dist.result }}
676+ run : |
677+ if [ "$UPDATE_RESULT" = skipped ]; then
678+ status="$HEAD_RESULT"
679+ mkdir -p report
680+ {
681+ echo '### Conda Update'
682+ echo
683+ echo "- Gate: $HEAD_RESULT, so conda-update did not run and nothing was built or pushed"
684+ } > report/conda-report.md
685+ else
686+ if [ "$UPDATE_RESULT" != success ]; then
687+ status="$UPDATE_RESULT"
688+ elif [ "$TAG_RESULT" = failure ] || [ "$DIST_RESULT" = failure ]; then
689+ status=failure
690+ elif [ "$TAG_RESULT" = cancelled ] || [ "$DIST_RESULT" = cancelled ]; then
691+ status=cancelled
692+ else
693+ status="${UPDATE_STATUS:-success}"
694+ fi
695+ # Both skip unless a build was pushed.
696+ if [ "$TAG_RESULT" != skipped ] && [ -f report/conda-report.md ]; then
697+ {
698+ echo "- Tag: $TAG_RESULT"
699+ echo "- Upload: $DIST_RESULT"
700+ } >> report/conda-report.md
701+ fi
702+ fi
703+ python3 util/discussion_report.py --category "$REPORT_CATEGORY" \
704+ --title 'cron-conda: conda distribution update report' --report report/conda-report.md \
705+ --mode "$MODE" --status "$status"
0 commit comments