Add remotes.json auto updation script #81
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Should be merged after #79
This script automatically creates/updates the remotes.json file to be consumed by the custom build server, listing the versions allowed to be built. It scrapes firmware.ardupilot.org and the listed subdirectories, determining releases and their githash using the artifacts. Then, it creates an object with metadata and adds it to the list of remotes in remotes.json.
If the remotes.json file doesn't exist or there's an error parsing it, a new file is created, replacing the existing remotes.json. If the file already exists, entries for other remotes are preserved, overwriting only the entry for the remote named 'ardupilot'.
To maintain static entries for the remote 'ardupilot' (which cannot be overwritten by this script), we can add a remote entry with a different name (e.g., 'ap-static'), using the same URL for the 'ardupilot' remote: https://github.com/ardupilot/ardupilot.git.
A sample remotes.json file would resemble:
In this file, the fetch_releases.py script would update only the metadata under the object for the remote named 'ardupilot'. This model allows for dynamically updating the list of releases at custom.ardupilot.org, listing branches/tags for builds that are not standard releases, and allowing builds from different remotes.
Update:- We now do this using git tags after @peterbarker's suggestion. Also, we can securely trigger a refresh on the application by sending a POST request at
/refresh_remotes
endpoint after updating the file. The POST request should contain a token named CBS_REMOTES_RELOAD_TOKEN which is retrieved from the environment. This is used to make sure that any unauthorised user cannot trigger a refresh by hitting the above mentioned endpoint.