Skip to content

workflow to run stylecheck #187

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 15 commits into from
Apr 2, 2025
Merged
Show file tree
Hide file tree
Changes from 6 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
50 changes: 50 additions & 0 deletions .github/workflows/stylecheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: PR Review Suggestions

on:
pull_request:
types: [opened, synchronize, labeled]
paths:
- '**.md'
- '**.mdx'

jobs:
suggest:
if: contains(github.event.pull_request.labels.*.name, 'stylecheck')
runs-on: ubuntu-latest
permissions:
pull-requests: write

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install requests

- name: Run stylecheck on changed files
env:
GITHUB_TOKEN: ${{ secrets.STYLECHECK }}
LLM_JWT: ${{ secrets.LLM_JWT }}
REPO_OWNER: ${{ github.repository_owner }}
REPO_NAME: ${{ github.event.repository.name }}
PR_NUMBER: ${{ github.event.pull_request.number }}
COMMIT_SHA: ${{ github.event.pull_request.head.sha }}
run: |
echo "DATE=$(date --iso-8601=seconds)" >> $GITHUB_ENV
mkdir -p temp
for file in $(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | grep -E '\.mdx?$'); do
python stylecheck.py "$file"
done
- name: Archive temp files
uses: actions/upload-artifact@v4
with:
name: stylecheck-${{ env.DATE }}
path: temp/**
2 changes: 1 addition & 1 deletion style/sample-common.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This integration links Datadog's monitoring system with Devrev's incident manage

- Automated Incident Creation: When an incident is triggered in Datadog, the snap-in automatically creates a corresponding incident in DevRev.
- Automated Incident Updation: When an incident is updated in Datadog, the changes are reflected in DevRev.
- Real-Time Synchronization: The snap-in ensures that incidents are created or updated in real-time, reducing delays between detection and resolution. DevRev captures the necessary incident details from the Datadog payload, allowing teams to address and mitigate issues.
- Real-time Synchronization: The snap-in ensures that incidents are created or updated in real-time, reducing delays between detection and resolution. DevRev captures the necessary incident details from the Datadog payload, allowing teams to address and mitigate issues.
- Seamless integration: The snap-in is built to streamline workflows, minimizing the need for manual intervention.
Comment on lines 7 to 10
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
- Automated Incident Creation: When an incident is triggered in Datadog, the snap-in automatically creates a corresponding incident in DevRev.
- Automated Incident Updation: When an incident is updated in Datadog, the changes are reflected in DevRev.
- Real-Time Synchronization: The snap-in ensures that incidents are created or updated in real-time, reducing delays between detection and resolution. DevRev captures the necessary incident details from the Datadog payload, allowing teams to address and mitigate issues.
- Real-time Synchronization: The snap-in ensures that incidents are created or updated in real-time, reducing delays between detection and resolution. DevRev captures the necessary incident details from the Datadog payload, allowing teams to address and mitigate issues.
- Seamless integration: The snap-in is built to streamline workflows, minimizing the need for manual intervention.
- Automated incident creation from Datadog triggers
- Automated incident updates from Datadog changes
- Real-time synchronization between systems
- Seamless workflow integration

Comment on lines 7 to 10
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
- Automated Incident Creation: When an incident is triggered in Datadog, the snap-in automatically creates a corresponding incident in DevRev.
- Automated Incident Updation: When an incident is updated in Datadog, the changes are reflected in DevRev.
- Real-Time Synchronization: The snap-in ensures that incidents are created or updated in real-time, reducing delays between detection and resolution. DevRev captures the necessary incident details from the Datadog payload, allowing teams to address and mitigate issues.
- Real-time Synchronization: The snap-in ensures that incidents are created or updated in real-time, reducing delays between detection and resolution. DevRev captures the necessary incident details from the Datadog payload, allowing teams to address and mitigate issues.
- Seamless integration: The snap-in is built to streamline workflows, minimizing the need for manual intervention.
- Automated incident creation: Creates corresponding incidents in DevRev when triggered in Datadog
- Automated incident updates: Reflects Datadog incident changes in DevRev
- Real-time synchronization: Ensures immediate creation and updates of incidents to reduce detection-to-resolution delays
- Seamless integration: Streamlines workflows to minimize manual intervention

Comment on lines 7 to 10
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
- Automated Incident Creation: When an incident is triggered in Datadog, the snap-in automatically creates a corresponding incident in DevRev.
- Automated Incident Updation: When an incident is updated in Datadog, the changes are reflected in DevRev.
- Real-Time Synchronization: The snap-in ensures that incidents are created or updated in real-time, reducing delays between detection and resolution. DevRev captures the necessary incident details from the Datadog payload, allowing teams to address and mitigate issues.
- Real-time Synchronization: The snap-in ensures that incidents are created or updated in real-time, reducing delays between detection and resolution. DevRev captures the necessary incident details from the Datadog payload, allowing teams to address and mitigate issues.
- Seamless integration: The snap-in is built to streamline workflows, minimizing the need for manual intervention.
- Automated incident creation: The snap-in creates corresponding incidents in DevRev when triggered in Datadog.
- Automated incident updates: Changes in Datadog incidents are automatically reflected in DevRev.
- Real-time synchronization: Incidents are created or updated in real-time, reducing delays between detection and resolution.
- Seamless integration: The workflow design minimizes manual intervention requirements.

Comment on lines 7 to 10
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
- Automated Incident Creation: When an incident is triggered in Datadog, the snap-in automatically creates a corresponding incident in DevRev.
- Automated Incident Updation: When an incident is updated in Datadog, the changes are reflected in DevRev.
- Real-Time Synchronization: The snap-in ensures that incidents are created or updated in real-time, reducing delays between detection and resolution. DevRev captures the necessary incident details from the Datadog payload, allowing teams to address and mitigate issues.
- Real-time Synchronization: The snap-in ensures that incidents are created or updated in real-time, reducing delays between detection and resolution. DevRev captures the necessary incident details from the Datadog payload, allowing teams to address and mitigate issues.
- Seamless integration: The snap-in is built to streamline workflows, minimizing the need for manual intervention.
- Automated incident creation from Datadog triggers
- Automated incident updates synchronized from Datadog changes
- Real-time synchronization between platforms
- Seamless workflow integration with minimal manual intervention

Comment on lines 7 to 10
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
- Automated Incident Creation: When an incident is triggered in Datadog, the snap-in automatically creates a corresponding incident in DevRev.
- Automated Incident Updation: When an incident is updated in Datadog, the changes are reflected in DevRev.
- Real-Time Synchronization: The snap-in ensures that incidents are created or updated in real-time, reducing delays between detection and resolution. DevRev captures the necessary incident details from the Datadog payload, allowing teams to address and mitigate issues.
- Real-time Synchronization: The snap-in ensures that incidents are created or updated in real-time, reducing delays between detection and resolution. DevRev captures the necessary incident details from the Datadog payload, allowing teams to address and mitigate issues.
- Seamless integration: The snap-in is built to streamline workflows, minimizing the need for manual intervention.
- Creates incidents in DevRev automatically when triggered in Datadog.
- Updates incident details in DevRev when changes occur in Datadog.
- Synchronizes incident data in real-time between both platforms.
- Streamlines workflows by minimizing manual intervention requirements.

Comment on lines 7 to 10
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
- Automated Incident Creation: When an incident is triggered in Datadog, the snap-in automatically creates a corresponding incident in DevRev.
- Automated Incident Updation: When an incident is updated in Datadog, the changes are reflected in DevRev.
- Real-Time Synchronization: The snap-in ensures that incidents are created or updated in real-time, reducing delays between detection and resolution. DevRev captures the necessary incident details from the Datadog payload, allowing teams to address and mitigate issues.
- Real-time Synchronization: The snap-in ensures that incidents are created or updated in real-time, reducing delays between detection and resolution. DevRev captures the necessary incident details from the Datadog payload, allowing teams to address and mitigate issues.
- Seamless integration: The snap-in is built to streamline workflows, minimizing the need for manual intervention.
- Incident creation automation: The snap-in automatically creates corresponding incidents in DevRev when triggered in Datadog.
- Incident update synchronization: All Datadog incident updates are automatically reflected in DevRev.
- Real-time processing: The snap-in processes incident creation and updates immediately to reduce delays between detection and resolution.
- Workflow integration: Built-in automation eliminates the need for manual intervention in routine tasks.

Comment on lines 7 to 10
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
- Automated Incident Creation: When an incident is triggered in Datadog, the snap-in automatically creates a corresponding incident in DevRev.
- Automated Incident Updation: When an incident is updated in Datadog, the changes are reflected in DevRev.
- Real-Time Synchronization: The snap-in ensures that incidents are created or updated in real-time, reducing delays between detection and resolution. DevRev captures the necessary incident details from the Datadog payload, allowing teams to address and mitigate issues.
- Real-time Synchronization: The snap-in ensures that incidents are created or updated in real-time, reducing delays between detection and resolution. DevRev captures the necessary incident details from the Datadog payload, allowing teams to address and mitigate issues.
- Seamless integration: The snap-in is built to streamline workflows, minimizing the need for manual intervention.
- Automated incident creation: The snap-in creates corresponding incidents in DevRev when triggered in Datadog.
- Automated incident updates: Changes in Datadog incidents are automatically reflected in DevRev.
- Real-time synchronization: The snap-in ensures immediate creation and updates of incidents, reducing delays between detection and resolution.
- Seamless integration: The snap-in streamlines workflows by minimizing manual intervention.

Comment on lines 7 to 10
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
- Automated Incident Creation: When an incident is triggered in Datadog, the snap-in automatically creates a corresponding incident in DevRev.
- Automated Incident Updation: When an incident is updated in Datadog, the changes are reflected in DevRev.
- Real-Time Synchronization: The snap-in ensures that incidents are created or updated in real-time, reducing delays between detection and resolution. DevRev captures the necessary incident details from the Datadog payload, allowing teams to address and mitigate issues.
- Real-time Synchronization: The snap-in ensures that incidents are created or updated in real-time, reducing delays between detection and resolution. DevRev captures the necessary incident details from the Datadog payload, allowing teams to address and mitigate issues.
- Seamless integration: The snap-in is built to streamline workflows, minimizing the need for manual intervention.
- Automated incident creation: The snap-in creates corresponding incidents in DevRev when triggered in Datadog.
- Automated incident updates: Changes in Datadog incidents are automatically reflected in DevRev.
- Real-time synchronization: The snap-in ensures immediate creation and updates of incidents, reducing delays between detection and resolution.
- Seamless integration: Built-in workflow optimization minimizes manual intervention requirements.

Comment on lines 7 to 10
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
- Automated Incident Creation: When an incident is triggered in Datadog, the snap-in automatically creates a corresponding incident in DevRev.
- Automated Incident Updation: When an incident is updated in Datadog, the changes are reflected in DevRev.
- Real-Time Synchronization: The snap-in ensures that incidents are created or updated in real-time, reducing delays between detection and resolution. DevRev captures the necessary incident details from the Datadog payload, allowing teams to address and mitigate issues.
- Real-time Synchronization: The snap-in ensures that incidents are created or updated in real-time, reducing delays between detection and resolution. DevRev captures the necessary incident details from the Datadog payload, allowing teams to address and mitigate issues.
- Seamless integration: The snap-in is built to streamline workflows, minimizing the need for manual intervention.
- Creates incidents in DevRev automatically when triggered in DataDog.
- Updates incident details in DevRev when changes occur in DataDog.
- Synchronizes incident data in real-time between systems.
- Streamlines workflows by minimizing manual intervention.


### Installing the Snap-in
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
### Installing the Snap-in
### Install the snap-in

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
### Installing the Snap-in
### Install the snap-in

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
### Installing the Snap-in
### Set up the snap-in

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
### Installing the Snap-in
### Configure and install the snap-in

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
### Installing the Snap-in
### Install the snap-in

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
### Installing the Snap-in
### Install the snap-in

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
### Installing the Snap-in
### Install the snap-in

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
### Installing the Snap-in
### Install the snap-in

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
### Installing the Snap-in
### Install the snap-in

Expand Down
19 changes: 11 additions & 8 deletions stylecheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ def parse_diff_hunks(diff_text):
'path': path,
'line': old_start + old_lines - 1,
'side': 'RIGHT',
'body': f'```suggestion\n{added_lines}\n```'
'body': f'```suggestion\n{added_lines}\n```',
'commit_id': os.environ.get('COMMIT_SHA')
}
if old_start < comment['line']:
comment['start_line'] = old_start
Expand All @@ -128,20 +129,22 @@ def parse_diff_hunks(diff_text):

return comments

def post_review_comment(owner, repo, pr_number, comment):
comment['commit_id'] = os.environ.get('COMMIT')
def post_review_comment(comment):
owner = os.environ.get('REPO_OWNER')
repo = os.environ.get('REPO_NAME')
pr = os.environ.get('PR_NUMBER')

if comment.get('line'):
# Suggestion
url = f'https://api.github.com/repos/{owner}/{repo}/pulls/{pr_number}/comments'
url = f'https://api.github.com/repos/{owner}/{repo}/pulls/{pr}/comments'
message = f"Posted comment on line {comment['line']}."
else:
# Timeline comment
url = f'https://api.github.com/repos/{owner}/{repo}/issues/{pr_number}/comments'
url = f'https://api.github.com/repos/{owner}/{repo}/issues/{pr}/comments'
message = f"Posted comment on timeline."

headers = {
'Authorization': f"token {os.environ.get('STYLECHECK')}",
'Authorization': f"token {os.environ.get('GITHUB_TOKEN')}",
'Accept': 'application/vnd.github.v3+json'
}
try:
Expand Down Expand Up @@ -193,10 +196,10 @@ def main(args):
suggestions = parse_diff_hunks(diff)
my_writer(suggestions, f"temp/{doc_name}_suggestions.json", 'suggestions')
if (args.suggest):
post_review_comment(os.environ.get('OWNER'), os.environ.get('REPO'), os.environ.get('PR'), {'body': comment_text})
post_review_comment({'body': comment_text})
for suggestion in suggestions:
time.sleep(1)
post_review_comment(os.environ.get('OWNER'), os.environ.get('REPO'), os.environ.get('PR'), suggestion)
post_review_comment(suggestion)

if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Check writing style of markdown file")
Expand Down
Loading