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

checks: update assignment of platform URLs var #94

Merged
merged 2 commits into from
Feb 16, 2023

Conversation

miabbott
Copy link
Member

@miabbott miabbott commented Jan 20, 2023

This updates the script to be more ShellCheck compliant around the
assignment of the UPDATE_PLATFORM_URLS variable and the check to see
if the varible is empty. The existing functionality remains unchanged.

Thanks to @alcir for the suggested changes!

Closes: #93

@miabbott
Copy link
Member Author

I haven't tested this (which got us in trouble the first time), so let's hold off on merging until we have confidence in this change.

Copy link
Member

@pcdubs pcdubs left a comment

Choose a reason for hiding this comment

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

LGTM

@alcir
Copy link
Contributor

alcir commented Jan 23, 2023

I'm not a bash expert, but instead of disable shellcheck, here

UPDATE_PLATFORM_URLS=$(grep -P -ho 'http[s]?.*' $REPOS_DIRECTORY/*)

we could actually populate the UPDATE_PLATFORM_URLS array simply in this way

UPDATE_PLATFORM_URLS=($(grep -P -ho 'http[s]?.*' $REPOS_DIRECTORY/*))

or

readarray -t UPDATE_PLATFORM_URLS < <(grep -P -ho 'http[s]?.*' $REPOS_DIRECTORY/*)

@miabbott
Copy link
Member Author

miabbott commented Jan 24, 2023

I'm not a bash expert, but instead of disable shellcheck, here

UPDATE_PLATFORM_URLS=$(grep -P -ho 'http[s]?.*' $REPOS_DIRECTORY/*)

we could actually populate the UPDATE_PLATFORM_URLS array simply in this way

UPDATE_PLATFORM_URLS=($(grep -P -ho 'http[s]?.*' $REPOS_DIRECTORY/*))

or

readarray -t UPDATE_PLATFORM_URLS < <(grep -P -ho 'http[s]?.*' $REPOS_DIRECTORY/*)

I tried both methods of assigning the array; the first suggestion introduced an error with Shellcheck related to SC2207 and the second suggestion did not trigger any error.

However, if I remove the comment to disable the SC2048 check on line 16-17, the error returns regardless of how the array is originally assigned.

@alcir
Copy link
Contributor

alcir commented Jan 25, 2023

What about

8     mapfile -t UPDATE_PLATFORM_URLS < <(grep -P -ho 'http[s]?.*' "${REPOS_DIRECTORY}"/*)
9     if [[ ${#UPDATE_PLATFORM_URLS[@]} -eq 0 ]]; then
...
16     for UPDATE_PLATFORM_URL in "${UPDATE_PLATFORM_URLS[@]}"; do

Running shellcheck from command line doesn't return any error and the script works as intended.

@miabbott
Copy link
Member Author

miabbott commented Jan 26, 2023

This looks promising...I was heading in this direction but lack of time has kept me from pursuing this fully.

This updates the script to be more ShellCheck compliant around the
assignment of the UPDATE_PLATFORM_URLS variable and the check to see
if the varible is empty. The existing functionality remains unchanged.

Thanks to @alcir for the suggested changes!

Closes: fedora-iot#93
@miabbott miabbott changed the title disable shellcheck SC2048 on URL array checks: update assignment of platform URLs var Feb 15, 2023
@miabbott
Copy link
Member Author

⬆️ Pushed an update yesterday with the suggestions from @alcir; I did some light testing on a Fedora IoT system and verified it worked with the happy path and unhappy path.

@nullr0ute
Copy link
Member

@miabbott so the bats_test is failing, is that a problem or does the test need to be adjusted or is it unrelated to this? Other than that is this ready to review/merge?

@miabbott
Copy link
Member Author

@nullr0ute BATS is failing like this:

not ok 1 Ensure watchdog check is working
# (from function `source' in file /usr/lib/greenboot/check/required.d/02_watchdog.sh, line 47,
#  from function `setup' in test file check_watchdog_support.bats, line 4)
#   `source $GREENBOOT_DEFAULT_CHECK_PATH/required.d/02_watchdog.sh --source-only' failed
# No watchdog on the system, skipping check

Looking at the history of that test on other PRs, it is failing similarly, so I believe it is unrelated to this change.

I believe this is ready for review + merge

@nullr0ute nullr0ute merged commit 0d9563b into fedora-iot:main Feb 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Failing 01_update_platforms_check.sh on Fedora IoT
4 participants