adafruit / ci-arduino

A script that will install all of the common dependencies for testing Arduino library builds using Github Actions
MIT License
115 stars 73 forks source link

Fault Detection of 'arduino-library' topic due to bash script error #178

Closed nkaaf closed 6 months ago

nkaaf commented 7 months ago

The execution of my workflow was successful, but I saw the warning "Warning: arduino-library is not found in this repo topic. Please add this tag in the About repo". I double checked my repo topics, but "arduino-library" is in there.

In the line above the warning, there is a bash error "ci/actions_install.sh: line 40: {: command not found".

I try to find the reason for this error and request a pull request after finding out the problem.

Workflow Source: https://github.com/nkaaf/Arduino-List/blob/638a66afd49261b5cf2b9fd690d9808c05a242c2/.github/workflows/githubci.yml Workflow execution: https://github.com/nkaaf/Arduino-List/actions/runs/7781242146/job/21215312938

tyeth commented 7 months ago

@nkaaf thanks for raising this issue and tracking down the culprit. Just playing around, and we can probably skip the temporary file with something like this if you fancy giving it a test, it seemed to detect your topics and fail gracefully with bad URLs (tested in new script using WSL/bash externally to actions_install.sh):

repo_topics=$(curl -f --request GET --url "https://api.github.com/repos/$GITHUB_REPOSITORY" || echo '{"topics":[]}')
repo_topics=$(jq -r '.topics[]' --jsonargs <<< $repo_topics )
tyeth commented 7 months ago

It occurred to me we could eventually get a length issue, so maybe echoing the variable to jq in the second line is more sensible (passing as STDIN rather than command line arguments)

repo_topics=$(curl -f --request GET --url "https://api.github.com/repos/$GITHUB_REPOSITORY" || echo '{"topics":[]}')
repo_topics=$(echo $repo_topics | jq -r '.topics[]' )
nkaaf commented 7 months ago

I have tested your second approach too and it worked. The output of a private/non-existing repository would be the error message of curl, that 404 occurred. If you want to, you can close my PR #179 and create a new one with your solution.

tyeth commented 7 months ago

I found the output visually from curl showed the 404 response json message along with usual download info, but the -f flag meant it shortcutted to instead assigning the default echo value on non 200 success code. Made me wonder about the --slient flag to stop the extra output. Thanks for taking a look. I've got to merge in something else so may slip it in then.

nkaaf commented 6 months ago

Fixed in #180