From 0a49120df2453dd4e0fe3f0be6e9864e9a6631af Mon Sep 17 00:00:00 2001 From: Ruth Cheesley Date: Sun, 2 Feb 2025 09:55:57 +0000 Subject: [PATCH] Restrict the linter to only files changed in the PR --- .github/workflows/linting.yml | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index 80ad930e..cab0b250 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -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: @@ -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 }} @@ -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.