Skip to content
Merged
Changes from all 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
61 changes: 61 additions & 0 deletions .github/workflows/lint-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Lint with Ruff

on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
lint:
runs-on: ubuntu-latest

permissions:
pull-requests: write
issues: write

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v4

- name: Set up Python
run: uv python install

- name: Install the project
run: uv sync --all-extras --dev

- name: Run Ruff
id: run_ruff
run: |
uv run ruff check . > ruff_output.txt || true

- name: Post PR comment
uses: actions/github-script@v6
with:
script: |
const fs = require('fs');
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
});

const botComment = comments.find(comment => comment.user.login === 'github-actions[bot]');
const body = `## Ruff\n\`\`\`\n${fs.readFileSync('ruff_output.txt', 'utf8')}\n\`\`\``;

if (botComment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body,
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
body,
});
}
Loading