Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: auto-summary for PRs #21

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions .github/workflows/annotate_pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Annotate PR

on:
pull_request:
branches: [beta]
types: [opened, synchronize, reopened, edited]
paths:
- 'synsets/**/*.xml'

jobs:
update-comment:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 2 # Fetches the last 2 commits

- name: List all changed synsets
id: diff
run: |
CHANGED_FILES=$(git diff --name-only beta...${{ github.head_ref }} -- 'synsets/**/*.xml')
echo "Changed synsets:"
echo "$CHANGED_FILES"
echo "CHANGED_FILES=${CHANGED_FILES}" >> $GITHUB_ENV
if [ -z "$CHANGED_FILES" ]; then
echo "No changes in synsets folder. Skipping the rest of the job."
exit 78
fi

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'

- name: Install dependencies
uses: bahmutov/npm-install@v1
with:
useLockFile: false

- name: Generate Comment File
run: scripts/annotate-pr ${{ env.CHANGED_FILES }} > comment-body.md

- name: Find Comment
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: Summary of Changes

- name: Create or Update Comment
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body-path: 'comment-body.md'
edit-mode: replace
2 changes: 2 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,5 @@ jobs:

- name: Run lint
run: npm run lint -- ${{ steps.the_changes.outputs.all_changed_files }}
env:
CI: true
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"private": true,
"scripts": {
"prepare": "husky install",
"annotate:pr": "scripts/annotate-pr",
"format": "scripts/format",
"lint": "scripts/lint-synset"
},
Expand Down
11 changes: 11 additions & 0 deletions scripts/annotate-pr
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

set -e

if [ $# -eq 0 ]; then
changed_files=$(git diff --name-only beta synsets)
else
changed_files="$*"
fi

isv suggestions annotate $changed_files
4 changes: 3 additions & 1 deletion scripts/lint-synset
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ lint_synset() {
cd "$(dirname "$0")/.."

if [ $# -eq 0 ]; then
find synsets -type f -name "*.xml" -exec $0 {} \;
if [ -z "$CI" ]; then
find synsets -type f -name "*.xml" -exec $0 {} \;
fi
else
for file in "$@"; do
lint_synset "$file"
Expand Down