Skip to content

keepsimple1/linkd-playground

 
 

Repository files navigation

Linkd Playground

This is a set of scripts for playing with the binaries in radicle-link.

How to use this

The scripts here are all designed to work with a local checkout of radicle-link. In particular all invocations of the lnk and linkd binaries are made using cargo run - this means that the binaries will be recompiled on any change to the codebase. To specify the location of your checkout of radicle-link you’ll need to modify the env file.

Running the scenario

We’re going to simulate two maintainers trying to collaborate via a seed node. The first maintainer will create a project and push it to their local monorepo via a running gitd. The gitd will then push the new changes to the seed. Finally the second maintainer will pull the changes from the seed to their local monorepo and checkout a working copy using lnk clone.

Create profiles

We must create three profiles in separate LNK_HOMEs, one for each of the maintainers and one for the seed. This script will prompt you for a passphrase for the profile you are creating three times. I just use "1" in each case.

./create-lnk-homes.sh

Add SSH keys to ssh-agent

Add the ssh keys for each profile to the ssh-agent, this will prompt you for your passphrases again.

./add-ssh-keys.sh

Create a default identity for the maintainers

This effectively runs lnk identities person create followed by lnk identities local set --urn <the urn we just created>

./create-identity.sh

Create a local repository

We create a working copy which we’re going to add to the local monorepo.

./create-repo.sh

This will output some JSON including the URN of the project, make a note of the URN.

Add the seed to the local peer seed configs

First get the seed peer ID.

LNK_HOME=/tmp/seed-home ./lnk.sh profile peer

Then add the seed to the seed configs for the local peers

echo <peerid>@127.0.0.1:8799 | tee /tmp/link-local-1/<profile id>/seeds /tmp/link-local-2/<profile id>/seeds

Start the seed

In a fresh terminal:

./start-seed.sh

Start the first peers gitd

In a fresh terminal:

./start-git-server-1.sh

Note that this script actually runs systemd-socket-activate to simulate a socket activated connection to the gitd. This means that the process will terminate once there are no more connections to service so you’ll need to run this script again each time you want to communicate with the gitd.

Make some changes in the repo

cd theproject
echo "test" > test
git add test
git commit -m "test"

Add the linkd remote to the repository

The URN here is the URN output by the create-repo.sh script. You can also find it in the git config. There will be a remote called rad with a URL of the form rad://<URN>.

git remote add linkd 'ssh://rad@127.0.0.1:9876/<URN>'

Push the changes to the monorepo

git push linkd main

Clone the repo for the second peer

First get the peer ID of the first peer

LNK_HOME=/tmp/link-local-1 ./lnk.sh profile peer
LNK_HOME=/tmp/link-local-2 ./lnk.sh lnk clone \
    --urn <project URN>\
    --path theproject2\
    --peer <first peer ID>

This should now show the repository in the theproject2 directory.

About

Playing with the linkd node

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 100.0%