Skip to content

Commit 8e5b0f5

Browse files
committed
Add tutorial to subscribe to package updates
Signed-off-by: Keshav Priyadarshi <git@keshav.space>
1 parent 39eae05 commit 8e5b0f5

5 files changed

Lines changed: 95 additions & 0 deletions
125 KB
Loading
194 KB
Loading
364 KB
Loading

docs/source/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ you will find information on:
2525
:caption: Tutorial
2626

2727
tutorial_getting_started
28+
tutorial_remote_subscribe_package_update
2829

2930
.. toctree::
3031
:maxdepth: 2
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
.. _tutorial_remote_subscribe_package_update:
2+
3+
Subscribe to Package Updates (Remote)
4+
=====================================
5+
6+
7+
In this tutorial, we will guide you through the step-by-step process of subscribing to
8+
package updates from a remote user. For this demo, we will subscribe to FederatedCode
9+
package updates in PurlDB. By the end of this tutorial, PurlDB will be able to subscribe
10+
to package updates and will receive ActivityPub streams for the activities of the subscribed
11+
packages.
12+
13+
.. note::
14+
This tutorial assumes that you have a working installation of FederatedCode.
15+
If you don't, please refer to the :ref:`installation` page.
16+
17+
18+
Initial Setup (FederatedCode)
19+
-----------------------------
20+
21+
#. Head over to :ref:`tutorial_getting_started` to perform the initial configuration of
22+
FederatedCode after installation.
23+
24+
#. Navigate to http://127.0.0.1:8000/admin/fedcode/remoteactor/add/ and add the ``purldb`` remote actor.
25+
Populate the URL with http://127.0.0.1:8001/api/users/@purldb and set the username as ``purldb``.
26+
27+
.. image:: img/tutorial_remote_subscribe_package_update_add_purldb_remote_actor.jpg
28+
29+
#. Navigate to http://127.0.0.1:8000/admin/fedcode/person/add/ to create the remote actor user.
30+
For now, enter any value in the summary and public key fields, leave the user field empty,
31+
and in the ``Remote actor`` dropdown, choose the one created in the previous step.
32+
33+
.. image:: img/tutorial_remote_subscribe_package_update_create_purldb_remote_actor_user.jpg
34+
35+
36+
Initial Setup (PurlDB)
37+
----------------------
38+
39+
#. Follow the steps here to install PurlDB: https://aboutcode.readthedocs.io/projects/PURLdb/en/latest/getting-started/install.html#installation
40+
41+
#. Add the FederatedCode ActivityPub server host to the ``.env`` file.
42+
43+
.. code-block:: bash
44+
:caption: .env
45+
46+
FEDERATEDCODE_HOST_URL="http://127.0.0.1:8000"
47+
48+
#. Subscribe to a PURL for updates. In this case, since we know that we have the
49+
``atlasboard`` package in our FederatedCode, we will subscribe to it.
50+
51+
.. code-block:: bash
52+
53+
python manage_purldb.py subscribe_package "pkg:npm/atlasboard"
54+
55+
On successful subscription, you will see this message:
56+
57+
.. code-block:: bash
58+
59+
{"status": "success", "message": "Successfully subscribed to package pkg:npm/atlasboard"}
60+
61+
#. Navigate to http://127.0.0.1:8001/api/package_activity/ (Package updates received from FederatedCode ActivityPub will be available here).
62+
63+
64+
Update Package Scan (Git Repo)
65+
------------------------------
66+
67+
Since we have subscribed to ``pkg:npm/atlasboard``, head over to
68+
https://github.com/<YOUR-GITHUB-USERNAME>/aboutcode-packages-npm-385/blob/main/npm/atlasboard/1.1.10/scancodeio.json,
69+
make some changes, and commit them.
70+
71+
72+
Run Sync and Federate (FederatedCode)
73+
-------------------------------------
74+
75+
#. Run the following command to sync the changes made to the package scan in the Git repository
76+
77+
.. code-block:: bash
78+
79+
python manage.py sync sync_scancode_scans
80+
81+
#. Run the following command to send activity updates to existing subscribers of the package
82+
83+
.. code-block:: bash
84+
85+
python manage.py federate
86+
87+
Browse the Package Activity (PurlDB)
88+
------------------------------------
89+
90+
Navigate to http://127.0.0.1:8001/api/package_activity/ to view the activity for the subscribed package.
91+
92+
.. image:: img/tutorial_remote_subscribe_package_update_purldb_activity_endpoint.png
93+
94+

0 commit comments

Comments
 (0)