ci: update-maintainers include eval diff
Show evaluated comparison in the PR we create. Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
This commit is contained in:
parent
30533223ee
commit
6613b6ce49
1 changed files with 60 additions and 11 deletions
71
.github/workflows/update-maintainers.yml
vendored
71
.github/workflows/update-maintainers.yml
vendored
|
|
@ -66,6 +66,11 @@ jobs:
|
|||
run: |
|
||||
git config user.name "$name"
|
||||
git config user.email "$email"
|
||||
- name: Save old maintainers
|
||||
id: old-maintainers
|
||||
run: |
|
||||
echo "📄 Saving old maintainers file for comparison..."
|
||||
echo "old_maintainers=$(nix eval --file all-maintainers.nix --apply 'builtins.attrNames' --json 2>/dev/null || echo '[]')" >> "$GITHUB_OUTPUT"
|
||||
- name: Generate updated maintainers list
|
||||
run: |
|
||||
echo "::group::📋 Generating updated generated/all-maintainers.nix..."
|
||||
|
|
@ -74,12 +79,15 @@ jobs:
|
|||
echo "::group::🎨 Formatting with nixfmt..."
|
||||
nix fmt all-maintainers.nix
|
||||
echo "::endgroup::"
|
||||
- name: Check for changes
|
||||
- name: Check for changes and compare maintainers
|
||||
id: check-changes
|
||||
env:
|
||||
old_maintainers: ${{ steps.old-maintainers.outputs.old_maintainers }}
|
||||
run: |
|
||||
if git diff --quiet all-maintainers.nix; then
|
||||
echo "No changes to all-maintainers.nix"
|
||||
echo "has_changes=false" >> "$GITHUB_OUTPUT"
|
||||
echo "maintainer_changes=No changes detected" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "Changes detected in all-maintainers.nix"
|
||||
echo "has_changes=true" >> "$GITHUB_OUTPUT"
|
||||
|
|
@ -87,6 +95,53 @@ jobs:
|
|||
added=$(git diff --numstat all-maintainers.nix | cut -f1)
|
||||
removed=$(git diff --numstat all-maintainers.nix | cut -f2)
|
||||
echo "changes_summary=+$added -$removed lines" >> "$GITHUB_OUTPUT"
|
||||
|
||||
# Compare old and new maintainers using nix eval
|
||||
echo "🔍 Comparing maintainers..."
|
||||
|
||||
# Extract maintainer names from new file
|
||||
new_maintainers=$(nix eval --file all-maintainers.nix --apply 'builtins.attrNames' --json)
|
||||
|
||||
# Compare using nix eval
|
||||
comparison=$(nix eval --expr "
|
||||
let
|
||||
old = builtins.fromJSON ''$old_maintainers'';
|
||||
new = builtins.fromJSON ''$new_maintainers'';
|
||||
oldSet = builtins.listToAttrs (map (name: { name = name; value = true; }) old);
|
||||
newSet = builtins.listToAttrs (map (name: { name = name; value = true; }) new);
|
||||
added = builtins.filter (name: !(oldSet ? \${name})) new;
|
||||
removed = builtins.filter (name: !(newSet ? \${name})) old;
|
||||
in {
|
||||
added = added;
|
||||
removed = removed;
|
||||
total_old = builtins.length old;
|
||||
total_new = builtins.length new;
|
||||
}
|
||||
" --json)
|
||||
|
||||
# Format comparison output
|
||||
added_count=$(echo "$comparison" | jq '.added | length')
|
||||
removed_count=$(echo "$comparison" | jq '.removed | length')
|
||||
total_old=$(echo "$comparison" | jq '.total_old')
|
||||
total_new=$(echo "$comparison" | jq '.total_new')
|
||||
|
||||
maintainer_summary="**Added:** $added_count maintainers"
|
||||
maintainer_summary="$maintainer_summary\n**Removed:** $removed_count maintainers"
|
||||
maintainer_summary="$maintainer_summary\n**Total:** $total_old → $total_new maintainers"
|
||||
|
||||
if [ "$added_count" -gt 0 ]; then
|
||||
added_names=$(echo "$comparison" | jq -r '.added | join(", ")')
|
||||
maintainer_summary="$maintainer_summary\n\n**✅ Added:** $added_names"
|
||||
fi
|
||||
|
||||
if [ "$removed_count" -gt 0 ]; then
|
||||
removed_names=$(echo "$comparison" | jq -r '.removed | join(", ")')
|
||||
maintainer_summary="$maintainer_summary\n\n**❌ Removed:** $removed_names"
|
||||
fi
|
||||
|
||||
echo "maintainer_changes<<EOF" >> "$GITHUB_OUTPUT"
|
||||
echo -e "$maintainer_summary" >> "$GITHUB_OUTPUT"
|
||||
echo "EOF" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
- name: Validate generated file
|
||||
if: steps.check-changes.outputs.has_changes == 'true'
|
||||
|
|
@ -149,7 +204,7 @@ jobs:
|
|||
- Home Manager specific maintainers from modules/lib/maintainers.nix
|
||||
- Nixpkgs maintainers referenced in Home Manager modules
|
||||
|
||||
Changes: ${{ steps.check-changes.outputs.changes_summary || 'No content changes' }}
|
||||
${{ steps.check-changes.outputs.maintainer_changes }}
|
||||
|
||||
Generated by: lib/python/generate-all-maintainers.py
|
||||
pr_url: ${{ steps.open_pr_info.outputs.url }}
|
||||
|
|
@ -165,22 +220,16 @@ jobs:
|
|||
|
||||
**Statistics:** ${{ steps.check-changes.outputs.changes_summary || 'No content changes (format/comment updates only)' }}
|
||||
|
||||
${{ steps.check-changes.outputs.maintainer_changes }}
|
||||
|
||||
The updated list includes all maintainers needed for review assignments across the Home Manager project.
|
||||
|
||||
## 🤖 Automation
|
||||
|
||||
- **Generated by:** `lib/python/generate-all-maintainers.sh`
|
||||
- **Generated by:** `lib/python/generate-all-maintainers.py`
|
||||
- **Trigger:** ${{ github.event_name == 'schedule' && 'Scheduled weekly update' || 'Manual workflow dispatch' }}
|
||||
- **Validation:** File syntax verified with `nix eval`
|
||||
|
||||
## 📚 Usage
|
||||
|
||||
This file can be imported and used for maintainer lookups:
|
||||
```nix
|
||||
let allMaintainers = import ./all-maintainers.nix; in
|
||||
# Access any maintainer by name: allMaintainers.username
|
||||
```
|
||||
|
||||
---
|
||||
🤖 *This PR was automatically created by the [update-maintainers workflow](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})*
|
||||
run: |
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue