-
Notifications
You must be signed in to change notification settings - Fork 664
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
github action fails to download ansible-lint-requirements.txt, assumes .git dir exists in working directory #3938
Comments
Look at our action usage example https://github.com/ansible/ansible-lint --- you MUST clone before calling the action or it will fail. |
I am doing so. Here's the full workflow (private repo so no link, sorry): ---
name: Ansible Lint
on:
push:
paths: ['ansible/**']
workflow_dispatch:
jobs:
lint:
name: Ansible Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Run ansible-lint
uses: ansible/ansible-lint@v6.22.1
with:
working_directory: ansible As described in the initial issue, because I am setting the working directory to a subdirectory of the cloned repository, there is no As a result, |
This is also an issue if you're using self-hosted runners with |
Is it fair to paraphrase this bug as: ansible-lint is broken for monorepo users? I.e. those who put automation/ansible scripts in a subdirectory, and happen to use anything outside of |
I think that's a separate issue from this @ajfabbri |
@jhg03a can you elaborate? IIUC this bug is the thing keeping us from being able to use ansible-lint on files with requirements (outside of ansible.builtins) in our monorepo CI. Since our ansible scripts are in a subdirectory, and |
The action is not supposed to work on sparse checkouts. You need a .git folder. I will closing this as a wont fix because I do not think there is anything we can do. If we decide to dump the requirements lock file in to the current directory, we might broke the codebase because we would create a file that is not tracked or ignored by git. Use of It should also be noted that the security model used by GHA does not allow us to write files to other random locations on disk outside current project directory. Still, if someone finds a better solution for this, we will be more than happy to consider it. |
Setting `working_directory` for ansible-lint action would fail due to hard-coded `.git`, introduced in commit 6f728e0, when fetching `.config/requirements-lock.txt`, introduced in This fix replaces `.git` with `${{ github.workspace }}/.git` to make `working_directory` argument work again.
Fix ansible#3938: don't assume working_directory is github.workspace
Setting `working_directory` for ansible-lint action would fail due to hard-coded `.git`, introduced in commit 6f728e0, when fetching `.config/requirements-lock.txt`, introduced in This fix replaces `.git` with `${{ github.workspace }}/.git` to make `working_directory` argument work again.
Setting `working_directory` for ansible-lint action would fail due to hard-coded `.git`, introduced in commit 6f728e0, when fetching `.config/requirements-lock.txt`. This fix replaces `.git` with `${{ github.workspace }}/.git` to make `working_directory` argument work again.
Thanks for looking @ssbarnea. The description here is a bit confusing, but it does not require a sparse checkout to reproduce. The linked PR has a fix and the description includes the GH action I'm using to test it. Hope this helps. |
Summary
Issue Type
OS / ENVIRONMENT
github actions
STEPS TO REPRODUCE
ansible-lint workflow:
Desired Behavior
Requirements file is downloaded to a path that exists and used successfully.
Actual Behavior
It seems that the action assumes there will be a
.git
directory, which isn't necessarily the case if using anything other than the repository root as the working directory (such as shown in the example above).The text was updated successfully, but these errors were encountered: