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

Fix working directory when used as an github action #4213

Merged
merged 18 commits into from
Jun 21, 2024

Conversation

bkaraoren
Copy link
Contributor

@bkaraoren bkaraoren commented Jun 7, 2024

When used container, it is not working as statically defined. I believe this should be a bug.
During the wget step and also python steps it is not considered to be used what is set previously. Even the wget works on the working directory, the file saved to some other directory and not cnsiderd in the code level.

fails like below:

Run ansible/ansible-lint@main
  with:
    working_directory: /__w/git-repo/git-repo
    setup_python: true
Run if [[ -n "/__w/git-repo/git-repo" ]]; then
  if [[ -n "/__w/git-repo/git-repo" ]]; then
    echo "working_directory=/__w/git-org/git-repo" >> $GITHUB_OUTPUT
  else
    echo "working_directory=/opt/actions-runner/_work/git-repo/git-repo" >> $GITHUB_OUTPUT
  fi
  shell: bash --noprofile --norc -e -o pipefail {0}
Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
Run wget --output-document=/opt/actions-runner/_work/git-repo/git-repo/.git/ansible-lint-requirements.txt https://github.com/ansible/ansible-lint/$GH_ACTION_REF/.config/requirements-lock.txt
  wget --output-document=/opt/actions-runner/_work/git-repo/git-repo/.git/ansible-lint-requirements.txt https://github.com/ansible/ansible-lint/$GH_ACTION_REF/.config/requirements-lock.txt
  shell: bash --noprofile --norc -e -o pipefail {0}
  env:
    GH_ACTION_REF: main
Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
/opt/actions-runner/_work/git-repo/git-repo/.git/ansible-lint-requirements.txt: No such file or directory
Error: Process completed with exit code 1.

@bkaraoren bkaraoren requested a review from a team as a code owner June 7, 2024 13:31
@bkaraoren bkaraoren requested review from Qalthos and priyamsahoo and removed request for a team June 7, 2024 13:31
@github-actions github-actions bot added the bug label Jun 7, 2024
@bkaraoren bkaraoren marked this pull request as draft June 7, 2024 13:59
@bkaraoren bkaraoren marked this pull request as ready for review June 9, 2024 09:49
@ssbarnea ssbarnea changed the title fix working directory inside the container when used Fix working directory when used as an github action Jun 19, 2024
@ssbarnea ssbarnea enabled auto-merge (squash) June 19, 2024 20:52
@ssbarnea ssbarnea disabled auto-merge June 21, 2024 11:17
@ssbarnea
Copy link
Member

@bkaraoren When you created this PR, you did not allow maintainer to make changes to it, so I cannot update it. Can you please do this or enable this? so I can release the fix?

@bkaraoren
Copy link
Contributor Author

@bkaraoren When you created this PR, you did not allow maintainer to make changes to it, so I cannot update it. Can you please do this or enable this? so I can release the fix?

how can I grant this permission @ssbarnea ?

@ssbarnea
Copy link
Member

@bhavenst Search in page for "allow" or "maintainers" -- right sidebar, last option on PR view.

@ssbarnea ssbarnea merged commit b4018c2 into ansible:main Jun 21, 2024
21 of 23 checks passed
@@ -42,14 +42,14 @@ runs:
GH_ACTION_REF: ${{ github.action_ref || 'main' }}
working-directory: ${{ steps.inputs.outputs.working_directory }}
run: |
wget --output-document=${{ github.workspace}}/.git/ansible-lint-requirements.txt https://github.com/ansible/ansible-lint/$GH_ACTION_REF/.config/requirements-lock.txt
wget --output-document=${{ steps.inputs.outputs.working_directory }}/.git/ansible-lint-requirements.txt https://github.com/ansible/ansible-lint/$GH_ACTION_REF/.config/requirements-lock.txt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ${{ steps.inputs.outputs.working_directory }}/ prefix is redundant, as there is already for working-directory: setting the working directory for the shell command (wget included); I just created #4232 to hopefully fix this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope, this can not work. When you run this on a container it can not get correct working-directory from GITHUB environment variables. GITHUB environment variables are only available for the RUNNER, not on a container in RUNNER.

ptoscano added a commit to RedHatInsights/ansible-collections-insights that referenced this pull request Jun 26, 2024
Due to recent changes in the ansible-lint action [1], the location of
the output file download via wget is not correct.
Hence, for now add a fake structure to work also with the paths
calculated by the action.

[1] ansible/ansible-lint#4213

Signed-off-by: Pino Toscano <ptoscano@redhat.com>
ptoscano added a commit to RedHatInsights/ansible-collections-insights that referenced this pull request Jun 26, 2024
Due to recent changes in the ansible-lint action [1], the location of
the output file download via wget is not correct.
Hence, for now add a fake structure to work also with the paths
calculated by the action.

[1] ansible/ansible-lint#4213

Signed-off-by: Pino Toscano <ptoscano@redhat.com>
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.

3 participants