jerboa icon indicating copy to clipboard operation
jerboa copied to clipboard

Generate default instance list on build

Open pipe01 opened this issue 2 years ago • 10 comments

Added a script that will download a list of instances from https://the-federation.info/platform/73 using the GraphQL API, then write it to a file containing a constant.

Currently it'll get the top 10 instances with the most monthly users, but it can easily be changed to e.g. all instances with more than X monthly users instead. The script is called on every build but maybe it'd be better to only call it on release builds, not sure how to detect that though.

The script is written in Bash and thus will only work on Linux systems (it also requires jq and curl), so when building on other platforms a dummy instance list will be emitted.

Also migrated all Gradle build scripts to Kotlin, so fixes #6.

pipe01 avatar Jun 11 '23 01:06 pipe01

I really like this idea, but I would prefer it be done in a cross-platform manner rather than requiring shell scripts whose dependencies aren't explicitly documented.

twizmwazin avatar Jun 11 '23 02:06 twizmwazin

Jerboa shouldn't be dependent on running a script to pull a list from a website it doesn't control.

kinther avatar Jun 11 '23 16:06 kinther

On second thought, this would violate reproducible builds by default. Maybe instead, this could be a Gradle task that is run that updates the file, and then that file is committed to the repo. It would then be done before performing a release.

twizmwazin avatar Jun 11 '23 16:06 twizmwazin

Sure, it can just make it a separate task instead. I could write it in a Kotlin script, but AFAIK it would mean that the build.gradle file must be converted to Kotlin, and the code would get pretty ugly. Or maybe a python script instead?

pipe01 avatar Jun 11 '23 18:06 pipe01

A python script has the same problem as bash, unless gradle supports grabbing a python interpreter. There is another issue that suggests migrating the gradle build scripts to kotlin, I'd be in favor of that.

twizmwazin avatar Jun 11 '23 23:06 twizmwazin

Yeah that's true, I'll write it in Kotlin then.

pipe01 avatar Jun 11 '23 23:06 pipe01

I've migrated the build.gradle file to Kotlin and also translated the fetch script into Kotlin. The script is in a separate file which makes it neater, but apparently you can't import libraries from other .kts files so I had to use the built-in APIs. This was a bit of a pain to figure out, but the result doesn't look too bad.

To run the task just do ./gradlew fetchInstances

pipe01 avatar Jun 12 '23 01:06 pipe01

Where should I add the info on how to fetch the instances to the README? Maybe we should add a CONTRIBUTING file.

pipe01 avatar Jun 14 '23 01:06 pipe01

You're right, this would make more sense in a CONTRIBUTING.md.

Could you create that, and add just that info? I can rework it and add a few things about how to debug and such once that's done.

dessalines avatar Jun 14 '23 13:06 dessalines

You're right, this would make more sense in a CONTRIBUTING.md.

Could you create that, and add just that info? I can rework it and add a few things about how to debug and such once that's done.

Don't forget to add this info now that CONTRIBUTING.md has been merged

ZJouba avatar Jun 20 '23 08:06 ZJouba

Obsoleted by #884

twizmwazin avatar Jun 26 '23 16:06 twizmwazin