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

Generate default instance list on build #508

Closed
wants to merge 7 commits into from

Conversation

pipe01
Copy link
Contributor

@pipe01 pipe01 commented Jun 11, 2023

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.

@twizmwazin
Copy link
Contributor

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.

@kinther
Copy link

kinther commented Jun 11, 2023

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

@twizmwazin
Copy link
Contributor

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.

@pipe01
Copy link
Contributor Author

pipe01 commented Jun 11, 2023

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?

@twizmwazin
Copy link
Contributor

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.

@pipe01
Copy link
Contributor Author

pipe01 commented Jun 11, 2023

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

@pipe01
Copy link
Contributor Author

pipe01 commented Jun 12, 2023

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

app/build.gradle.kts Show resolved Hide resolved
app/get_instances.gradle.kts Outdated Show resolved Hide resolved
app/get_instances.gradle.kts Show resolved Hide resolved
app/src/main/java/com/jerboa/DefaultInstances.kt Outdated Show resolved Hide resolved
@pipe01
Copy link
Contributor Author

pipe01 commented Jun 14, 2023

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

@dessalines
Copy link
Member

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.

@ZJouba
Copy link
Contributor

ZJouba commented Jun 20, 2023

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

@twizmwazin
Copy link
Contributor

Obsoleted by #884

@twizmwazin twizmwazin closed this Jun 26, 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.

Convert Gradle buildscripts to Kotlin script
5 participants