Skip to content
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

Swiftlint is still checking unchanged files #27

Open
stefangerard opened this issue Mar 4, 2020 · 15 comments
Open

Swiftlint is still checking unchanged files #27

stefangerard opened this issue Mar 4, 2020 · 15 comments

Comments

@stefangerard
Copy link

stefangerard commented Mar 4, 2020

SwiftLint is still checking unchanged files in my pull-requests even though I'm using the following swiftlint.yml config

name: SwiftLint

on:
  pull_request:
    paths:
      - '.github/workflows/swiftlint.yml'
      - '.swiftlint.yml'
      - '**/*.swift'
      - '!Pods/**'

jobs:
  SwiftLint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - name: GitHub Action for SwiftLint (Only files changed in the PR)
        uses: norio-nomura/[email protected]
        env:
          DIFF_BASE: ${{ github.base_ref }}
@stefangerard stefangerard changed the title Swiftlint still check unchanged files Swiftlint is still checking unchanged files Mar 4, 2020
@samh-depop
Copy link

I have the same issue.
I get this error message

fatal: Not a valid object name dev

dev is the value in ${{ github.base_ref }}

Anyway to fix that?

@kerrmarin
Copy link

Same issue here!

@dlackty
Copy link

dlackty commented Apr 22, 2020

@samh-depop @kerrmarin I've solved this problem with following action configs:

      - name: Fetch base ref
        run: git fetch --no-tags --prune --depth=1 origin ${{ github.base_ref }}
      - name: Run SwiftLint
        uses: norio-nomura/[email protected]
        with:
          args: --force-exclude
        env:
          DIFF_BASE: origin/${{ github.base_ref }}

@tudorsirbu
Copy link

I get the same issue with fatal: Not a valid object name dev. Has anyone managed to find a fix for this? I've tried what @dlackty has suggested but it doesn't review any files. It's saying no files changed. :(

@dlackty
Copy link

dlackty commented Jun 3, 2020

@stefangerard Do you add additional git fetch step to fetch base ref?

Could you share the whole workflow yml? I would like to help.

@BrentMifsud
Copy link

I have the same problem. using DIFF_BASE: ${{ gitHub.base_ref }} just results in:

no object master in the console log.

@akashnimare
Copy link

@theoriginalbit
Copy link

I too have noticed that github.base_ref isn't actually working like we'd expect.

Though I am getting a PR lint successfully when new commits are pushed, but when run locally linting fails. It seems that it is only linting against the changes that were pushed and not the entire PR? The pushed commits didn't have linting issues but also didn't fix the previous linting issues. Has anyone else experienced this issue while using github.base_ref? Should we be using github.ref instead? 🤔

@akashnimare it comes from the github context not env vars (look at github.base_ref docs)

@akashnimare
Copy link

I have tried out github_ref as well doesn't work as expected.

image

What's the best way to test out GitHub actions locally?

@theoriginalbit
Copy link

What's the best way to test out GitHub actions locally?

I haven't found a way. I just have a private repo that I do lots of commits on.

@akashnimare
Copy link

Internet says this tool could be used for testing actions locally.

@yo1995
Copy link

yo1995 commented Jul 6, 2020

Same issue here. Will opt-out changed file only till it works.

@rvilardo
Copy link

rvilardo commented Feb 5, 2021

having the same issue. Any clue?

@shrutis826
Copy link

Facing same issue, any solution suggested?

@ayoy
Copy link

ayoy commented Apr 15, 2022

The root cause is that the action cannot perform a diff against base branch, because the base branch has not been checked out by the workflow (hence fatal: Not a valid object: dev/main/master errors). If you fetch its most recent commit, then it's known to git locally and diff works.

- name: Fetch PR's target branch
  run: git fetch --no-tags --prune --depth=1 origin ${{ github.base_ref }}
- name: Run SwiftLint on files changed in the PR
  uses: norio-nomura/[email protected]
  with:
    args: --force-exclude
  env:
    DIFF_BASE: ${{ github.base_ref }}

It's similar to what @dlackty posted, although in my case origin/ doesn't seem to be needed (in fact it doesn't work that way). Works here, however it still prints that error 🤷

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests