Skip to content

Add GitHub Actions workflow for linting with Ruff #2

Add GitHub Actions workflow for linting with Ruff

Add GitHub Actions workflow for linting with Ruff #2

Workflow file for this run

name: Lint with Ruff
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
lint:
runs-on: ubuntu-latest
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:

Check failure on line 31 in .github/workflows/lint-pr.yml

View workflow run for this annotation

GitHub Actions / Lint with Ruff

Invalid workflow file

The workflow is not valid. .github/workflows/lint-pr.yml (Line: 31, Col: 12): Unexpected value '' .github/workflows/lint-pr.yml (Line: 32, Col: 7): Unexpected value 'script'
script: |
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,
});
}