-
Notifications
You must be signed in to change notification settings - Fork 141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Only lint modified files #47
Comments
It would be great to have this working. I'm just not quite sure if this will work nicely with GitHub annotations (see #1). In any case, this would be a follow-up to #46. It might also make sense to delegate the identification of modified files to another action (e.g. file-changes-action) and use that action's output as input for the |
This should be optional, because if a lint rule is changed, it should lint all source files again for new rules whether those files changed or not. |
@samuelmeuli went through #1 will read on github annotation over the weekend and see if there's a possibility for getting this in.
Nice fallback |
@theoomoregbee @samuelmeuli any progress on this issue? Thanks |
We had a blocker kinda as mentioned in #1 but had not gotten free time to go over GitHub annotations yet to see if there's a way around it. Will add it to my todo list for the week now and see if I can go over it on or before the weekend. |
Did some research regarding #1 and found a GitHub action that helps with annotation via a They just released a new version of runner that helps with composite actions https://docs.github.com/en/actions/creating-actions/about-actions#composite-run-steps-actions But it's not fully ready to support calling an action within another action yet (which I think is the main reason we need the composite action though lol actions/runner#646 (comment) Here are the next steps for composite actions: actions/runner#646 When expected action within action is released, we can leverage
|
A stale label has been added to this issue because it has been open 15 days with no activity. To keep this issue open, add a comment within 5 days. |
I think the only issue is that the linting path is hard-coded to I originally tried using
Lastly, my example does not take into account changes to rules. If any of those files change, you'll want to trigger a complete lint rather than just changed files. This could be accomplished with Here's a sample config, linting a subdirectory: steps:
# We need to check out the repo history... perhaps fetch-depth: 0 is not needed? TBD
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha || github.sha }}
# Also need to test if this is still necessary
- run: |
git fetch --no-tags --depth=1 origin ${{ github.event.pull_request.base.sha || github.event.push.before }}
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 16
cache: 'npm'
cache-dependency-path: 'packages/foobar/package-lock.json'
# Need to install eslint dependencies in the subdirectory (note in this example root/package.json must have eslint)
- name: Install Node.js dependencies
run: |
npm ci
cd packages/foobar && npm ci
# Now actually lint by setting files to an empty string, and telling it to use the base hash to compare to
- name: Lint packages/foobar
uses: shahyar/lint-action@master
with:
only_changes_from: ${{ github.event.pull_request.base.sha || github.event.push.before }}
eslint: true
eslint_dir: packages/foobar/
eslint_files: "" |
Any news on this? |
This package is basically unmaintained. The only changes getting merged are new linters. You can see my draft PR above (forked at |
It's incredibly frustrating that annotations don't work, but thank you @shahyar for the fork you've made. I'm really hopeful that someone smarter than me can figure out a way to work around the check_run API limitations pointed out here. Edit: it looks like maybe they figured it out over here https://github.com/tj-actions/eslint-changed-files |
It's what we're using for eslint, but as stylelint was next, requiring similar mechanics, I started looking around for combo-linters, and ended up here. One thing's for sure: "only lint modified files" is a hard requirement. |
I wandered into this thread trying to research how to do the same. Just FYI wanted to share that the changed file logic lives in a separate action here: https://github.com/tj-actions/changed-files/ |
I was going through the codebase to see how feasible to add this feature because we currently need it.
Suggestion
I was thinking of adding an extra param
[linter]_only_changed_files: boolean
(we can decide on the best name to go with).Then checking doing a quick diff of the current branch with
where:
$filter
: can be defaulted toACM
(added, copied and modified), more: https://git-scm.com/docs/git-diff#Documentation/git-diff.txt---diff-filterACDMRTUXB82308203$baseBranch
: we can get the base branch fromevent.pull_request.base.ref
$extensions
: e.g.js|.ts
or we use the default extension from the lint configurationI see you already swap
branch
forhasFork
here: https://github.com/samuelmeuli/lint-action/blob/a820202c34156c11c68a7c534178ac66e12758b9/src/git.js#L22We just need to do the same thing with the base repository:
base-fork
remote locallyDon't know if this is what you want to support @samuelmeuli else I can spin up a PR for this.
@samuelmeuli wdyt?
The text was updated successfully, but these errors were encountered: