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

GitHub Action: properly respect the working_directory argument #3905

Merged
merged 2 commits into from
Nov 27, 2023
Merged

GitHub Action: properly respect the working_directory argument #3905

merged 2 commits into from
Nov 27, 2023

Conversation

ptoscano
Copy link
Contributor

PR #3798 introduced a working_directory argument to switch the base directory in which ansible-lint runs; while it seems a good idea, in practice it does not work properly.
When specifying a different working directory than github.workspace, the steps before the ansible-lint run are not run in that different directory, leading to wget and pip to fail because of .git not found.

Hence:

  • process the arguments earlier
  • use the working directory in all the steps that need it

This way the working directory passed as argument is available to all
the steps, not only the ansible-lint one.

Signed-off-by: Pino Toscano <[email protected]>
Make sure to respect the working directory when running the shell steps
and locating the files that are supposed to be in the working directory.

Signed-off-by: Pino Toscano <[email protected]>
@ptoscano ptoscano requested a review from a team as a code owner November 21, 2023 13:26
@ptoscano ptoscano requested review from a team, cristianonicolai and priyamsahoo and removed request for a team November 21, 2023 13:26
ptoscano added a commit to RedHatInsights/ansible-collections-insights that referenced this pull request Nov 23, 2023
Add a simple workflow to run ansible-lint on push and for pull requests.

ansible-lint requires a "ansible_collections/<namespace>/<name>/"
structure to recognize the collection and its bits, so check out the
code in that way. Also export few environment variables to locate all
the bits.

Sadly currently (ansible-lint v6.22.0) the action does not respect its
"working_directory" for all the steps, failing in its initial setup
steps; a potential fix has been proposed [1], so create a local
workaround to get the action to run in the meanwhile.

[1] ansible/ansible-lint#3905

Signed-off-by: Pino Toscano <[email protected]>
ptoscano added a commit to RedHatInsights/ansible-collections-insights that referenced this pull request Nov 27, 2023
Add a simple workflow to run ansible-lint on push and for pull requests.

ansible-lint requires a "ansible_collections/<namespace>/<name>/"
structure to recognize the collection and its bits, so check out the
code in that way. Also export few environment variables to locate all
the bits.

Sadly currently (ansible-lint v6.22.0) the action does not respect its
"working_directory" for all the steps, failing in its initial setup
steps; a potential fix has been proposed [1], so create a local
workaround to get the action to run in the meanwhile.

[1] ansible/ansible-lint#3905

Signed-off-by: Pino Toscano <[email protected]>
@ssbarnea ssbarnea added the bug label Nov 27, 2023
@ssbarnea ssbarnea merged commit 5fda814 into ansible:main Nov 27, 2023
24 checks passed
@ptoscano ptoscano deleted the gha-fix-workdir branch November 27, 2023 13:27
ptoscano added a commit to RedHatInsights/ansible-collections-insights that referenced this pull request Nov 30, 2023
There was a bug [1] in the ansible-lint action that made its
"working_directory" parameter not working as expected. This was fixed in
v6.22.1 [2].

Since we use the "v6" tag, which points to the latest version of
ansible-lint 6.x, the fixed action should be used already. Hence, drop
the workaround step.

[1] ansible/ansible-lint#3905
[2] https://github.com/ansible/ansible-lint/releases/tag/v6.22.1

Signed-off-by: Pino Toscano <[email protected]>
ahitacat pushed a commit to RedHatInsights/ansible-collections-insights that referenced this pull request Nov 30, 2023
There was a bug [1] in the ansible-lint action that made its
"working_directory" parameter not working as expected. This was fixed in
v6.22.1 [2].

Since we use the "v6" tag, which points to the latest version of
ansible-lint 6.x, the fixed action should be used already. Hence, drop
the workaround step.

[1] ansible/ansible-lint#3905
[2] https://github.com/ansible/ansible-lint/releases/tag/v6.22.1

Signed-off-by: Pino Toscano <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants