redlib-org / redlib-instances

GNU General Public License v3.0
41 stars 24 forks source link

If no onion or i2p sites exist in json file, the github action will always fail #53

Open sahal opened 1 month ago

sahal commented 1 month ago

Since #51 was merged in Actions have been failing: https://github.com/redlib-org/redlib-instances/actions

Screenshot_20240725_205735

It seems that maybe the last PR generated an instances.json without any .i2p or .onion links. I'm assuming (big assumption) that the instances.json file was generated with the -T flag.

The logic in the bash script is set to fail when jq exits non-zero.

    731         IFS=$'\n' imported_nonwww=($(jq -Mcer '.instances[] | select(.onion or .i2p)' "${import_nonwww_from_file}"))
    732         rc=$?
    733 
    734         if [[ ${rc} -ne 0 ]]
    735         then
    736             echo >&2 "Failed to read onion instances from existing JSON file."
    737             return 1
    738         fi
    739     fi

In my opinion, it should be logical to sometimes have a list of redlib instances without .onion or .i2p sites.

A lazy way to do this would be to set rc to 0 when you do not find .onion or .i2p in the json (via grep for example). I've proposed this in a linked PR.

Other options

  1. (schema fix) If you always expect an onion or i2p site to be running redlib then you'll have to check to see if people accidentally (or otherwise) generated the instances.json file without having Tor or I2p enabled. Maybe add a note to the json with the bash script flags or something.

  2. (process fix) Personally, I don't think its reasonable for people adding their own (or others) instances to have to run Tor to generate the instances.json. You might be able to solve this by always having the maintainers generate instances.json (assuming maintainers use Tor and i2p).

sahal commented 1 month ago

Just realized this failure might be a feature, not a bug. In that case, maybe its best to run the action at PR time too.