From 6fd50e38691a76ee0aef90129f89c73aeae06f34 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Fri, 3 Oct 2025 23:47:23 -0700 Subject: [PATCH 1/5] Run notes-github-pr while .git is still available https://github.com/ruby/ruby/actions/runs/18240911019/job/51942567201 --- .github/workflows/check_misc.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/check_misc.yml b/.github/workflows/check_misc.yml index b332eef541468f..62b0a472ab32d6 100644 --- a/.github/workflows/check_misc.yml +++ b/.github/workflows/check_misc.yml @@ -62,6 +62,14 @@ jobs: GITHUB_NEW_SHA: ${{ github.event.pull_request.merge_commit_sha }} if: ${{ github.repository == 'ruby/ruby' && startsWith(github.event_name, 'pull') }} + - name: Push PR notes to GitHub + run: ruby tool/notes-github-pr.rb "$(pwd)" "$GITHUB_OLD_SHA" "$GITHUB_NEW_SHA" refs/heads/master + env: + GITHUB_OLD_SHA: ${{ github.event.before }} + GITHUB_NEW_SHA: ${{ github.event.after }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + if: ${{ github.repository == 'ruby/ruby' && github.ref == 'refs/heads/master' && github.event_name == 'push' }} + - name: Check if C-sources are US-ASCII run: | grep -r -n --include='*.[chyS]' --include='*.asm' $'[^\t-~]' -- . && exit 1 || : @@ -132,14 +140,6 @@ jobs: name: ${{ steps.docs.outputs.htmlout }} if: ${{ steps.docs.outcome == 'success' }} - - name: Push PR notes to GitHub - run: ruby tool/notes-github-pr.rb "$(pwd)" "$GITHUB_OLD_SHA" "$GITHUB_NEW_SHA" refs/heads/master - env: - GITHUB_OLD_SHA: ${{ github.event.before }} - GITHUB_NEW_SHA: ${{ github.event.after }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - if: ${{ github.repository == 'ruby/ruby' && github.ref == 'refs/heads/master' && github.event_name == 'push' }} - - uses: ./.github/actions/slack with: SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot From 4da1fa3ff48c2e8db50ef9e7980c22f5f80ab876 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Fri, 3 Oct 2025 23:51:55 -0700 Subject: [PATCH 2/5] Fix the GIT_DIR given to notes-github-pr --- .github/workflows/check_misc.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check_misc.yml b/.github/workflows/check_misc.yml index 62b0a472ab32d6..e2eee89435dd4d 100644 --- a/.github/workflows/check_misc.yml +++ b/.github/workflows/check_misc.yml @@ -63,7 +63,7 @@ jobs: if: ${{ github.repository == 'ruby/ruby' && startsWith(github.event_name, 'pull') }} - name: Push PR notes to GitHub - run: ruby tool/notes-github-pr.rb "$(pwd)" "$GITHUB_OLD_SHA" "$GITHUB_NEW_SHA" refs/heads/master + run: ruby tool/notes-github-pr.rb "$(pwd)/.git" "$GITHUB_OLD_SHA" "$GITHUB_NEW_SHA" refs/heads/master env: GITHUB_OLD_SHA: ${{ github.event.before }} GITHUB_NEW_SHA: ${{ github.event.after }} From 9c9f3bb6e2f5844867bf2a9c2784be1d92d1b566 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Fri, 3 Oct 2025 23:56:12 -0700 Subject: [PATCH 3/5] Configure git user for notes-github-pr --- .github/workflows/check_misc.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/check_misc.yml b/.github/workflows/check_misc.yml index e2eee89435dd4d..b820b9ce4c4cdd 100644 --- a/.github/workflows/check_misc.yml +++ b/.github/workflows/check_misc.yml @@ -68,6 +68,9 @@ jobs: GITHUB_OLD_SHA: ${{ github.event.before }} GITHUB_NEW_SHA: ${{ github.event.after }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GIT_AUTHOR_NAME: git + GIT_COMMITTER_NAME: git + EMAIL: svn-admin@ruby-lang.org if: ${{ github.repository == 'ruby/ruby' && github.ref == 'refs/heads/master' && github.event_name == 'push' }} - name: Check if C-sources are US-ASCII From d29b1435cd4fca619f5a8a0868650bd68b82811a Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Sat, 4 Oct 2025 00:18:02 -0700 Subject: [PATCH 4/5] Stop cloning the repository into another path which seems to prevent it from fetching notes when the path is not the actual repository but a shallow-cloned repository. --- .github/workflows/check_misc.yml | 22 +++++------ tool/notes-github-pr.rb | 65 ++++++++++++++------------------ 2 files changed, 39 insertions(+), 48 deletions(-) diff --git a/.github/workflows/check_misc.yml b/.github/workflows/check_misc.yml index b820b9ce4c4cdd..07c43a0c3b0788 100644 --- a/.github/workflows/check_misc.yml +++ b/.github/workflows/check_misc.yml @@ -62,17 +62,6 @@ jobs: GITHUB_NEW_SHA: ${{ github.event.pull_request.merge_commit_sha }} if: ${{ github.repository == 'ruby/ruby' && startsWith(github.event_name, 'pull') }} - - name: Push PR notes to GitHub - run: ruby tool/notes-github-pr.rb "$(pwd)/.git" "$GITHUB_OLD_SHA" "$GITHUB_NEW_SHA" refs/heads/master - env: - GITHUB_OLD_SHA: ${{ github.event.before }} - GITHUB_NEW_SHA: ${{ github.event.after }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GIT_AUTHOR_NAME: git - GIT_COMMITTER_NAME: git - EMAIL: svn-admin@ruby-lang.org - if: ${{ github.repository == 'ruby/ruby' && github.ref == 'refs/heads/master' && github.event_name == 'push' }} - - name: Check if C-sources are US-ASCII run: | grep -r -n --include='*.[chyS]' --include='*.asm' $'[^\t-~]' -- . && exit 1 || : @@ -143,6 +132,17 @@ jobs: name: ${{ steps.docs.outputs.htmlout }} if: ${{ steps.docs.outcome == 'success' }} + - name: Push PR notes to GitHub + run: ruby tool/notes-github-pr.rb "$(pwd)/.git" "$GITHUB_OLD_SHA" "$GITHUB_NEW_SHA" refs/heads/master + env: + GITHUB_OLD_SHA: ${{ github.event.before }} + GITHUB_NEW_SHA: ${{ github.event.after }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GIT_AUTHOR_NAME: git + GIT_COMMITTER_NAME: git + EMAIL: svn-admin@ruby-lang.org + if: ${{ github.repository == 'ruby/ruby' && github.ref == 'refs/heads/master' && github.event_name == 'push' }} + - uses: ./.github/actions/slack with: SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot diff --git a/tool/notes-github-pr.rb b/tool/notes-github-pr.rb index e282386eba15d4..d69d479cdf79f1 100644 --- a/tool/notes-github-pr.rb +++ b/tool/notes-github-pr.rb @@ -103,45 +103,36 @@ def git(*cmd, repo_path: nil) github = GitHub.new(ENV.fetch('GITHUB_TOKEN')) repo_path, *rest = ARGV -rest.each_slice(3).map do |oldrev, newrev, refname| - branch = Git.abbrev_ref(refname, repo_path: repo_path) - next if branch != 'master' # we use pull requests only for master branches - - Dir.mktmpdir do |workdir| - # Clone a branch and fetch notes - depth = Git.rev_list("#{oldrev}..#{newrev}", repo_path: repo_path).size + 50 - system('git', 'clone', "--depth=#{depth}", "--branch=#{branch}", "file://#{repo_path}", workdir) - Dir.chdir(workdir) - system('git', 'fetch', 'origin', 'refs/notes/commits:refs/notes/commits') - - updated = false - Git.rev_list("#{oldrev}..#{newrev}", first_parent: true).each do |sha| - github.pulls(owner: 'ruby', repo: 'ruby', commit_sha: sha).each do |pull| - number = pull.fetch('number') - url = pull.fetch('html_url') - next unless url.start_with?('https://github.com/ruby/ruby/pull/') - - # "Merged" notes for "Squash and merge" - message = Git.commit_message(sha) - notes = Git.notes_message(sha) - if !message.include?(url) && !message.match(/[ (]##{number}[) ]/) && !notes.include?(url) - system('git', 'notes', 'append', '-m', "Merged: #{url}", sha) - updated = true - end - - # "Merged-By" notes for "Rebase and merge" - if Git.committer_name(sha) == 'GitHub' && Git.committer_email(sha) == 'noreply@github.com' - username = github.pull_request(owner: 'ruby', repo: 'ruby', number: number).fetch('merged_by').fetch('login') - email = github.user(username: username).fetch('email') - email ||= SVN_TO_EMAILS[GITHUB_TO_SVN.fetch(username, username)]&.first - system('git', 'notes', 'append', '-m', "Merged-By: #{username}#{(" <#{email}>" if email)}", sha) - updated = true - end +rest.each_slice(3).map do |oldrev, newrev, _refname| + system('git', 'fetch', 'origin', 'refs/notes/commits:refs/notes/commits', exception: true) + + updated = false + Git.rev_list("#{oldrev}..#{newrev}", first_parent: true).each do |sha| + github.pulls(owner: 'ruby', repo: 'ruby', commit_sha: sha).each do |pull| + number = pull.fetch('number') + url = pull.fetch('html_url') + next unless url.start_with?('https://github.com/ruby/ruby/pull/') + + # "Merged" notes for "Squash and merge" + message = Git.commit_message(sha) + notes = Git.notes_message(sha) + if !message.include?(url) && !message.match(/[ (]##{number}[) ]/) && !notes.include?(url) + system('git', 'notes', 'append', '-m', "Merged: #{url}", sha, exception: true) + updated = true end - end - if updated - system('git', 'push', 'origin', 'refs/notes/commits') + # "Merged-By" notes for "Rebase and merge" + if Git.committer_name(sha) == 'GitHub' && Git.committer_email(sha) == 'noreply@github.com' + username = github.pull_request(owner: 'ruby', repo: 'ruby', number: number).fetch('merged_by').fetch('login') + email = github.user(username: username).fetch('email') + email ||= SVN_TO_EMAILS[GITHUB_TO_SVN.fetch(username, username)]&.first + system('git', 'notes', 'append', '-m', "Merged-By: #{username}#{(" <#{email}>" if email)}", sha, exception: true) + updated = true + end end end + + if updated + system('git', 'push', 'origin', 'refs/notes/commits', exception: true) + end end From 8eb28da3e73cd571cb06d1450ee87384e37b83a7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 9 Sep 2025 03:28:32 +0000 Subject: [PATCH 5/5] Bump actions/labeler from 5 to 6 Bumps [actions/labeler](https://github.com/actions/labeler) from 5 to 6. - [Release notes](https://github.com/actions/labeler/releases) - [Commits](https://github.com/actions/labeler/compare/v5...v6) --- updated-dependencies: - dependency-name: actions/labeler dependency-version: '6' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/labeler.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index e57cd86e2b3c7f..16dbac1afa0f18 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -9,4 +9,4 @@ jobs: pull-requests: write runs-on: ubuntu-latest steps: - - uses: actions/labeler@v5 + - uses: actions/labeler@v6