action-swiftlint
action-swiftlint copied to clipboard
Swiftlint is still checking unchanged files
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 }}
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?
Same issue here!
@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 }}
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. :(
@stefangerard Do you add additional git fetch step to fetch base ref?
Could you share the whole workflow yml? I would like to help.
I have the same problem. using DIFF_BASE: ${{ gitHub.base_ref }}
just results in:
no object master
in the console log.
base_ref
is only available for forked repo I think -
https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables
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)
I have tried out github_ref
as well doesn't work as expected.
What's the best way to test out GitHub actions locally?
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.
Internet says this tool could be used for testing actions locally.
Same issue here. Will opt-out changed file only till it works.
having the same issue. Any clue?
Facing same issue, any solution suggested?
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 🤷