tj-actions/eslint-changed-files

[BUG] Changed files from Pull Request wrong

Closed this issue · 4 comments

I noticed that the way the action is pulling in the files from Git to determine the changed files seems to be odd. In my case the head ref sha1 is different than the PR commit sha1.

Have you seen this before? Is this an easy fix?

Here is my action usage:

name: Lint

on: pull_request

defaults:
  run:
    working-directory: ./resources/assets

jobs:
  eslint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          ref: ${{ github.head_ref }}
      
      - uses: actions/setup-node@v2
        with:
          node-version: 12

      - name: Install modules
        run: npm install
        
      - uses: tj-actions/eslint-changed-files@v6.4
        with:
          token: ${{ github.token }}
          config_path: "resources/assets/.eslintrc.js"
          extensions: "js,vue"
          extra_args: "--fix"

      - uses: stefanzweifel/git-auto-commit-action@v4
        with:
          status_options: '--untracked-files=no'
          add_options: '-u'
          skip_dirty_check: false
          skip_fetch: true
          disable_globbing: true

It seems to be caused by the target branch somehow using develop when I'm on a PR branch. Is there somehow I could pass in the ref as an input like the actions/checkout@v2 action?

This seems like a different issue.

The current design is to determine files that have changed relative to the default branch.

develop <- my PR (only run eslint on those files that I made changes to)

The head sha is the last commit on develop as opposed to the PR branch since the diff is based on
the commit you made on develop against what files you modified in the PR.

To support changing the ref would be a new feature as opposed to a bug.

Thanks for the reply @jackton1. Maybe I'm doing something wrong. I updated that example above if you have any ideas I'm willing to give anything a try. I have an auto-commit action at the very end which depending on the checkout ref either that breaks or this one and I'm not sure exactly what is the right solution.

@dmyers Sorry for the delay on this, the latest change which would be released soon would include a clear message of the branch and the sha used.

NOTE: The diff is always based on changes in a PR branch i.e What files have been modified in my PR relative to the default branch. Using the checkout action it merges your base branch into your current PR which is why the github displayed sha is different from what you see in the logs.

Screen Shot 2021-06-17 at 9 56 31 AM
Screen Shot 2021-06-17 at 9 56 50 AM

Notice the displayed branch sha is 5f7dba4 and in the logs it shows dfa... because

Screen Shot 2021-06-17 at 9 58 46 AM