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

[CI] Added job adding preview links #2561

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open

Conversation

mnocon
Copy link
Contributor

@mnocon mnocon commented Nov 29, 2024

Target: master, 4.6, 3.3 and user doc as a follow-up.

Adding a job to automatically generate preview links for all the changed Markdown files, so that we don't have to do this manually. See the comment below.

IMPORTANT NOTE
Contains TMP changes (borrowed from #2560) to test the job - only the .github/workflows/preview_comment.yaml file should be reviewed.

Option 1: No Markdown changes in the docs directory

The job doesn't run, there's a filter in the job trigger

Option 2: Markdown changes

See the bot comment below: #2561 (comment)

Option 3: Too many changes

I've chosen an arbitrary limit of 100 files - we can adjust it if needed.

@ibexa ibexa deleted a comment from github-actions bot Nov 30, 2024
@ibexa ibexa deleted a comment from github-actions bot Nov 30, 2024
@ibexa ibexa deleted a comment from github-actions bot Nov 30, 2024
@ibexa ibexa deleted a comment from github-actions bot Nov 30, 2024
@ibexa ibexa deleted a comment from github-actions bot Nov 30, 2024
@ibexa ibexa deleted a comment from github-actions bot Nov 30, 2024
@ibexa ibexa deleted a comment from github-actions bot Nov 30, 2024
@mnocon mnocon force-pushed the preview-links-comment branch from f45d0fd to c47f2fe Compare November 30, 2024 10:13
@ibexa ibexa deleted a comment from github-actions bot Nov 30, 2024
@mnocon mnocon force-pushed the preview-links-comment branch from c47f2fe to 3cf1b26 Compare November 30, 2024 10:14
@ibexa ibexa deleted a comment from github-actions bot Nov 30, 2024
@ibexa ibexa deleted a comment from github-actions bot Nov 30, 2024
@mnocon mnocon marked this pull request as ready for review December 2, 2024 11:03
@mnocon mnocon requested a review from adriendupuis December 2, 2024 11:04
number_of__changed_files=$(echo "$changed_files" | wc -l)

if [[ $changed_files -eq "" ]] ; then
comment="Preview of modified files:: no markdown files changed, no preview needed."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I modify a code sample, a preview is needed. I would reword to stick to the scope.

Suggested change
comment="Preview of modified files:: no markdown files changed, no preview needed."
comment="Preview of modified Markdown files:: No Markdown change to preview."


if [[ $changed_files -eq "" ]] ; then
comment="Preview of modified files:: no markdown files changed, no preview needed."
elif [[ $number_of__changed_files -gt file_limit ]] ; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works without the dollar??

Suggested change
elif [[ $number_of__changed_files -gt file_limit ]] ; then
elif [[ $number_of__changed_files -gt $file_limit ]] ; then

if [[ $changed_files -eq "" ]] ; then
comment="Preview of modified files:: no markdown files changed, no preview needed."
elif [[ $number_of__changed_files -gt file_limit ]] ; then
comment="Preview of modified files: too many files modified in a single PR. Unable to post preview links, sorry!"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
comment="Preview of modified files: too many files modified in a single PR. Unable to post preview links, sorry!"
comment="Preview of modified Markdown files: Too many files modified in a single PR, preview link list is skipped. ($number_of__changed_files files &gth; $file_limit)"

right=$(yes ")\n" | head -n "$number_of__changed_files" )

comment=$(paste -d'\0' <(echo "$left") <(echo "$filenames") <(echo "$middle") <(echo "$urls") <(echo "$right"))
comment="Preview of modified files:\n\n$comment"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
comment="Preview of modified files:\n\n$comment"
comment="Preview of modified Markdown files:\n\n$comment"

with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: 'Preview of modified files'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
body-includes: 'Preview of modified files'
body-includes: 'Preview of modified Markdown files'

Comment on lines +33 to +34
changed_files=$(git diff --name-only HEAD "origin/$GITHUB_BASE_REF" | grep -E ".md$" || [[ $? == 1 ]])
number_of__changed_files=$(echo "$changed_files" | wc -l)
Copy link
Contributor

@adriendupuis adriendupuis Dec 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I manage to generate the whole link list in one go:
git diff --name-only HEAD "origin/master" | grep -E "^docs\/.*\.md$" | sed -E "s|^docs/(.*)\.md$|- [docs/\1.md](${build_url}\1/)|"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants