Skip to content

Commit ada2b34

Browse files
committed
feat: add GitHub workflows for building, testing, and releasing the library
1 parent 284d58b commit ada2b34

3 files changed

Lines changed: 199 additions & 0 deletions

File tree

.github/workflows/README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Workflows
2+
3+
## release.yml — Build and Release
4+
5+
Builds platform wheels, publishes to PyPI, and creates a GitHub Release.
6+
7+
- **Trigger**: automatically via `repository_dispatch` from `rgb-lib`, or manually
8+
- **Input**: `rgb_lib_version` (e.g. `v0.3.0-beta.8`)
9+
- **What it does**:
10+
1. Checks out the rgb-lib submodule at the target version
11+
2. Converts version to PEP 440 format (e.g. `v0.3.0-beta.8``0.3.0b8`)
12+
3. Builds platform wheels for Linux x64, Linux ARM64, and macOS ARM64
13+
4. Publishes all wheels to PyPI via `twine`
14+
5. Creates a GitHub Release with the tag and wheel files
15+
16+
## test.yml — Test Library (local)
17+
18+
Tests the Python bindings using a **locally built** wheel.
19+
20+
- **Trigger**: push to `main`, PRs to `main`, after release workflow, or manually
21+
- **What it does**:
22+
1. Builds the wheel from source via `poetry build`
23+
2. Installs the local wheel with `pip install dist/*.whl`
24+
3. Runs `pytest tests/` against the local build
25+
4. Tests on Linux x64, Linux ARM64, and macOS ARM64
26+
27+
## test_tag.yml — Test Library (published tag)
28+
29+
Tests the **published** PyPI package — simulates what end users do.
30+
31+
- **Trigger**: push of a `v*` tag (i.e. right after a release)
32+
- **What it does**:
33+
1. Converts the git tag to PEP 440 version format
34+
2. Installs the exact version from PyPI (`pip install rgb-lib==<version>`)
35+
3. Retries up to 5 times with 60s delay if PyPI hasn't indexed the package yet
36+
4. Runs `pytest tests/` against the published package
37+
5. Tests on Linux x64, Linux ARM64, and macOS ARM64

.github/workflows/test.yml

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
name: Test Library
2+
3+
on:
4+
repository_dispatch:
5+
types: [rgb-lib-release]
6+
7+
workflow_run:
8+
workflows: ["Build and Release"]
9+
types:
10+
- completed
11+
12+
workflow_dispatch:
13+
inputs:
14+
bitcoin_network:
15+
description: 'Bitcoin network (signet, testnet, regtest)'
16+
required: false
17+
default: 'signet'
18+
type: string
19+
20+
push:
21+
branches:
22+
- main
23+
paths:
24+
- 'src/**'
25+
- 'tests/**'
26+
- 'pyproject.toml'
27+
- 'rgb-lib/**'
28+
29+
pull_request:
30+
branches:
31+
- main
32+
33+
jobs:
34+
test:
35+
name: Test (${{ matrix.platform }})
36+
runs-on: ${{ matrix.runner }}
37+
strategy:
38+
fail-fast: false
39+
matrix:
40+
include:
41+
- runner: ubuntu-22.04
42+
platform: linux-x86_64
43+
target: x86_64-unknown-linux-gnu
44+
- runner: ubuntu-22.04-arm
45+
platform: linux-aarch64
46+
target: aarch64-unknown-linux-gnu
47+
- runner: macos-latest
48+
platform: macosx-arm64
49+
target: aarch64-apple-darwin
50+
51+
steps:
52+
- name: Checkout repository
53+
uses: actions/checkout@v4
54+
with:
55+
submodules: recursive
56+
57+
- name: Setup Python
58+
uses: actions/setup-python@v5
59+
with:
60+
python-version: '3.11'
61+
62+
- name: Setup Rust
63+
uses: actions-rust-lang/setup-rust-toolchain@v1
64+
with:
65+
toolchain: stable
66+
target: ${{ matrix.target }}
67+
68+
- name: Install dependencies
69+
run: |
70+
python -m pip install --upgrade pip
71+
pip install poetry
72+
poetry install
73+
shell: bash
74+
75+
- name: Build local wheel
76+
run: |
77+
export PLATFORM="${{ matrix.platform }}"
78+
poetry build -vvv
79+
env:
80+
PLATFORM: ${{ matrix.platform }}
81+
shell: bash
82+
83+
- name: Install local wheel
84+
run: |
85+
pip install dist/*.whl --force-reinstall
86+
shell: bash
87+
88+
- name: Run tests
89+
env:
90+
BITCOIN_NETWORK: ${{ inputs.bitcoin_network || 'signet' }}
91+
MNEMONIC: ${{ secrets.TEST_MNEMONIC }}
92+
ACCOUNT_XPUB_VANILLA: ${{ secrets.TEST_ACCOUNT_XPUB_VANILLA }}
93+
ACCOUNT_XPUB_COLORED: ${{ secrets.TEST_ACCOUNT_XPUB_COLORED }}
94+
MASTER_FINGERPRINT: ${{ secrets.TEST_MASTER_FINGERPRINT }}
95+
INDEXER_URL: ${{ secrets.TEST_INDEXER_URL }}
96+
run: |
97+
pip install pytest
98+
pytest tests/ -v
99+
shell: bash

.github/workflows/test_tag.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Test Library (tag)
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
test:
10+
name: Test tag (${{ matrix.platform }})
11+
runs-on: ${{ matrix.runner }}
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
include:
16+
- runner: ubuntu-22.04
17+
platform: linux-x86_64
18+
target: x86_64-unknown-linux-gnu
19+
- runner: ubuntu-22.04-arm
20+
platform: linux-aarch64
21+
target: aarch64-unknown-linux-gnu
22+
- runner: macos-latest
23+
platform: macosx-arm64
24+
target: aarch64-apple-darwin
25+
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v4
29+
with:
30+
ref: ${{ github.ref_name }}
31+
32+
- name: Setup Python
33+
uses: actions/setup-python@v5
34+
with:
35+
python-version: '3.11'
36+
37+
- name: Install published package from PyPI
38+
run: |
39+
VERSION="${{ github.ref_name }}"
40+
# Convert tag to PEP 440: v0.3.0-beta.8 -> 0.3.0b8
41+
PY_VERSION=$(echo "$VERSION" | sed 's/^v//' | sed 's/-beta\./b/' | sed 's/-alpha\./a/' | sed 's/-rc\./rc/')
42+
echo "Installing rgb-lib==$PY_VERSION"
43+
44+
# Retry loop — PyPI index may lag behind the release
45+
for i in 1 2 3 4 5; do
46+
pip install "rgb-lib==$PY_VERSION" && break
47+
echo "Attempt $i failed, waiting 60s for PyPI to index..."
48+
sleep 60
49+
done
50+
shell: bash
51+
52+
- name: Run tests
53+
env:
54+
BITCOIN_NETWORK: signet
55+
MNEMONIC: ${{ secrets.TEST_MNEMONIC }}
56+
ACCOUNT_XPUB_VANILLA: ${{ secrets.TEST_ACCOUNT_XPUB_VANILLA }}
57+
ACCOUNT_XPUB_COLORED: ${{ secrets.TEST_ACCOUNT_XPUB_COLORED }}
58+
MASTER_FINGERPRINT: ${{ secrets.TEST_MASTER_FINGERPRINT }}
59+
INDEXER_URL: ${{ secrets.TEST_INDEXER_URL }}
60+
run: |
61+
pip install pytest
62+
pytest tests/ -v
63+
shell: bash

0 commit comments

Comments
 (0)