Skip to content

Commit d79e980

Browse files
authored
Better tests (#143)
1 parent 7d0c486 commit d79e980

File tree

2 files changed

+83
-57
lines changed

2 files changed

+83
-57
lines changed

.github/workflows/libsec.yml

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# https://docs.github.com/en/free-pro-team@latest/actions/guides/building-and-testing-python
2+
3+
name: fast libsec
4+
on: push
5+
jobs:
6+
7+
all-tests:
8+
# Super fast but only Ubuntu
9+
runs-on: ${{ matrix.os }}
10+
strategy:
11+
matrix:
12+
python-version: [3.6, 3.7, 3.8, 3.9, "3.10"]
13+
# Downgrading to 20.04 to avoid this openssl bug
14+
# https://github.com/bitcoin/bitcoin/issues/23710
15+
os: [ubuntu-20.04]
16+
steps:
17+
- uses: actions/checkout@v3
18+
- uses: actions/setup-python@v4
19+
with:
20+
python-version: ${{ matrix.python-version }}
21+
cache: 'pip'
22+
cache-dependency-path: '**/requirements*.txt'
23+
- name: Install python dependencies
24+
run: |
25+
pip install -r requirements-test.txt && pip install -r requirements-libsec.txt
26+
- name: pytest python unit tests, excluding slowest ones
27+
# all of the tests excluded here get run below once libsec is installed
28+
run: |
29+
pytest -vv --durations=0 -k "not musig and not psbt and not descriptor and not hd and not taproot and not script and not schnorr and not blinding and not shamir and not mnemonic" buidl/test
30+
- name: Install secp256k1 dependencies
31+
run: |
32+
sudo apt install -y libffi-dev pkg-config
33+
- name: Install secp256k1
34+
run: |
35+
# https://github.com/bitcoin-core/secp256k1/issues/542
36+
time git clone --depth 1 https://github.com/bitcoin-core/secp256k1 && cd secp256k1 && time ./autogen.sh && time ./configure --prefix=/usr --enable-module-extrakeys --enable-module-schnorrsig --enable-experimental && time make && time sudo make install
37+
- name: Build libsec
38+
run: |
39+
python3 -m pip install --editable . && cd buidl && python3 libsec_build.py && cd .. && python3 -c "from buidl import *; print('success') if is_libsec_enabled() else print('LIBSEC INSTALL FAIL')"
40+
- name: libsec ALL unit tests
41+
run: |
42+
pytest -vv --durations=0 buidl/test
43+
- name: Lint with flake8
44+
run: |
45+
# stop the build if there are Python syntax errors or undefined names
46+
flake8 . --count --statistics
47+
- name: Lint with black
48+
run: |
49+
black . --diff --check
50+
- name: pytest CLI singlesig
51+
run: |
52+
# We retry these 3x if needed, which is a disgusting hack but GH is really buggy for CLI apps
53+
pytest -vv test_singlesweep.py || pytest -vv test_singlesweep.py || pytest -vv test_singlesweep.py
54+
- name: pytest CLI multisig
55+
run: |
56+
# We retry these 3x if needed, which is a disgusting hack but GH is really buggy for CLI apps
57+
pytest -vv test_multiwallet.py || pytest -vv test_multiwallet.py || pytest -vv test_multiwallet.py
58+
env:
59+
SKIP_GH_UNRELIABLE_TESTS: True

.github/workflows/python.yml

+24-57
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,39 @@
11
# https://docs.github.com/en/free-pro-team@latest/actions/guides/building-and-testing-python
22

3-
name: Python
4-
5-
on: [push]
6-
3+
name: slow python
4+
on:
5+
pull_request:
6+
# These tests are so slow that we only run them when a PR is opened/reopened
7+
# If an existing PR gets new commits, only the libsec tests will run (to manually trigger a full test-suite, close and reopen the github PR)
8+
types: [opened, reopened]
9+
710
jobs:
811

9-
lint:
10-
runs-on: ${{ matrix.os }}
11-
strategy:
12-
matrix:
13-
python-version: [3.6, 3.7, 3.8, 3.9, "3.10"]
14-
os: [ubuntu-20.04, macos-11, windows-2019]
15-
steps:
16-
- uses: actions/checkout@v2
17-
- uses: actions/setup-python@v2
18-
with:
19-
python-version: ${{ matrix.python-version }}
20-
- name: Install python testing dependencies
21-
run: |
22-
pip install -r requirements-test.txt
23-
- name: Lint with black
24-
run: |
25-
black . --diff --check
26-
- name: Lint with flake8
27-
run: |
28-
# stop the build if there are Python syntax errors or undefined names
29-
flake8 . --count --statistics
30-
31-
cli-apps:
32-
runs-on: ${{ matrix.os }}
33-
strategy:
34-
matrix:
35-
python-version: [3.6, 3.7, 3.8, 3.9, "3.10"]
36-
# TODO CLI app testing doesn't work on windows due to different handling of pexcept:
37-
# https://github.com/pexpect/pexpect/issues/321
38-
os: [ubuntu-20.04, macos-11]
39-
steps:
40-
- uses: actions/checkout@v2
41-
- uses: actions/setup-python@v2
42-
with:
43-
python-version: ${{ matrix.python-version }}
44-
- name: Install python testing dependencies
45-
run: |
46-
pip install -r requirements-test.txt
47-
- name: pytest CLI multisig
48-
run: |
49-
pytest -v test_multiwallet.py
50-
env:
51-
SKIP_GH_UNRELIABLE_TESTS: True
52-
- name: pytest CLI singlesig
53-
run: |
54-
pytest -v test_singlesweep.py
55-
5612
unit-tests:
5713
runs-on: ${{ matrix.os }}
5814
strategy:
5915
matrix:
16+
# TODO: consider cutting down on python-version/os combos for speed
6017
python-version: [3.6, 3.7, 3.8, 3.9, "3.10"]
61-
os: [ubuntu-20.04, macos-11, windows-2019]
18+
os: [ubuntu-20.04, macos-11, macos-12, windows-2019, windows-2022]
19+
# TODO: add ubuntu-22.04 support! Something is up with openssl for that
20+
# https://github.com/bitcoin-core/secp256k1/issues/542
21+
exclude:
22+
# Ubuntu 22.04 doesn't come with python 3.6 installed
23+
- os: ubuntu-22.04
24+
python-version: 3.6
6225
steps:
63-
- uses: actions/checkout@v2
64-
- uses: actions/setup-python@v2
26+
- uses: actions/checkout@v3
27+
- uses: actions/setup-python@v4
6528
with:
6629
python-version: ${{ matrix.python-version }}
67-
- name: Install python testing dependencies
30+
cache: 'pip'
31+
cache-dependency-path: '**/requirements-test.txt'
32+
- name: Install python dependencies
6833
run: |
6934
pip install -r requirements-test.txt
70-
- name: pytest unit tests
35+
- name: pytest unit tests in pure python
7136
run: |
72-
pytest -v buidl/test
37+
pytest -vv --durations=0 buidl/test
38+
39+

0 commit comments

Comments
 (0)