Skip to content

Commit 7edac59

Browse files
authored
Merge pull request #54 from aboutcode-org/federatedcode-client-release
Prepare `aboutcode.federatedcode` v0.1.0 release
2 parents b21f094 + 7d464f9 commit 7edac59

File tree

10 files changed

+151
-7
lines changed

10 files changed

+151
-7
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Build aboutcode.federatedcode Python distributions and publish on PyPI
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
tags:
7+
- "aboutcode.federatedcode/*"
8+
9+
jobs:
10+
build-and-publish:
11+
name: Build and publish library to PyPI
12+
runs-on: ubuntu-22.04
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Set up Python
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: 3.11
21+
22+
- name: Install flot
23+
run: python -m pip install flot --user
24+
25+
- name: Build binary wheel and source tarball
26+
run: python -m flot --pyproject pyproject-aboutcode.federatedcode.toml --sdist --wheel --output-dir dist/
27+
28+
- name: Publish to PyPI
29+
if: startsWith(github.ref, 'refs/tags')
30+
uses: pypa/gh-action-pypi-publish@release/v1
31+
with:
32+
password: ${{ secrets.PYPI_API_TOKEN_ABOUTCODE_FEDERATEDCODE }}
33+
34+
- name: Upload built archives
35+
uses: actions/upload-artifact@v4
36+
with:
37+
name: pypi_archives
38+
path: dist/*

aboutcode/__init__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#
2+
# Copyright (c) nexB Inc. and others. All rights reserved.
3+
# FederatedCode is a trademark of nexB Inc.
4+
# SPDX-License-Identifier: Apache-2.0
5+
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
6+
# See https://github.com/nexB/federatedcode for support or download.
7+
# See https://aboutcode.org for more information about AboutCode.org OSS projects.
8+
#
9+
10+
import pkgutil
11+
12+
__path__ = pkgutil.extend_path(__path__, __name__)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Changelog
2+
=============
3+
4+
5+
6+
v0.1.0 (December 13, 2024)
7+
---------------------------
8+
9+
- Initial release of the ``aboutcode.federatedcode`` library.

aboutcode/federatedcode/README.rst

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,70 @@
22
aboutcode.federatedcode
33
=======================
44

5-
|license| |build|
5+
|license| |build| |release|
66

77
.. |license| image:: https://img.shields.io/badge/License-Apache--2.0-blue.svg?style=for-the-badge
88
:target: https://opensource.org/licenses/Apache-2.0
99

10-
.. |build| image:: https://img.shields.io/github/actions/workflow/status/aboutcode-org/federatedcode/main.yml?style=for-the-badge&logo=github
10+
.. |build| image:: https://img.shields.io/github/actions/workflow/status/aboutcode-org/federatedcode/pypi-release-aboutcode-federatedcode.yml?style=for-the-badge&logo=github
1111

12-
This is a library of FederatedCode client utilities to fetch and subscribe package metadata.
12+
.. |release| image:: https://img.shields.io/pypi/v/aboutcode.federatedcode?style=for-the-badge&logo=pypi&color=%23a569bd
13+
:target: https://pypi.org/project/aboutcode.federatedcode/
14+
:alt: PyPI - Version
1315

1416

17+
This is a CLI and library of FederatedCode client utilities for fetching and subscribing to package metadata, and utilities for managing activity streams.
18+
19+
Installation
20+
============
21+
22+
To install the FederatedCode client, use the following command:
23+
24+
.. code-block:: bash
25+
26+
pip install aboutcode.federatedcode
27+
28+
29+
CLI Usage
30+
=========
31+
32+
Use the ``federatedcode`` CLI to discover and fetch scans using the PURL:
33+
34+
.. code-block:: bash
35+
36+
# Display the general help for federatedcode
37+
federatedcode --help
38+
39+
# Display help for a specific command
40+
federatedcode [command] --help
41+
42+
Example
43+
-------
44+
45+
Discover a PURL in the FederatedCode AP Server:
46+
47+
.. code-block:: bash
48+
49+
❯ federatedcode discover pkg:npm/%40angular/animation
50+
http://<Your-FederatedCode-Host>/purls/@pkg:npm/%2540angular/animation
51+
52+
53+
Library Usage
54+
=============
55+
56+
Use the ``client`` module to fetch scan results, subscribe to packages, or discover packages
57+
in the AP server.
58+
59+
.. code-block:: python
60+
61+
from aboutcode.federatedcode import client
62+
63+
Use the ``contrib`` module to get the Django mixin and various utilities to manage activity streams.
64+
65+
.. code-block:: python
66+
67+
from aboutcode.federatedcode.contrib import django
68+
1569
License
1670
=======
1771

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#
2+
# Copyright (c) nexB Inc. and others. All rights reserved.
3+
# FederatedCode is a trademark of nexB Inc.
4+
# SPDX-License-Identifier: Apache-2.0
5+
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
6+
# See https://github.com/nexB/federatedcode for support or download.
7+
# See https://aboutcode.org for more information about AboutCode.org OSS projects.
8+
#
9+
10+
__version__ = "0.1.0"

aboutcode/federatedcode/client/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313
from urllib.parse import urljoin
1414

1515
import requests
16-
from aboutcode.hashid import get_package_base_dir
1716
from dotenv import load_dotenv
1817
from packageurl import PackageURL
1918

19+
from aboutcode.hashid import get_package_base_dir
20+
2021
load_dotenv()
2122

2223
FEDERATEDCODE_GIT_RAW_URL = os.getenv(
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#
2+
# Copyright (c) nexB Inc. and others. All rights reserved.
3+
# FederatedCode is a trademark of nexB Inc.
4+
# SPDX-License-Identifier: Apache-2.0
5+
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
6+
# See https://github.com/nexB/federatedcode for support or download.
7+
# See https://aboutcode.org for more information about AboutCode.org OSS projects.
8+
#
9+
10+
from unittest.mock import patch
11+
12+
from aboutcode.federatedcode.client import discover_package_in_ap_server
13+
14+
15+
def test_discover_package_in_ap_server():
16+
with patch("requests.head") as mock_head:
17+
mock_response = mock_head.return_value
18+
mock_response.status_code = 200
19+
20+
result = discover_package_in_ap_server("pkg:foo/bar")
21+
expected = "http://localhost:8000/purls/@pkg:npm/foo/bar"
22+
result == expected

fedcode/pipelines/sync_scancode_scans.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from traceback import format_exc as traceback_format_exc
1212

1313
from aboutcode.pipeline import LoopProgress
14-
1514
from fedcode.models import Package
1615
from fedcode.models import Repository
1716
from fedcode.pipelines import FederatedCodePipeline

fedcode/pipelines/sync_vulnerablecode.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
from itertools import zip_longest
1313

1414
import saneyaml
15-
from aboutcode.pipeline import LoopProgress
1615

16+
from aboutcode.pipeline import LoopProgress
1717
from fedcode.activitypub import Activity
1818
from fedcode.activitypub import UpdateActivity
1919
from fedcode.models import Note

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ addopts = [
5050
[tool.black]
5151
line-length = 100
5252
include = '\.pyi?$'
53-
skip_gitignore = true
5453
# 'extend-exclude' excludes files or directories in addition to the defaults
5554
extend-exclude = "venv|fedcode/migrations"
5655

0 commit comments

Comments
 (0)