rojopolis / spellcheck-github-actions

Spell check action
MIT License
132 stars 38 forks source link

Ability to run only on files modified in a PR. #33

Closed vybhav72954 closed 3 years ago

vybhav72954 commented 3 years ago

Even though am using:

on:
  pull_request:
    branches: [ master ]

The action still runs on the Whole Codebase.

This makes action really slow for a huge Repository, it would be great if we can only check files modified in a PR.

facelessuser commented 3 years ago

What do you mean it runs on the whole code base? You have it specified to run on only pull_request. Are you saying it is running on pushes to master? If so, that doesn't make sense unless there is more in your config that you aren't showing.

vybhav72954 commented 3 years ago

I will post my config file yml file and screenshot here 😄

vybhav72954 commented 3 years ago

my workflow file- error1

My Conifg File

matrix:
- name: Markdown
  aspell:
    lang: en
  dictionary:
    wordlists:
    - .github/linters/.wordlist.txt
    encoding: utf-8
  pipeline:
  - pyspelling.filters.markdown:
  - pyspelling.filters.html:
    comments: false
    ignores:
    - code
    - pre
  sources:
  - '**/*.md'
  default_encoding: utf-8

The Action going through whole codebase

error

Is the

sources:
  - '**/*.md'

causing this? (In the config file)

facelessuser commented 3 years ago

I'm still confused. It looks like it is going through your Markdown files as you specified.

I still don't know what you mean by going through your "whole codebase". It looks like it is doing exactly what you are telling it to do. If not, you'll have to be more clear.

vybhav72954 commented 3 years ago

Yes, it is going through all the Markdown Files in my whole Repo!!!

My point is, is it possible, that it runs on only those md files, which are edited or modified in a PR only.

Just as example

tb

You can see that I only have 1 md file in this PR, but the action running on all the md files. What I am trying to say is, can I do something, so that it runs on only the files modified in the PR, in this case, Troubleshoot.md

vybhav72954 commented 3 years ago

Linked PR - HarshCasper/Rotten-Scripts#698

facelessuser commented 3 years ago

PySpelling does not check git status of files. I guess you could come up with an elaborate system that gathers git status of files and generates or modifies a pyspelling config to target only the files in the pull request.

It's possible it could be added as a feature in PySpelling at some point. I'm not promising such a feature, just mentioning that it might be a possibility. What I don't want to do is open the door for supporting multiple version control system status, as that would kind of be a pain.

vybhav72954 commented 3 years ago

I understand your point. So as of now, I believe that one such functionality is not a part of the project.

I can definitely come up with ideas to implement this. You can certainly close the issue now, if I will come up with something I will open a PR and will reopen the issue, only if you think that contribution is required that is.

facelessuser commented 3 years ago

Well, this repository is the GitHub action. I do not maintain this repository. It is mainly a wrapper around PySpelling (which I do maintain). If I were to integrate such functionality it would be there: https://github.com/facelessuser/pyspelling. I assume there would be some kind of hook to filter out files that were captured by the source pattern. If I did this, maybe people could use a plugin to override the hook to filter by git status or whatever. Again, I haven't put much thought into this yet, nor am I committing to such a thing, but that is just what I'm thinking right now.

miff2000 commented 3 years ago

I'm actually working on getting this added @vybhav72954. I have the same use case as you. Currently, this GitHub Action uses the sources specified in the pyspelling.yaml file (or config_path override passed into the Action). This means your sources: section would need to have a list of the changes files in your PR, which is a pain to achieve.

I'm putting together a PR to allow you to provide a list of files to the GitHub Action, which will be passed into PySpelling in the form of --name <task_name> --source <path1> --source <path2> flags. Provided that gets merged in, it'll serve your purpose.

To get a list of changes files in the PR, I currently use this config in my GitHub Actions test file:

name: Check files
on: [pull_request, push]
jobs:
  check:
    runs-on: ubuntu-latest
    steps:
      - name: Check out source files
        uses: actions/checkout@v2

      - name: Get a list of changed files
        uses: jitterbit/get-changed-files@v1
        id: changed_files

      - name: Run initial tests
        run: ./tests.sh ${{ steps.changed_files.outputs.all }}

So the only thing I've not taken care of here is only checking *.md files.

vybhav72954 commented 3 years ago
- name: Detect Files
      uses: dorny/paths-filter@v2.6.0
      id: filter
      with:
        # Enable listing of files matching each filter.
        # Paths to files will be available in `${FILTER_NAME}_files` output variable.
        # Paths will be escaped and space-delimited.
        # Output is usable as command-line argument list in linux shell
        list-files: shell

        # In this example changed files will be checked by linter.
        # It doesn't make sense to lint deleted files.
        # Therefore we specify we are only interested in added or modified files.
        filters: |
          python:
            - added|modified: '**.py'

I use something like this to detect changed files in a PR in one of my Repos. (For Python here)

miff2000 commented 3 years ago

Nice, so that pretty much covers it all off, once my is approved, I think?

vybhav72954 commented 3 years ago

Seems like it, but it still depends on the Owner, whether he wants to incorporate another action or hard code it himself, but for now I believe your PR can solve this issue. Will test run once then update

edumco commented 3 years ago

This is closed by #34