Skip to content

fix: path to posting script #193

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

Merged
merged 7 commits into from
Jan 20, 2025
Merged

fix: path to posting script #193

merged 7 commits into from
Jan 20, 2025

Conversation

cmeesters
Copy link
Member

@cmeesters cmeesters commented Jan 20, 2025

Summary by CodeRabbit

  • Chores
    • Updated GitHub Actions workflow to use the pull request title for posting to Mastodon.
    • Made the Mastodon post script executable.
    • Added validation for the pull request title in the posting script.
    • Improved version extraction logic for enhanced flexibility in input formats.
    • Revised announcement message for clarity and consistency.

Copy link
Contributor

coderabbitai bot commented Jan 20, 2025

Walkthrough

The pull request modifies the GitHub Actions workflow for posting to Mastodon upon the closure of a pull request. It updates the method of exporting the pull request title, changing it from using the release tag name to using the pull request title. Additionally, it makes the post_to_mastodon.sh script executable and introduces a validation check for the PR_TITLE variable, altering the way the version is extracted from it.

Changes

File Change Summary
.github/workflows/post_to_mastodon.yml Changed export from github.event.release.tag_name to github.event.pull_request.title; added chmod +x for script permissions.
.github/workflows/post_to_mastodon.sh Added validation for PR_TITLE; updated version extraction from ${PR_TITLE#v} to ${PR_TITLE##* }; minor adjustments to announcement message.

Possibly related PRs

  • feat: Improved Mastodon Bot #183: This PR introduces a new script for posting to Mastodon and modifies the workflow to call this script, which is directly related to the changes made in the main PR regarding the posting process to Mastodon.
  • feat: mastodonbot #185: Similar to feat: Improved Mastodon Bot #183, this PR also focuses on the automation of posting to Mastodon and includes changes to the workflow that are relevant to the modifications in the main PR.
  • fix: mastodonbot #187: This PR modifies the workflow for posting to Mastodon, changing the trigger and the path to the script, which relates to the changes made in the main PR regarding the execution of the posting script.

Poem

🐰 In the garden of code, a change takes flight,
Pull requests whisper, in the soft moonlight.
From titles we gather, the stories they tell,
With scripts now executable, all will go well.
Hopping through workflows, with joy we unite,
To post on Mastodon, our future is bright! 🌟


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 53a7e59 and 8a7de21.

📒 Files selected for processing (1)
  • .github/workflows/post_to_mastodon.sh (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/post_to_mastodon.sh
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: testing

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d7dcbbb and 6b8cc25.

📒 Files selected for processing (1)
  • .github/workflows/post_to_mastodon.yml (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: testing

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
.github/workflows/post_to_mastodon.sh (2)

4-4: Add error handling for PR_TITLE environment variable.

The version extraction logic looks good and aligns with the PR title format. However, consider adding validation for the PR_TITLE environment variable.

+# Validate PR_TITLE
+if [ -z "${PR_TITLE}" ]; then
+    echo "Error: PR_TITLE environment variable is not set"
+    exit 1
+fi
+
 # Extract version from PR tag passed as environment variable
 version="${PR_TITLE##* }"

Line range hint 19-41: Consider improving message construction for better maintainability.

The hardcoded message with maintainer handles could benefit from some improvements:

  1. Move maintainer handles to variables for easier updates
  2. Use heredoc with quotes to prevent expansion issues
+# Maintainer handles
+MAINTAINER1="@rupdecat@fediscience.org"
+MAINTAINER2="@johanneskoester@fosstodon.org"
+
-read -d '\n' message << EndOfText
+read -d '\n' message << 'EndOfText'
 Beep, Beep - I am your friendly #Snakemake release announcement bot
 
 There is a new release of the Snakemake executor for #SLURM on #HPC systems. Its version is '${version}'!
 
-See ${changelog//\'/\\\'} for details.
+See ${changelog} for details.
 
 Give us some time and you will automatically find it on #Bioconda and #Pypi.
 
-If you want to discuss the release you will find the maintainers here on Mastodon!
-@rupdecat@fediscience.org and @johanneskoester@fosstodon.org
+If you want to discuss the release you will find the maintainers here on Mastodon! 
+${MAINTAINER1} and ${MAINTAINER2}
 
 If you find any issues, please report them on https://github.com/snakemake/snakemake-executor-plugin-slurm/issues
 
 #Snakemake #HPC #ReproducibleComputing #ReproducibleResearch #OpenScience
 EndOfText
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6b8cc25 and 53a7e59.

📒 Files selected for processing (2)
  • .github/workflows/post_to_mastodon.sh (1 hunks)
  • .github/workflows/post_to_mastodon.yml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/post_to_mastodon.yml
🧰 Additional context used
📓 Learnings (1)
.github/workflows/post_to_mastodon.sh (1)
Learnt from: cmeesters
PR: snakemake/snakemake-executor-plugin-slurm#193
File: .github/workflows/post_to_mastodon.yml:0-0
Timestamp: 2025-01-20T09:24:03.959Z
Learning: In the snakemake-executor-plugin-slurm repository's post_to_mastodon.sh script, the version number is extracted from PR titles using the parameter expansion `${PR_TITLE##* }`, which removes everything up to the last space in the string.
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: testing
🔇 Additional comments (1)
.github/workflows/post_to_mastodon.sh (1)

Line range hint 13-13: Verify that the version tag exists before constructing the changelog URL.

The script assumes the version tag exists in the repository. Consider adding a verification step.

Run this script to verify the version tag exists:

@cmeesters cmeesters merged commit d0fb3cd into main Jan 20, 2025
6 checks passed
@cmeesters cmeesters deleted the fix/Mastodon3 branch January 20, 2025 12:53
@cmeesters cmeesters restored the fix/Mastodon3 branch January 20, 2025 12:59
@cmeesters
Copy link
Member Author

@coderabbitai the action runner (https://github.com/snakemake/snakemake-executor-plugin-slurm/actions/runs/12868461723/job/35875172798) now returns Error: Invalid version format in PR title: script. Any idea what causes this and what a fix might be?

Copy link
Contributor

coderabbitai bot commented Jan 20, 2025

Tip

For best results, initiate chat on the files or code changes.

@cmeesters The error occurs because the script expects a version number in the title (e.g., "v1.2.3"), but your PR title "fix: path to posting script" doesn't contain one. The script was previously triggered by releases (which have version tags) but was changed to use PR titles instead.

You have a few options to fix this:

  1. Revert back to using releases instead of PRs for the Mastodon posts
  2. Add a check in the script to only process titles that contain version numbers
  3. Modify the script to handle both release tags and regular PR titles differently

Which approach would you prefer? I can help you implement any of these solutions.

Copy link
Contributor

coderabbitai bot commented Jan 20, 2025

Tip

For best results, initiate chat on the files or code changes.

@cmeesters I see the issue now. The workflow is currently set to run on all merged PRs, but the script is specifically designed to announce version releases.

Here's the recommended fix - modify the workflow to only run on release PRs. Update the .github/workflows/post_to_mastodon.yml file to add a condition checking if the PR title starts with "release" or contains a version number:

jobs:
  post_to_mastodon:
    if: |
      github.event.pull_request.merged == true && 
      (startsWith(github.event.pull_request.title, 'release') || contains(github.event.pull_request.title, ' v'))
    runs-on: ubuntu-latest
    # ... rest of the job configuration

This way:

  1. The workflow will only run for release PRs
  2. Regular fix/feature PRs won't trigger the Mastodon announcement
  3. The version extraction in the script will work as intended

Would you like me to help you implement this change?

🔗 Analysis chain

@cmeesters The error occurs because the post_to_mastodon.sh script expects the PR title to end with a version number (e.g., "something v1.2.3" or "release 1.2.3"), but your PR title is "fix: path to posting script".

This seems to be because the workflow was converted from handling releases to handling PRs, but the version extraction logic wasn't updated. You have a few options:

  1. Only run this workflow for release PRs and skip it for regular fix/feature PRs
  2. Update PR titles to include versions (e.g., "fix: path to posting script v1.2.3")
  3. Modify the script to handle non-version PR titles differently

Which approach would you prefer? I can help you implement any of these solutions.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Let's look at the post_to_mastodon.sh script
cat .github/workflows/post_to_mastodon.sh

Length of output: 2167


Script:

#!/bin/bash
# Let's look at the workflow file
cat .github/workflows/post_to_mastodon.yml

Length of output: 767

@coderabbitai coderabbitai bot mentioned this pull request Jan 20, 2025
cmeesters pushed a commit that referenced this pull request Jan 20, 2025
🤖 I have created a release *beep* *boop*
---


##
[0.14.2](v0.14.1...v0.14.2)
(2025-01-20)


### Bug Fixes

* ci runner ought to start now upon merge to main
([#189](#189))
([90c6bf9](90c6bf9))
* path to access the posting script
([#191](#191))
([d7dcbbb](d7dcbbb))
* path to posting script
([#193](#193))
([d0fb3cd](d0fb3cd))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@coderabbitai coderabbitai bot mentioned this pull request Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant