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

test: debug why tests_lvm_pool_members_nvme_generated fails #504

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion .github/workflows/ansible-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,44 @@ jobs:
pip3 install "git+https://github.com/linux-system-roles/[email protected]"

- name: Convert role to collection format
id: collection
run: |
set -euxo pipefail
TOXENV=collection lsr_ci_runtox
coll_dir=".tox/ansible_collections/$LSR_ROLE2COLL_NAMESPACE/$LSR_ROLE2COLL_NAME"
# ansible-lint action requires a .git directory???
# https://github.com/ansible/ansible-lint/blob/main/action.yml#L45
mkdir -p "$coll_dir/.git"
meta_req_file="${{ github.workspace }}/meta/collection-requirements.yml"
test_req_file="${{ github.workspace }}/tests/collection-requirements.yml"
if [ -f "$meta_req_file" ] && [ -f "$test_req_file" ]; then
coll_req_file="${{ github.workspace }}/req.yml"
python -c 'import sys; import yaml
hsh1 = yaml.safe_load(open(sys.argv[1]))
hsh2 = yaml.safe_load(open(sys.argv[2]))
coll = {}
for item in hsh1["collections"] + hsh2["collections"]:
if isinstance(item, dict):
name = item["name"]
rec = item
else:
name = item # assume string
rec = {"name": name}
if name not in coll:
coll[name] = rec
hsh1["collections"] = list(coll.values())
yaml.safe_dump(hsh1, open(sys.argv[3], "w"))' "$meta_req_file" "$test_req_file" "$coll_req_file"
elif [ -f "$meta_req_file" ]; then
coll_req_file="$meta_req_file"
elif [ -f "$test_req_file" ]; then
coll_req_file="$test_req_file"
else
coll_req_file=""
fi
echo "coll_req_file=$coll_req_file" >> $GITHUB_OUTPUT

- name: Run ansible-lint
uses: ansible/ansible-lint@v24
uses: ansible/ansible-lint@v25
with:
working_directory: ${{ github.workspace }}/.tox/ansible_collections/${{ env.LSR_ROLE2COLL_NAMESPACE }}/${{ env.LSR_ROLE2COLL_NAME }}
requirements_file: ${{ steps.collection.outputs.coll_req_file }}
12 changes: 10 additions & 2 deletions library/find_unused_disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,17 @@
sector_sizes[ss].append(path)
else:
sector_sizes[ss] = [path]
disks = [os.path.basename(p) for p in max(sector_sizes.values(), key=len)]
try:
disks = [os.path.basename(p) for p in max(sector_sizes.values(), key=len)]
except ValueError as ve:
result["info"] = info
module.fail_json(msg=str(ve), **result)

Check warning on line 252 in library/find_unused_disk.py

View check run for this annotation

Codecov / codecov/patch

library/find_unused_disk.py#L248-L252

Added lines #L248 - L252 were not covered by tests
else:
disks = [os.path.basename(p) for p in disks.keys()]
try:
disks = [os.path.basename(p) for p in disks.keys()]
except ValueError as ve:
result["info"] = info
module.fail_json(msg=str(ve), **result)

Check warning on line 258 in library/find_unused_disk.py

View check run for this annotation

Codecov / codecov/patch

library/find_unused_disk.py#L254-L258

Added lines #L254 - L258 were not covered by tests

if not disks:
result['disks'] = "Unable to find unused disk"
Expand Down