ansible / ansible-lint-action

❗️Replaced by https://github.com/marketplace/actions/run-ansible-lint
https://github.com/marketplace/actions/run-ansible-lint
MIT License
254 stars 132 forks source link

Failed to discover lintable files using git: (Warning and Error) #135

Closed sbates130272 closed 1 year ago

sbates130272 commented 1 year ago

Hi

I am running a simple workflow using a GitHub Ubuntu 22.04 runner and hiting this error when I run the ansiblie-lint action. Interestingly I get the same warning and error if I add the mentioned gif config step to the workflow.

WARNING  Failed to discover lintable files using git: fatal: detected dubious ownership in repository at '/github/workspace' To add an exception for this directory, call:      git config --global --add safe.directory /github/workspace

Here is my workflow:

name: batesste-ansible Github Workflow
on: [push, pull_request]

jobs:
  build:
    runs-on: ubuntu-22.04
    steps:
      - name: Checkout code
        uses: actions/checkout@v3
      - name: Render the checkout directory safe for the lint step
        run: git config --global --add safe.directory /github/workspace
      - name: GitHub spellcheck action
        uses: rojopolis/spellcheck-github-actions@0.27.0
      - name: Run ansible-lint
        uses: ansible-community/ansible-lint-action@main
ssbarnea commented 1 year ago

Unable to reproduce, please post link to job failing with current version.

hemberger commented 1 year ago

I'm still seeing this issue with the latest version of the action (6.10.0). Here's an example job:

https://github.com/smrealms/seed-server/actions/runs/3779503586/jobs/6424809722

Note that I'm not using git config --global --add safe.directory /github/workspace in my workflow. Is this actually the recommended solution? Here's my workflow:

jobs:
  lint:
    name: Ansible Lint
    runs-on: ubuntu-22.04

    steps:
      - name: Checkout the source code
        uses: actions/checkout@v3

      - name: Run ansible-lint
        uses: ansible-community/ansible-lint-action@v6.10.0
MikeJansen commented 1 year ago

I'm getting the same. I note that my output from actions/checkout has:

/usr/bin/git config --global --add safe.directory /home/runner/work/XXX

But the ansible/ansible-lint-action has:

WARNING  Failed to discover lintable files using git: fatal: 
   detected dubious ownership in repository at '/github/workspace'
To add an exception for this directory, call:

    git config --global --add safe.directory /github/workspace

My jobs spec is almost identical:

jobs:
  ansible-lint:
    runs-on: ubuntu-22.04
    steps:
      - uses: actions/checkout@v3
      - uses: ansible/ansible-lint-action@v6

EDIT: Just noticed the bind mount on the docker run which explains the /home/runner/work... => /github/workspace.

MikeJansen commented 1 year ago

Might be related to https://github.com/actions/runner/issues/2033 ? Might have to do with the docker container being launched as root user as mentioned in this comment.

ssbarnea commented 1 year ago

@MikeJansen Don't worry, I have multiple ways of addressing it in next release.