Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/scripts/check_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import re
import sys
from pathlib import Path


def get_version(file_path, pattern):
content = Path(file_path).read_text()
match = re.search(pattern, content)
return match.group(1) if match else None


pyproject_version = get_version("pyproject.toml", r'version\s*=\s*"([^"]+)"')
version_py_version = get_version("src/warnet/version.py", r'VERSION\s*=\s*"([^"]+)"')

if pyproject_version == version_py_version:
print(f"Versions match: {pyproject_version}")
sys.exit(0)
else:
print(f"Version mismatch: pyproject.toml={pyproject_version}, version.py={version_py_version}")
sys.exit(1)
38 changes: 16 additions & 22 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
name: deploy

on:
workflow_run:
workflows: ["test"]
types:
- completed
push:
tags:
- '*'

jobs:
deploy-to-dockerhub:
check-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Check version consistency
run: python .github/scripts/check_version.py
deploy:
needs: [check-version]
runs-on: ubuntu-latest
if: >
github.event.workflow_run.conclusion == 'success'
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
Expand All @@ -24,8 +32,6 @@ jobs:
images: ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_RPC_REPO }}
tags: |
type=ref,event=tag
type=ref,event=pr
type=raw,value=latest,enable={{is_default_branch}}
labels: |
maintainer=bitcoindevproject
org.opencontainers.image.title=warnet-rpc
Expand All @@ -40,21 +46,9 @@ jobs:
with:
file: resources/images/rpc/Dockerfile_prod
platforms: linux/amd64,linux/arm64
context: src/warnet/templates/rpc
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build and push dev RPC image
if: github.ref == 'refs/heads/main'
uses: docker/build-push-action@v5
with:
file: resources/images/rpc/Dockerfile_dev
platforms: linux/amd64,linux/arm64
context: src/warnet/templates/rpc
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_RPC_REPO }}:dev
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
6 changes: 5 additions & 1 deletion .github/workflows/publish-dist.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: Publish Python 🐍 distribution 📦 to PyPI

on: push
on:
pull_request:
push:
branches:
- main

jobs:
build:
Expand Down
50 changes: 50 additions & 0 deletions .github/workflows/test-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: test image builds

on:
workflow_run:
workflows: ["test"]
types:
- completed

jobs:
test-prod:
runs-on: ubuntu-latest
if: >
github.event.workflow_run.conclusion == 'success'
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build production RPC image
uses: docker/build-push-action@v5
with:
file: resources/images/rpc/Dockerfile_prod
platforms: linux/amd64,linux/arm64
context: .
push: false
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_RPC_REPO }}:latest
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
test-dev:
runs-on: ubuntu-latest
if: >
github.event.workflow_run.conclusion == 'success'
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build dev RPC image
uses: docker/build-push-action@v5
with:
file: resources/images/rpc/Dockerfile_dev
platforms: linux/amd64,linux/arm64
context: resources/images/rpc
push: false
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_RPC_REPO }}:dev
cache-from: type=gha
cache-to: type=gha,mode=max
12 changes: 11 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,18 @@ jobs:
- uses: chartboost/ruff-action@v1
with:
args: 'format --check'
check-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Check version consistency
run: python .github/scripts/check_version.py
build-image:
needs: [ruff, ruff-format]
needs: [ruff, ruff-format, check-version]
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "warnet"
version = "0.9.11"
version = "0.9.12"
description = "Monitor and analyze the emergent behaviours of bitcoin networks"
readme = "README.md"
requires-python = ">=3.10"
Expand Down
22 changes: 7 additions & 15 deletions src/warnet/cli/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from importlib.resources import files

import click
from warnet.version import VERSION

MANIFEST_PATH = files("manifests")
RPC_PATH = files("images").joinpath("rpc")
Expand Down Expand Up @@ -55,21 +56,17 @@ def run_command(command, stream_output=False):
@cluster.command()
def minikube_setup():
"""Setup minikube for use with Warnet"""
script_content = f"""
script_content = """
#!/usr/bin/env bash
set -euxo pipefail

# Function to check if minikube is running
check_minikube() {{
minikube status | grep -q "Running" && echo "Minikube is already running" || minikube start --memory=4000mb --cpus=4 --mount --mount-string="$PWD:/mnt/src"
}}
check_minikube() {
minikube status | grep -q "Running" && echo "Minikube is already running" || minikube start --memory=4000mb --cpus=4
}

# Check minikube status
check_minikube

# Build image in local registry and load into minikube
docker build -t warnet/dev -f {RPC_PATH}/Dockerfile_dev {RPC_PATH} --load
minikube image load warnet/dev
"""

run_command(script_content, stream_output=True)
Expand All @@ -94,7 +91,7 @@ def deploy():
kubectl apply -f {MANIFEST_PATH}/namespace.yaml
kubectl apply -f {MANIFEST_PATH}/rbac-config.yaml
kubectl apply -f {MANIFEST_PATH}/warnet-rpc-service.yaml
kubectl apply -f {MANIFEST_PATH}/warnet-rpc-statefulset-dev.yaml
sed "s|bitcoindevproject/warnet-rpc:latest|bitcoindevproject/warnet-rpc:{VERSION}|" {MANIFEST_PATH}/warnet-rpc-statefulset.yaml | kubectl apply -f -
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2991223

making me wonder again if python-embedded-bash (plus external yaml files) can be simplified with just... python.

https://github.com/kubernetes-client/python/blob/master/kubernetes/docs/AppsV1Api.md#create_namespaced_stateful_set

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or maybe warnet-rpc-statefulset.yaml should just always have its own version hard-coded? I'm trying to think if we'd ever need latest in prod?

kubectl config set-context --current --namespace=warnet

# Check for warnet-rpc container
Expand All @@ -119,12 +116,7 @@ def deploy():
@cluster.command()
def minikube_clean():
"""Reinit minikube images"""
script_content = """
#!/usr/bin/env bash
set -euxo pipefail
minikube image rm warnet/dev
"""
run_command(script_content, stream_output=True)
run_command("minikube delete", stream_output=True)


@cluster.command()
Expand Down
1 change: 1 addition & 0 deletions src/warnet/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VERSION = "0.9.12"