Skip to content

Commit

Permalink
Restrict the linter to only files changed in the PR
Browse files Browse the repository at this point in the history
  • Loading branch information
RCheesley authored Feb 2, 2025
1 parent e185f2b commit 0a49120
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
The workflow is currently configured to check the entire `docs` folder, which can be time-consuming and unnecessary when only a few files are modified in a pull request. Instead, you can modify the workflow to check only the files changed in the PR. Here's how to fix it:

1. **Use `paths` filter**: This will limit the workflow to run only when files in specific paths are changed.
2. **Use environment variables**: Set up environment variables to capture the changed files.
3. **Modify the Vale step**: Adjust the Vale step to process only the changed files.

Here is the updated workflow with the necessary changes:

```yaml
name: Linting
on:
pull_request:
paths:
- 'docs/**'
jobs:
prose:
Expand All @@ -22,13 +33,17 @@ jobs:
- name: Install Python dependencies
run: pip3 install -r docs/requirements.txt
- name: Get changed files
id: changed-files
run: |
echo "::set-output name=files::$(git diff --name-only ${{ github.base_ref }} ${{ github.head_ref }} | grep '^docs/')"
- name: Vale
uses: errata-ai/vale-action@reviewdog
with:
filter_mode: added
# Please keep version in sync with the version in .gitpod.Dockerfile for a consistent experience
version: 3.7.1
files: docs/
files: ${{ steps.changed-files.outputs.files }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -53,3 +68,8 @@ jobs:
- name: Check links
working-directory: docs
run: make checklinks
```

This updates the workflow to:
- Run only when files in the `docs` directory are changed.
- Capture the changed files and pass them to the Vale action, ensuring only those files are checked.

0 comments on commit 0a49120

Please sign in to comment.