Review found that a run on main still treated main's tip as the commit under test in several places, and shared concurrency groups with pushes. - Concurrency: 14 nested workflows keyed their group on the ref, or on "tag". A stable run is on main, so a push could cancel its checks. They now use the run id when the caller passes a commit, and never cancel. - Docker and Nix archived, stamped and labelled GITHUB_SHA. They now use CANDIDATE_COMMIT, which is the commit input or the triggering commit. - Install e2e compared the package manifest with GITHUB_SHA. It now reads HERMES_TESTED_COMMIT. - e2e-desktop rewrote the visual baselines whenever the ref was main. A stable run now only compares. - The lint test checks the value each nested call passes, every concurrency group, and any other use of the triggering ref or SHA.
115 lines
4.3 KiB
YAML
115 lines
4.3 KiB
YAML
name: Lockfile diff
|
|
|
|
# Advisory PR comment showing the *semantic* diff of package-lock.json
|
|
# changes — which packages were added/removed/updated and their versions.
|
|
# The raw textual diff of a lockfile is unreadable (npm reorders entries
|
|
# and rewrites integrity hashes), so scripts/ci/lockfile_diff.py parses
|
|
# the ``packages`` map at the merge base and at HEAD and set-diffs the
|
|
# {install path: version} maps instead.
|
|
#
|
|
# The semantic diff is exposed as a workflow_call output ``review_status``
|
|
# (a JSON array in the unified status format) and an artifact
|
|
# (``lockfile-diff`` containing the markdown fragment) for the step
|
|
# summary.
|
|
#
|
|
# Never blocking — this is review signal, not enforcement.
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
commit:
|
|
description: Commit to test and build. Empty keeps the triggering commit.
|
|
type: string
|
|
default: ''
|
|
outputs:
|
|
changed:
|
|
description: Whether package-lock.json changed relative to the target branch.
|
|
value: ${{ jobs.diff.outputs.changed }}
|
|
review_status:
|
|
description: JSON array of review status objects for the unified PR comment.
|
|
value: ${{ jobs.diff.outputs.review_status }}
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
group: lockfile-diff-${{ inputs.commit != '' && github.run_id || github.event.pull_request.number || github.ref }}
|
|
# A stable run is on the default branch. It must not queue behind or cancel a push.
|
|
cancel-in-progress: ${{ inputs.commit == '' }}
|
|
|
|
jobs:
|
|
diff:
|
|
name: package-lock.json semantic diff
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 5
|
|
outputs:
|
|
changed: ${{ steps.diff.outputs.changed }}
|
|
review_status: ${{ steps.emit-status.outputs.review_status }}
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@f548e57e544e1ff5a4c46bf1e1b8685f8e4a348a # v7.0.1
|
|
with:
|
|
ref: ${{ inputs.commit }}
|
|
fetch-depth: 0 # need history for the merge base
|
|
|
|
- name: Generate semantic lockfile diff
|
|
id: diff
|
|
run: |
|
|
set -euo pipefail
|
|
# Three-dot semantics by hand: diff from the merge base with the
|
|
# target branch to the PR head, so changes that landed on main
|
|
# after the branch point don't show up as this PR's doing.
|
|
BASE_SHA=$(git merge-base "origin/${{ github.base_ref }}" HEAD)
|
|
echo "Merge base: ${BASE_SHA}"
|
|
python3 scripts/ci/lockfile_diff.py \
|
|
--base "$BASE_SHA" \
|
|
--head HEAD \
|
|
--output /tmp/lockfile-diff.md
|
|
if [ -s /tmp/lockfile-diff.md ]; then
|
|
echo "changed=true" >> "$GITHUB_OUTPUT"
|
|
{
|
|
echo "## package-lock.json semantic diff"
|
|
echo ""
|
|
cat /tmp/lockfile-diff.md
|
|
} >> "$GITHUB_STEP_SUMMARY"
|
|
else
|
|
echo "changed=false" >> "$GITHUB_OUTPUT"
|
|
: > /tmp/lockfile-diff.md
|
|
fi
|
|
|
|
- name: Emit review_status
|
|
id: emit-status
|
|
run: |
|
|
set -euo pipefail
|
|
CHANGED="${{ steps.diff.outputs.changed }}"
|
|
STATUS="[]"
|
|
|
|
if [ "$CHANGED" = "true" ]; then
|
|
CONTENT=$(cat /tmp/lockfile-diff.md | python3 -c "import sys,json; print(json.dumps(sys.stdin.read()))")
|
|
STATUS="[{\"source\":\"lockfile-diff\",\"results\":[{\"kind\":\"action_required\",\"title\":\"package-lock.json\",\"summary\":\"Locked npm dependency versions changed.\",\"detail\":${CONTENT},\"how_to_fix\":\"Verify the version changes are expected. package-lock.json changes need a hermes-agent-core review.\"}]}]"
|
|
else
|
|
STATUS="[]"
|
|
fi
|
|
|
|
echo "review_status=${STATUS}" >> "$GITHUB_OUTPUT"
|
|
echo "review_status=${STATUS}" > review-status.json
|
|
|
|
- name: Upload review status artifact
|
|
if: always() && steps.emit-status.outcome != 'skipped'
|
|
continue-on-error: true
|
|
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
|
with:
|
|
name: review-status-lockfile-diff
|
|
path: review-status.json
|
|
retention-days: 1
|
|
overwrite: true
|
|
if-no-files-found: ignore
|
|
|
|
- name: Upload diff artifact
|
|
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
|
with:
|
|
name: lockfile-diff
|
|
path: /tmp/lockfile-diff.md
|
|
retention-days: 1
|
|
overwrite: true
|