Jennifer Academy

Code: One API over GitHub, GitLab and Forgejo

Code for "One API over GitHub, GitLab and Forgejo"

The programs behind the slides, for Jennifer 0.27.0 and the released decks @deckyard/codehost 0.3.0 (with github 0.3.0, gitlab 0.4.0, forgejo 0.4.0) and @deckyard/git 0.2.0. Everything runs against local throwaway servers: Forgejo and GitLab CE in docker, and a GitHub stand-in written in Jennifer. No real forge account is used, except one anonymous read in ratelimit.j.

Run every command from this folder. jvc install and setup.sh create vendor/ and work/; neither belongs in the repository.

Setup

jvc install                                   # vendor/ from deck.toml

# Forgejo on 127.0.0.1:13300
docker run -d --name academy-forge-forgejo -p 127.0.0.1:13300:3000 \
  -e FORGEJO__security__INSTALL_LOCK=true \
  -e FORGEJO__database__DB_TYPE=sqlite3 \
  -e FORGEJO__server__ROOT_URL=http://127.0.0.1:13300/ \
  codeberg.org/forgejo/forgejo:13
docker exec -u git academy-forge-forgejo forgejo admin user create --admin \
  --username relbot --password 'CHANGE-ME-long-password' \
  --email relbot@example.invalid --must-change-password=false
docker exec -u git academy-forge-forgejo forgejo admin user \
  generate-access-token --username relbot --token-name rw --raw \
  --scopes write:repository,write:issue,write:user
docker exec -u git academy-forge-forgejo forgejo admin user \
  generate-access-token --username relbot --token-name ro --raw \
  --scopes read:repository

# GitLab CE on 127.0.0.1:18929 (needs about 4 GB of RAM, starts in minutes)
docker run -d --name academy-forge-gitlab --shm-size 256m \
  -p 127.0.0.1:18929:18929 \
  -e GITLAB_ROOT_PASSWORD='CHANGE-ME-random-password' \
  -e GITLAB_OMNIBUS_CONFIG="external_url 'http://127.0.0.1:18929'; prometheus_monitoring['enable']=false; registry['enable']=false" \
  gitlab/gitlab-ce:latest

In GitLab, sign in as root, create the user relbot and, as relbot, a personal access token with scope api and one with read_api.

jennifer run ghfake.j 127.0.0.1:18080 &       # the GitHub stand-in
export GITHUB_TOKEN=placeholder-github-token  # the stand-in checks none
export FORGEJO_TOKEN=<the rw token> GITLAB_TOKEN=<the api token>
./setup.sh                                    # prints the 1.3.0 commit
jennifer run seed.j                           # two issues on each forge

forges.toml lists the three forges; set FORGES to use another file.

Programs, in the order of the slides

FileSlidesRun
forges.j, forges.tomlA Forge from configurationimported by the others
repos.jOne loop, three forgesjennifer run repos.j
pulls.j, pulls.tomlChange requestsFORGES=pulls.toml jennifer run pulls.j
show.jReleases with assetsjennifer run show.j (after the release)
ci.jA red gate, A green runjennifer run ci.j <sha> ci/check pending
release.jThe release script to A green runjennifer run release.j work/tempo 1.3.0 work/dist/tempo-1.3.0.tar.gz work/dist/SHA256SUMS
labels.jSync labelsjennifer run labels.j
errors.jErrors; Tokens and scopesjennifer run errors.j, then again with the read-only tokens in FORGEJO_TOKEN and GITLAB_TOKEN
ratelimit.jPaging and rate limitsjennifer run ratelimit.j (one anonymous call to api.github.com)
plainhttp.jPlain http is an opt-injennifer run plainhttp.j (sends nothing; git.lan must not resolve)
extras.jBeyond the common verbsjennifer run extras.j; --kick starts CI, which tempo lacks

Helpers: ghfake.j answers the GitHub REST paths these programs use, under /api/v3 and /api/uploads as a GitHub Enterprise Server does, from memory; it is not GitHub. setup.sh creates the repositories and the local checkout. seed.j opens the issues. ci.j reports a commit status as CI would.

Cleanup

docker rm -f academy-forge-forgejo academy-forge-gitlab
kill %1                                       # the stand-in
rm -rf work vendor
FileSize
LICENSE899 Braw
README.md3.9 KiBraw
ci.j542 Braw
deck.toml418 Braw
errors.j514 Braw
extras.j1.5 KiBraw
forges.j1.0 KiBraw
forges.toml433 Braw
ghfake.j7.0 KiBraw
labels.j1.3 KiBraw
plainhttp.j922 Braw
pulls.j1.0 KiBraw
pulls.toml286 Braw
ratelimit.j416 Braw
release.j3.9 KiBraw
repos.j572 Braw
seed.j495 Braw
setup.sh1.7 KiBraw
show.j550 Braw