The tooling that mirrors the catalogued repositories into this instance and reports on them | Read-only mirror of https://codefloe.com/lsmith/forgejo-mirror-sync — open-source-ecosystem. Issues & pull requests at the source.
  • Python 76.7%
  • Shell 23.3%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-12-04 21:40:35 +01:00
deploy sync: --models-only (MODELS_ONLY=1) runs the model scan alone and leaves the run report as it is; redeploy.sh --run-models starts it 2026-12-03 17:43:52 +01:00
docs Set a mirror's default branch again when its upstream deleted it 2026-11-23 08:39:42 +01:00
tests metrics: the page has an AI models section from models.json: models named in code and their bases, the repositories and organisations naming them, hub size, gated and unlicensed models, unpinned names, bill-of-materials declarations and Software Heritage coverage 2026-12-04 21:40:35 +01:00
.gitignore Add the MIT licence, ignore rules for instance data and credentials, and a README opening 2026-11-19 10:09:27 +01:00
apply.py Drop the claim that the CronJob image has no git 2026-11-23 09:03:47 +01:00
check_mirror_health.py Read each instance's settings from INSTANCE_DIR instead of the code 2026-11-19 10:44:30 +01:00
check_upstream.py Docs and usage lines follow the instance layout 2026-11-19 11:01:17 +01:00
forgejo.py mirrors: the shared repository listing can return full repository objects, for callers that need updated_at and the default branch 2026-11-17 15:54:27 +01:00
init_instance.py mirrors: say what a held repository's ticket, label and alert mean 2026-09-15 13:25:28 +02:00
instance.py Stop early and say why when an instance is set up wrong 2026-11-19 11:01:17 +01:00
LICENSE Add the MIT licence, ignore rules for instance data and credentials, and a README opening 2026-11-19 10:09:27 +01:00
liveness.py Read each instance's settings from INSTANCE_DIR instead of the code 2026-11-19 10:44:30 +01:00
metrics.py metrics: the page has an AI models section from models.json: models named in code and their bases, the repositories and organisations naming them, hub size, gated and unlicensed models, unpinned names, bill-of-materials declarations and Software Heritage coverage 2026-12-04 21:40:35 +01:00
publiccode_checks.py the content checks' GitHub fields and the reading of their answer live in publiccode_checks.py, so a catalogue generator only adds them to its query and passes its vocabulary 2026-12-02 20:01:07 +01:00
README.md models: a git repository a bill of materials declares as holding a model is archived like a hub model; models are hunted for on the hub only, and weight files found in a repository never list it 2026-12-03 13:56:45 +01:00
scan_models.py scan_models: a new SBOM reader re-reads only repositories that had a bill of materials; a new file name (BOM_NAMES) still re-reads every repository 2026-12-03 16:21:03 +01:00
scan_publiccode.py catalogue entries whose publiccode.yml contradicts the repository (stale releaseDate or softwareVersion, expired contract, missing or unrecognised publisher URI) are tagged publiccode-check and listed in the report with what to change 2026-12-01 20:56:05 +01:00
seed_archived_repo.py Read each instance's settings from INSTANCE_DIR instead of the code 2026-11-19 10:44:30 +01:00
set_org_avatars.py Read each instance's settings from INSTANCE_DIR instead of the code 2026-11-19 10:44:30 +01:00
smoke.sh the Software Heritage save also covers the repositories in SWH_SAVE_ALSO, each asked on its own 2026-12-02 20:01:14 +01:00
sync.py sync: --models-only (MODELS_ONLY=1) runs the model scan alone and leaves the run report as it is; redeploy.sh --run-models starts it 2026-12-03 17:43:52 +01:00

forgejo-mirror-sync

Mirrors a curated list of public code repositories into a Forgejo instance and reports on them: whether each upstream still exists, its publiccode.yml, and the AI models the code uses. It runs git.opencode.swiss, the read-only mirror described in opencode-forges, and is meant to be reusable by other instances. Each instance keeps its own settings in a directory of its own; git.opencode.swiss's are in opencode-forges.

This code was written with the help of AI assistants (Claude). It is published under the MIT licence.

What a run does

sync.py is the entry point. A scheduled run:

  1. Regenerates the mirror sets from the catalogues the instance trusts, so a repository a catalogue adds is picked up without anyone editing a list.
  2. Creates the missing mirrors as native Forgejo pull mirrors, one organisation per upstream owner. Forgejo keeps them in sync on its own schedule.
  3. Holds what needs a person: a new organisation, or a repository over the size cap, waits until someone approves the ticket the run opens for it.
  4. Checks each upstream, pausing mirrors whose upstream is gone and keeping them readable.
  5. Tags every repository with topics such as its sector, a missing licence and whether it has a publiccode.yml, so visitors can filter.
  6. Lists the AI models the mirrored code uses, with a digest of every file of each revision.
  7. Publishes a report of what changed to a repository on the instance, and alerts when something needs attention.

Without --apply, a run only reports and changes nothing.

Scripts

Script What it does
sync.py Runs the steps above in order, and writes the report
apply.py Creates mirrors and organisations from a mirror set, and sets topics; safe to run again
scan_publiccode.py Finds which mirrors carry a publiccode.yml
scan_models.py Lists the Hugging Face models the code names or declares in a bill of materials, and keeps a record of each revision; a repository elsewhere counts as holding a model only when a bill of materials declares it
liveness.py Asks GitHub which upstream repositories still exist
check_mirror_health.py Checks that every mirror exists and is in sync with its upstream
check_upstream.py Records the size of each upstream repository
metrics.py Writes the instance's figures as a page of their own
init_instance.py Creates what the run expects on a new instance: the report repository with its decision files, the labels and each organisation's team; safe to run again
set_org_avatars.py Gives each organisation its upstream owner's avatar
seed_archived_repo.py Imports an archived repository too large to mirror in one go
forgejo.py The Forgejo API client the scripts share
instance.py Where the instance's files are, and what its instance.json says

Setting up an instance

Everything that belongs to one instance lives in a directory of its own, named by INSTANCE_DIR:

  • instance.json: the instance's name, the catalogue sources in order of precedence with the generator for each, and a few labels. instance.py lists every setting.
  • sources/: the generators, one per source, each writing a mirror set to data/.
  • data/: the mirror sets, caches and credentials. Never committed.
  • deploy/: the instance's manifests (see deploy/README.md).

git.opencode.swiss is the worked example: its instance directory has three sources (the federal catalogue, the OSS benchmark and the Swiss index) and a Kubernetes deployment.

Running it

export INSTANCE_DIR=<the instance's directory>
source "$INSTANCE_DIR/data/forgejo.env"   # FORGEJO_URL and the bot's credentials
python3 init_instance.py                  # what is missing on the instance; --apply creates it
python3 sync.py                           # report only
python3 sync.py --apply --report          # the weekly run

deploy/README.md covers deploying it, and deploy/expected-env.txt lists the environment variables the code reads.

Tests

  • INSTANCE_DIR=… ./smoke.sh checks the tool together with an instance, and the deployment when you are logged in to the cluster.
  • python3 -I tests/test_boms.py checks how bills of materials are read, without network access.

Reference

The design reasons and operating details, in full:

Document Covers
docs/sign-off.md Organisation rights, the import size gate, and approving or declining through tickets
docs/scheduled-refresh.md The scheduled run: order of steps, health checks, exit codes, and how gone upstreams are paused
docs/link-outs.md Sending visitors to the upstream issue tracker and wiki