Skip to content

Commit fc555c0

Browse files
authored
Merge branch 'master' into remove-border-left-from-method-details
2 parents 8c02435 + f3204b7 commit fc555c0

File tree

11 files changed

+211
-9
lines changed

11 files changed

+211
-9
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Build and Deploy Cloudflare Preview
2+
3+
on:
4+
repository_dispatch:
5+
types: [pr-preview-deploy]
6+
7+
permissions:
8+
pull-requests: write # To allow commenting on the PR
9+
10+
jobs:
11+
build-deploy-and-comment:
12+
name: Build, Deploy, and Comment
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout PR Code
16+
uses: actions/checkout@v4
17+
with:
18+
repository: ${{ github.event.client_payload.pr_checkout_repository }}
19+
ref: ${{ github.event.client_payload.pr_head_sha }}
20+
21+
- name: Setup Ruby
22+
uses: ruby/setup-ruby@v1
23+
with:
24+
ruby-version: '3.4'
25+
bundler-cache: true
26+
27+
- name: Build site
28+
run: bundle exec rake rdoc
29+
30+
- name: Deploy to Cloudflare Pages
31+
id: deploy
32+
uses: cloudflare/wrangler-action@v3
33+
with:
34+
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
35+
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
36+
command: pages deploy ./_site --project-name=rdoc --branch="${{ github.event.client_payload.pr_number }}-preview"
37+
38+
- name: Comment on PR with preview URL
39+
uses: actions/github-script@v7
40+
with:
41+
github-token: ${{ secrets.MATZBOT_GITHUB_TOKEN }}
42+
script: |
43+
const prNumber = ${{ github.event.client_payload.pr_number }};
44+
const url = "${{ steps.deploy.outputs.deployment-url }}";
45+
const commentMarker = "🚀 Preview deployment available at:";
46+
const commitSha = '${{ github.event.client_payload.pr_head_sha }}';
47+
48+
const comments = await github.rest.issues.listComments({
49+
issue_number: prNumber,
50+
owner: context.repo.owner,
51+
repo: context.repo.repo,
52+
per_page: 100
53+
});
54+
55+
const existingComment = comments.data.find(comment =>
56+
comment.body.includes(commentMarker)
57+
);
58+
59+
const commentBody = `${commentMarker} [${url}](${url}) (commit: ${commitSha})`;
60+
61+
if (existingComment) {
62+
await github.rest.issues.updateComment({
63+
comment_id: existingComment.id,
64+
owner: context.repo.owner,
65+
repo: context.repo.repo,
66+
body: commentBody
67+
});
68+
console.log("Updated existing preview comment");
69+
} else {
70+
await github.rest.issues.createComment({
71+
issue_number: prNumber,
72+
owner: context.repo.owner,
73+
repo: context.repo.repo,
74+
body: commentBody
75+
});
76+
console.log("Created new preview comment");
77+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Dispatch Fork PR Preview Deployment
2+
3+
on:
4+
workflow_run:
5+
workflows: ["PR Preview Check"]
6+
types: [completed]
7+
8+
jobs:
9+
deploy-fork:
10+
name: Trigger Preview Build and Deploy (Fork)
11+
runs-on: ubuntu-latest
12+
if: |
13+
github.event.workflow_run.conclusion == 'success' &&
14+
github.event.workflow_run.event == 'pull_request'
15+
steps:
16+
- name: Download PR information
17+
uses: actions/download-artifact@v4
18+
with:
19+
name: pr
20+
github-token: ${{ secrets.GITHUB_TOKEN }}
21+
run-id: ${{ github.event.workflow_run.id }}
22+
23+
- name: Read PR information and trigger deployment
24+
uses: actions/github-script@v7
25+
with:
26+
script: |
27+
const fs = require('fs');
28+
29+
// Check if this was a fork PR by checking if approve-fork job ran
30+
const jobs = await github.rest.actions.listJobsForWorkflowRun({
31+
owner: context.repo.owner,
32+
repo: context.repo.repo,
33+
run_id: context.payload.workflow_run.id,
34+
});
35+
36+
const approveJob = jobs.data.jobs.find(job => job.name === 'Approve Fork PR');
37+
if (!approveJob || approveJob.conclusion !== 'success') {
38+
core.setFailed('Not a fork PR approval workflow run');
39+
return;
40+
}
41+
42+
// Read PR information from artifacts
43+
let prNumber, prHeadSha, prCheckoutRepo;
44+
try {
45+
prNumber = fs.readFileSync('./pr_number', 'utf8').trim();
46+
prHeadSha = fs.readFileSync('./pr_head_sha', 'utf8').trim();
47+
prCheckoutRepo = fs.readFileSync('./pr_checkout_repository', 'utf8').trim();
48+
} catch (error) {
49+
core.setFailed(`Failed to read PR information: ${error.message}`);
50+
return;
51+
}
52+
53+
console.log(`Deploying approved fork PR #${prNumber}`);
54+
55+
// Trigger deployment via repository dispatch
56+
await github.rest.repos.createDispatchEvent({
57+
owner: context.repo.owner,
58+
repo: context.repo.repo,
59+
event_type: 'pr-preview-deploy',
60+
client_payload: {
61+
pr_number: prNumber,
62+
pr_head_sha: prHeadSha,
63+
pr_checkout_repository: prCheckoutRepo,
64+
is_fork: 'true'
65+
}
66+
});
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: PR Preview Check
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
# Deploy main repo PRs directly
8+
deploy-for-main:
9+
name: Trigger Preview Build and Deploy (Main Repo)
10+
runs-on: ubuntu-latest
11+
if: github.event.pull_request.head.repo.fork == false
12+
steps:
13+
- name: Trigger preview deployment
14+
uses: actions/github-script@v7
15+
with:
16+
github-token: ${{ secrets.GITHUB_TOKEN }}
17+
script: |
18+
await github.rest.repos.createDispatchEvent({
19+
owner: context.repo.owner,
20+
repo: context.repo.repo,
21+
event_type: 'pr-preview-deploy',
22+
client_payload: {
23+
pr_number: '${{ github.event.pull_request.number }}',
24+
pr_head_sha: '${{ github.event.pull_request.head.sha }}',
25+
pr_checkout_repository: '${{ github.repository }}',
26+
is_fork: 'false'
27+
}
28+
});
29+
console.log('Triggered main repo preview deployment');
30+
31+
# Approval gate for fork PRs
32+
approve-for-fork:
33+
name: Approve Fork PR
34+
runs-on: ubuntu-latest
35+
if: github.event.pull_request.head.repo.fork == true
36+
environment: fork-preview-protection
37+
steps:
38+
- name: Save PR information
39+
run: |
40+
echo "Fork PR #${{ github.event.pull_request.number }} approved for preview deployment"
41+
mkdir -p ./pr
42+
echo "${{ github.event.pull_request.number }}" > ./pr/pr_number
43+
echo "${{ github.event.pull_request.head.sha }}" > ./pr/pr_head_sha
44+
echo "${{ github.event.pull_request.head.repo.full_name }}" > ./pr/pr_checkout_repository
45+
46+
- name: Upload PR information
47+
uses: actions/upload-artifact@v4
48+
with:
49+
name: pr
50+
path: pr/
51+
retention-days: 1

.github/workflows/push_gem.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323

2424
steps:
2525
- name: Harden Runner
26-
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
26+
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
2727
with:
2828
egress-policy: audit
2929

@@ -43,4 +43,4 @@ jobs:
4343
tag_name="$(git describe --tags --abbrev=0)"
4444
gh release create "${tag_name}" --verify-tag --generate-notes
4545
env:
46-
GITHUB_TOKEN: ${{ secrets.MATZBOT_GITHUB_WORKFLOW_TOKEN }}
46+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

lib/rdoc/code_object/context/section.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# frozen_string_literal: true
2-
require 'cgi/util'
2+
require 'cgi/escape'
3+
require 'cgi/util' unless defined?(CGI::EscapeExt)
34

45
##
56
# A section of documentation like:

lib/rdoc/code_object/method_attr.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,8 @@ def block_params=(value)
282282
# HTML id-friendly method/attribute name
283283

284284
def html_name
285-
require 'cgi/util'
285+
require 'cgi/escape'
286+
require 'cgi/util' unless defined?(CGI::EscapeExt)
286287

287288
CGI.escape(@name.gsub('-', '-2D')).gsub('%', '-').sub(/^-/, '')
288289
end

lib/rdoc/markup/to_html.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# frozen_string_literal: true
2-
require 'cgi/util'
2+
require 'cgi/escape'
3+
require 'cgi/util' unless defined?(CGI::EscapeExt)
34

45
##
56
# Outputs RDoc markup as HTML.

lib/rdoc/markup/to_label.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# frozen_string_literal: true
2-
require 'cgi/util'
2+
require 'cgi/escape'
3+
require 'cgi/util' unless defined?(CGI::EscapeExt)
34

45
##
56
# Creates HTML-safe labels suitable for use in id attributes. Tidylinks are

lib/rdoc/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ module RDoc
55
##
66
# RDoc version you are using
77

8-
VERSION = '6.13.1'
8+
VERSION = '6.14.1'
99

1010
end

rdoc.gemspec

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,10 @@ RDoc includes the +rdoc+ and +ri+ tools for generating and displaying documentat
5151
"exe/rdoc",
5252
"exe/ri",
5353
"man/ri.1",
54+
"rdoc.gemspec",
5455
]
5556
template_files = Dir.glob("lib/rdoc/generator/template/**/*")
56-
lib_files = Dir.glob("lib/**/*.{rb,kpeg,ry}")
57+
lib_files = Dir.glob("lib/**/*.{rb,kpeg,ry}", base: File.expand_path('..', __FILE__))
5758

5859
s.files = (non_lib_files + template_files + lib_files).uniq
5960

test/rdoc/support/test_case.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
require 'tmpdir'
1414
require 'stringio'
1515

16-
require_relative '../../lib/helper'
16+
begin
17+
require_relative '../../lib/helper'
18+
rescue LoadError
19+
end
1720
require_relative '../../../lib/rdoc'
1821

1922
##

0 commit comments

Comments
 (0)