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

Regression - GH action fails to download requirements if .git directory missing in work dir #4323

Closed
tigattack opened this issue Sep 10, 2024 · 2 comments
Labels
bug new Triage required

Comments

@tigattack
Copy link

tigattack commented Sep 10, 2024

Summary

Relates to #3938

This is a regression of the fix in #4103, which was undone by #4213. As a result, this problem has resurfaced in the same use case that the original fix was meant to resolve.

For clarification this affects all users who are setting the working_directory input to a path other than the root of a repository (i.e. a path containing a .git directory). For such users, it is breaking!

Since https://github.com/ansible/ansible-lint/blob/main/action.yml#L49 explicitly references ${{ steps.inputs.outputs.working_directory }}/.git, the action simply fails as soon as it reaches this point when a .git directory does not exist in the current path.

Given that the user is allowed to define an arbitrary working directory, assuming the existence of .git within the set path seems (and is proving to be) very fragile.

Issue Type
  • Bug Report
OS / ENVIRONMENT

github actions

STEPS TO REPRODUCE

ansible-lint workflow:

- uses: actions/checkout@v4
- uses: ansible/ansible-lint@main
  with:
    working_directory: ansible
    requirements_file: ansible/requirements.yml
Desired Behavior

Requirements file is downloaded to a path that exists, whether pre-existing or created at runtime.

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).

2024-09-10T11:18:27.0870375Z ##[group]Run wget --output-document=ansible/.git/ansible-lint-requirements.txt https://raw.githubusercontent.com/ansible/ansible-lint/$GH_ACTION_REF/.config/requirements-lock.txt
2024-09-10T11:18:27.0872062Z �[36;1mwget --output-document=ansible/.git/ansible-lint-requirements.txt https://raw.githubusercontent.com/ansible/ansible-lint/$GH_ACTION_REF/.config/requirements-lock.txt�[0m
2024-09-10T11:18:27.0895305Z shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
2024-09-10T11:18:27.0895919Z env:
2024-09-10T11:18:27.0896190Z   ANSIBLE_DIR: ansible
2024-09-10T11:18:27.0896543Z   GH_ACTION_REF: main
2024-09-10T11:18:27.0896976Z ##[endgroup]
2024-09-10T11:18:27.0982808Z ansible/.git/ansible-lint-requirements.txt: No such file or directory
2024-09-10T11:18:27.0998516Z ##[error]Process completed with exit code 1.
@tigattack tigattack added bug new Triage required labels Sep 10, 2024
@tigattack tigattack changed the title Regression - github action fails to download ansible-lint-requirements.txt when working directory is not repo root Regression - GH action fails to download requirements if .git directory missing in work dir Sep 11, 2024
@audgirka
Copy link
Contributor

@tigattack could you confirm if this is fixed?

@tigattack
Copy link
Author

tigattack commented Sep 24, 2024

It has! Apologies, I didn't yet test the changes since the fix in v24.9.2. Thanks all, much appreciated ❤️

Solved by #4340.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug new Triage required
Projects
Archived in project
Development

No branches or pull requests

2 participants