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

Correct use of working directory with ansible-lint github action #4340

Merged
merged 1 commit into from
Sep 19, 2024

Conversation

ssbarnea
Copy link
Member

@ssbarnea ssbarnea commented Sep 19, 2024

Fixes: #4232
Related: #3938

@github-actions github-actions bot added the bug label Sep 19, 2024
@ssbarnea ssbarnea changed the title Improve testing of github action Correct use of working directory with ansible-lint github action Sep 19, 2024
@ssbarnea ssbarnea marked this pull request as ready for review September 19, 2024 14:06
@ssbarnea ssbarnea requested a review from a team as a code owner September 19, 2024 14:06
@ssbarnea ssbarnea requested review from Qalthos and shatakshiiii and removed request for a team September 19, 2024 14:06
@ssbarnea ssbarnea merged commit 4e3058f into main Sep 19, 2024
26 checks passed
@ssbarnea ssbarnea deleted the fix/action-working-dir branch September 19, 2024 14:40
shell: bash
env:
GH_ACTION_REF: ${{ github.action_ref || 'main' }}
working-directory: ${{ steps.inputs.outputs.working_directory }}
run: |
wget --output-document=${{ steps.inputs.outputs.working_directory }}/.git/ansible-lint-requirements.txt https://raw.githubusercontent.com/ansible/ansible-lint/$GH_ACTION_REF/.config/requirements-lock.txt
reqs_file=$(git rev-parse --show-toplevel)/.git/ansible-lint-requirements.txt
echo "reqs_file=$reqs_file\n" >> $GITHUB_OUTPUT

Choose a reason for hiding this comment

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

What's the \n for?

It's causing the following issue for me. See that the cache-dependency-path passed to setup-python includes this \n and appears to be the reason for its failure:

2024-09-19T14:58:48.8798941Z ##[group]Run ansible/ansible-lint@main
2024-09-19T14:58:48.8799414Z with:
2024-09-19T14:58:48.8799782Z   working_directory: ansible
2024-09-19T14:58:48.8800234Z   requirements_file: ansible/requirements.yml
2024-09-19T14:58:48.8800686Z   setup_python: true
2024-09-19T14:58:48.8801086Z   expected_return_code: 0
2024-09-19T14:58:48.8801416Z env:
2024-09-19T14:58:48.8801714Z   ANSIBLE_DIR: ansible
2024-09-19T14:58:48.8802111Z ##[endgroup]
2024-09-19T14:58:48.8994286Z ##[group]Run if [[ -n "ansible" ]]; then
2024-09-19T14:58:48.8994848Z �[36;1mif [[ -n "ansible" ]]; then�[0m
2024-09-19T14:58:48.8995531Z �[36;1m  echo "working_directory=ansible" >> $GITHUB_OUTPUT�[0m
2024-09-19T14:58:48.8996001Z �[36;1melse�[0m
2024-09-19T14:58:48.8996696Z �[36;1m  echo "working_directory=/home/runner/work/Infrastructure/Infrastructure" >> $GITHUB_OUTPUT�[0m
2024-09-19T14:58:48.8997379Z �[36;1mfi�[0m
2024-09-19T14:58:48.9022776Z shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
2024-09-19T14:58:48.9023509Z env:
2024-09-19T14:58:48.9023798Z   ANSIBLE_DIR: ansible
2024-09-19T14:58:48.9024156Z ##[endgroup]
2024-09-19T14:58:48.9137107Z ##[group]Run reqs_file=$(git rev-parse --show-toplevel)/.git/ansible-lint-requirements.txt
2024-09-19T14:58:48.9138042Z �[36;1mreqs_file=$(git rev-parse --show-toplevel)/.git/ansible-lint-requirements.txt�[0m
2024-09-19T14:58:48.9138755Z �[36;1mecho "reqs_file=$reqs_file\n" >> $GITHUB_OUTPUT�[0m
2024-09-19T14:58:48.9139735Z �[36;1mwget --output-document=$reqs_file https://raw.githubusercontent.com/ansible/ansible-lint/$GH_ACTION_REF/.config/requirements-lock.txt�[0m
2024-09-19T14:58:48.9162652Z shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
2024-09-19T14:58:48.9163168Z env:
2024-09-19T14:58:48.9163559Z   ANSIBLE_DIR: ansible
2024-09-19T14:58:48.9163886Z   GH_ACTION_REF: main
2024-09-19T14:58:48.9164253Z ##[endgroup]
2024-09-19T14:58:48.9269413Z --2024-09-19 14:58:48--  https://raw.githubusercontent.com/ansible/ansible-lint/main/.config/requirements-lock.txt
2024-09-19T14:58:48.9326901Z Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.111.133, 185.199.108.133, 185.199.109.133, ...
2024-09-19T14:58:48.9440840Z Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.111.133|:443... connected.
2024-09-19T14:58:49.0746183Z HTTP request sent, awaiting response... 200 OK
2024-09-19T14:58:49.0748853Z Length: 991 [text/plain]
2024-09-19T14:58:49.0751181Z Saving to: ‘/home/runner/work/Infrastructure/Infrastructure/.git/ansible-lint-requirements.txt’
2024-09-19T14:58:49.0752331Z 
2024-09-19T14:58:49.0752685Z      0K                                                       100% 69.5M=0s
2024-09-19T14:58:49.0753203Z 
2024-09-19T14:58:49.0754447Z 2024-09-19 14:58:49 (69.5 MB/s) - ‘/home/runner/work/Infrastructure/Infrastructure/.git/ansible-lint-requirements.txt’ saved [991/991]
2024-09-19T14:58:49.0756101Z 
2024-09-19T14:58:49.0839635Z ##[group]Run actions/setup-python@v5
2024-09-19T14:58:49.0840175Z with:
2024-09-19T14:58:49.0840451Z   cache: pip
2024-09-19T14:58:49.0841147Z   cache-dependency-path: /home/runner/work/Infrastructure/Infrastructure/.git/ansible-lint-requirements.txt\n
2024-09-19T14:58:49.0841982Z   python-version: 3.11
2024-09-19T14:58:49.0842347Z   check-latest: false
2024-09-19T14:58:49.0842891Z   token: ***
2024-09-19T14:58:49.0843217Z   update-environment: true
2024-09-19T14:58:49.0843602Z   allow-prereleases: false
2024-09-19T14:58:49.0844032Z env:
2024-09-19T14:58:49.0844329Z   ANSIBLE_DIR: ansible
2024-09-19T14:58:49.0844638Z ##[endgroup]
2024-09-19T14:58:49.2516582Z ##[group]Installed versions
2024-09-19T14:58:49.2593636Z Successfully set up CPython (3.11.10)
2024-09-19T14:58:49.2596613Z ##[endgroup]
2024-09-19T14:58:49.4989609Z ##[error]No file in /home/runner/work/Infrastructure/Infrastructure matched to [/home/runner/work/Infrastructure/Infrastructure/.git/ansible-lint-requirements.txt\n or **/pyproject.toml], make sure you have checked out the target repository

Choose a reason for hiding this comment

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

Solved by #4342.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants