Skip to content

Commit a137111

Browse files
authored
Merge pull request bitcoin-dev-project#377 from willcl-ark/package
Package for pypi
2 parents 2377b7e + ecee15e commit a137111

File tree

102 files changed

+813
-363
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+813
-363
lines changed

.github/workflows/publish-dist.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: Publish Python 🐍 distribution 📦 to PyPI
2+
3+
on: push
4+
5+
jobs:
6+
build:
7+
name: Build distribution 📦
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v4
12+
- name: Set up Python
13+
uses: actions/setup-python@v5
14+
with:
15+
python-version: "3.x"
16+
- name: Install pypa/build
17+
run: >-
18+
python3 -m
19+
pip install
20+
build
21+
--user
22+
- name: Build a binary wheel and a source tarball
23+
run: python3 -m build
24+
- name: Store the distribution packages
25+
uses: actions/upload-artifact@v3
26+
with:
27+
name: python-package-distributions
28+
path: dist/
29+
30+
publish-to-pypi:
31+
name: >-
32+
Publish Python 🐍 distribution 📦 to PyPI
33+
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
34+
needs:
35+
- build
36+
runs-on: ubuntu-latest
37+
environment:
38+
name: pypi
39+
url: https://pypi.org/p/warnet
40+
permissions:
41+
id-token: write # IMPORTANT: mandatory for trusted publishing
42+
43+
steps:
44+
- name: Download all the dists
45+
uses: actions/download-artifact@v3
46+
with:
47+
name: python-package-distributions
48+
path: dist/
49+
- name: Publish distribution 📦 to PyPI
50+
uses: pypa/gh-action-pypi-publish@release/v1
51+
52+
github-release:
53+
name: >-
54+
Sign the Python 🐍 distribution 📦 with Sigstore
55+
and upload them to GitHub Release
56+
needs:
57+
- publish-to-pypi
58+
runs-on: ubuntu-latest
59+
60+
permissions:
61+
contents: write # IMPORTANT: mandatory for making GitHub Releases
62+
id-token: write # IMPORTANT: mandatory for sigstore
63+
64+
steps:
65+
- name: Download all the dists
66+
uses: actions/download-artifact@v3
67+
with:
68+
name: python-package-distributions
69+
path: dist/
70+
- name: Sign the dists with Sigstore
71+
uses: sigstore/[email protected]
72+
with:
73+
inputs: >-
74+
./dist/*.tar.gz
75+
./dist/*.whl
76+
- name: Create GitHub Release
77+
env:
78+
GITHUB_TOKEN: ${{ github.token }}
79+
run: >-
80+
gh release create
81+
'${{ github.ref_name }}'
82+
--repo '${{ github.repository }}'
83+
--notes ""
84+
- name: Upload artifact signatures to GitHub Release
85+
env:
86+
GITHUB_TOKEN: ${{ github.token }}
87+
# Upload to GitHub Release using the `gh` CLI.
88+
# `dist/` contains the built packages, and the
89+
# sigstore-produced signatures and certificates.
90+
run: >-
91+
gh release upload
92+
'${{ github.ref_name }}' dist/**
93+
--repo '${{ github.repository }}'
94+

.github/workflows/test.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
- name: Build and export
3636
uses: docker/build-push-action@v5
3737
with:
38-
file: src/templates/rpc/Dockerfile_rpc
38+
file: src/warnet/templates/rpc/Dockerfile_rpc
3939
context: .
4040
tags: warnet/dev
4141
cache-from: type=gha
@@ -74,13 +74,13 @@ jobs:
7474
uv pip install -e .
7575
7676
echo "Contents of warnet-rpc-statefulset-dev.yaml being used:"
77-
cat src/templates/rpc/warnet-rpc-statefulset-dev.yaml
77+
cat src/warnet/templates/rpc/warnet-rpc-statefulset-dev.yaml
7878
7979
echo Setting up k8s
80-
kubectl apply -f src/templates/rpc/namespace.yaml
81-
kubectl apply -f src/templates/rpc/rbac-config.yaml
82-
kubectl apply -f src/templates/rpc/warnet-rpc-service.yaml
83-
kubectl apply -f src/templates/rpc/warnet-rpc-statefulset-dev.yaml
80+
kubectl apply -f src/warnet/templates/rpc/namespace.yaml
81+
kubectl apply -f src/warnet/templates/rpc/rbac-config.yaml
82+
kubectl apply -f src/warnet/templates/rpc/warnet-rpc-service.yaml
83+
kubectl apply -f src/warnet/templates/rpc/warnet-rpc-statefulset-dev.yaml
8484
kubectl config set-context --current --namespace=warnet
8585
8686
echo sleeping for 30s to give k8s time to boot

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ __pycache__
44
warnet.egg-info
55
.python-version
66
.env
7+
dist/
8+
build/

MANIFEST.in

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
include src/schema/*.json
2-
include src/templates/bitcoin.conf
3-
include src/templates/fork_observer_config.toml
4-
include src/templates/addrman_observer_config.toml
5-
include src/templates/addrman.patch
6-
include src/templates/isroutable.patch
7-
graft src/templates/k8s
8-
graft src/templates/rpc
9-
graft src/templates/grafana-provisioning
1+
include src/warnet/schema/*.json
2+
include src/warnet/templates/bitcoin.conf
3+
include src/warnet/templates/fork_observer_config.toml
4+
include src/warnet/templates/addrman_observer_config.toml
5+
include src/warnet/templates/addrman.patch
6+
include src/warnet/templates/isroutable.patch
7+
include src/warnet/scripts/quick_start.sh
8+
graft src/warnet/templates/k8s
9+
graft src/warnet/templates/rpc
10+
graft src/warnet/templates/grafana-provisioning
11+
graft src/warnet/logging_config

README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@ Monitor and analyze the emergent behaviors of Bitcoin networks.
1515

1616
## Documentation
1717

18-
- [Installation](docs/install.md)
19-
- [Running Warnet](docs/running.md)
20-
- [Network Topology](docs/graph.md)
21-
- [CLI Commands](docs/warcli.md)
22-
- [Scenarios](docs/scenarios.md)
23-
- [Data Collection](docs/data.md)
24-
- [Monitoring](docs/monitoring.md)
25-
- [Lightning Network](docs/lightning.md)
18+
- [Installation](https://github.com/bitcoin-dev-project/warnet/blob/main/docs/install.md)
19+
- [Quick Run](https://github.com/bitcoin-dev-project/warnet/blob/main/docs/quickrun.md)
20+
- [Running Warnet](https://github.com/bitcoin-dev-project/warnet/blob/main/docs/running.md)
21+
- [Network Topology](https://github.com/bitcoin-dev-project/warnet/blob/main/docs/graph.md)
22+
- [CLI Commands](https://github.com/bitcoin-dev-project/warnet/blob/main/docs/warcli.md)
23+
- [Scenarios](https://github.com/bitcoin-dev-project/warnet/blob/main/docs/scenarios.md)
24+
- [Data Collection](https://github.com/bitcoin-dev-project/warnet/blob/main/docs/data.md)
25+
- [Monitoring](https://github.com/bitcoin-dev-project/warnet/blob/main/docs/monitoring.md)
26+
- [Lightning Network](https://github.com/bitcoin-dev-project/warnet/blob/main/docs/lightning.md)
2627

27-
![warnet-art](docs/machines.webp)
28+
![warnet-art](https://raw.githubusercontent.com/bitcoin-dev-project/warnet/main/docs/machines.webp)

docs/developer-notes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ DOCKER_REGISTRY=bitcoindevproject/warnet-rpc TAG=0.1 ./scripts/build-k8s-rpc.sh
1818

1919
You can optionally specify `LATEST=1` to also include the `latest` tag on docker hub.
2020

21-
Once a new image has been pushed, it should be referenced in [warnet-rpc-statefulset.yaml](../src/templates/warnet-rpc-statefulset.yaml) in the `image` field.
21+
Once a new image has been pushed, it should be referenced in [warnet-rpc-statefulset.yaml](../src/warnet/templates/warnet-rpc-statefulset.yaml) in the `image` field.

docs/quickrun.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Quick run
2+
3+
Warnet runs a server which can be used to manage multiple networks. On docker
4+
this runs locally, but on Kubernetes this runs as a `statefulSet` in the
5+
cluster.
6+
7+
If the `$XDG_STATE_HOME` environment variable is set, the server will log to
8+
a file `$XDG_STATE_HOME/warnet/warnet.log`, otherwise it will use `$HOME/.warnet/warnet.log`.
9+
10+
## Quick start via pip
11+
12+
You can install warnet via `pip` into your virtual environment with
13+
14+
```bash
15+
python3 -m venv .venv
16+
source .venv/bin/activate
17+
pip install warnet
18+
```
19+
20+
Following installation `warcli` commands will operate natively on the Kubernetes cluster currently configured with `kubectl`.
21+
22+
Starting the Warnet server is as easy as:
23+
24+
```bash
25+
# (optional) if using a local minikube cluster check that we have all required programs installed
26+
warcli setup
27+
28+
# (optional) if using a local minikube cluster, set it up
29+
warcli cluster minikube-setup
30+
31+
warcli cluster deploy
32+
```
33+
34+
This also automatically configures port forwarding to the Server in the cluster.
35+
36+
To tear down the cluster:
37+
38+
```bash
39+
warcli cluster teardown
40+
41+
# (optional) if using a local minikube cluster, remove the image
42+
warcli cluster minikube-clean
43+
44+

docs/release-process.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Release process
2+
3+
Once a tag is pushed to GH this will start an image build using the tag
4+
5+
## Prerequisites
6+
7+
- [ ] Update version in pyproject.toml
8+
- [ ] Tag git with new version
9+
- [ ] Push tag to GitHub
10+
11+
## Manual Builds
12+
13+
```bash
14+
# Install build dependencies
15+
pip install -e .[build]
16+
17+
# Remove previous release metadata
18+
rm -i -Rf build/ dist/
19+
20+
# Build wheel
21+
python3 -m build
22+
```
23+
24+
### Upload
25+
26+
```bash
27+
# Upload to Pypi
28+
python3 -m twine upload dist/*
29+
```

docs/running.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ a file `$XDG_STATE_HOME/warnet/warnet.log`, otherwise it will use `$HOME/.warnet
99

1010
## Kubernetes
1111

12-
Deploy the resources in `src/templates/`, this sets up the correct permissions on the cluster (`rbac-config.yaml`) and deploys the warnet RPC server as a service + statefulset.
12+
Deploy the resources in `src/warnet/templates/`, this sets up the correct permissions on the cluster (`rbac-config.yaml`) and deploys the warnet RPC server as a service + statefulset.
1313

14-
This can be done with from inside the `src/templates/` directory by running:
14+
This can be done with from inside the `src/warnet/templates/` directory by running:
1515

1616
```bash
1717
kubectl apply -f '*.yaml'
@@ -40,13 +40,13 @@ kubectl delete statefulset
4040
First make sure you have `helm` installed, then simply run the following script:
4141

4242
```bash
43-
./src/templates/k8s/install_logging.sh
43+
./src/warnet/templates/k8s/install_logging.sh
4444
```
4545

4646
To forward port to view Grafana dashboard:
4747

4848
```bash
49-
./src/templates/k8s/connect_logging.sh
49+
./src/warnet/templates/k8s/connect_logging.sh
5050
```
5151

5252
## Kubernetes (e.g. minikube)

0 commit comments

Comments
 (0)