Skip to content

Commit

Permalink
Merge pull request #52 from jamesob/jamesob-22-01-single-file
Browse files Browse the repository at this point in the history
Remove compilation step
  • Loading branch information
jamesob committed Jan 14, 2022
2 parents 8ca3c13 + 73a3227 commit 1f4abf5
Show file tree
Hide file tree
Showing 19 changed files with 172 additions and 3,674 deletions.
20 changes: 8 additions & 12 deletions .github/workflows/run-tests.yml
Expand Up @@ -23,27 +23,23 @@ jobs:
- name: Install test dependencies
run: |
python -m pip install --upgrade pip
pip install -r src/requirements-dev.txt
pip install -r requirements-dev.txt
cp coldcore coldcore.py
echo "PYTHONPATH=$(pwd)" >> $GITHUB_ENV
- name: black
run: black --check
run: black --check coldcore

- name: flake8
run: |
flake8 src --count --show-source --statistics --exclude 'test_*'
flake8 coldcore --count --show-source --statistics
# When linting the tests, ignore long line errors
flake8 src --count --show-source --statistics --ignore E501
flake8 test/ --count --show-source --statistics --ignore E501
- name: pytest
run: |
pytest -vv src
pytest -vv test/
- name: mypy
run: |
mypy src/coldcore
- name: check compiled script
run: |
python ./bin/compile
git diff --exit-code
./coldcore --help
mypy coldcore
6 changes: 6 additions & 0 deletions Dockerfile
@@ -0,0 +1,6 @@
# Dockerfile for running tests/lints
FROM docker.io/library/python:latest

WORKDIR /src
COPY ./requirements-dev.txt .
RUN pip install -r requirements-dev.txt
17 changes: 12 additions & 5 deletions Makefile
@@ -1,8 +1,15 @@
install:
install -m755 coldcore /usr/local/bin/coldcore

coldcore:
./bin/compile
docker-build:
docker build --tag coldcore/test .

test:
pytest src/coldcore
test: docker-build
docker run -v ./coldcore:/src/coldcore.py -e PYTHONPATH=/src -v ./:/src:ro coldcore/test pytest -vv --color=yes test/

.PHONY: test
lint: docker-build
docker run --rm -v ./:/src:ro coldcore/test flake8 coldcore
docker run --rm -v ./:/src:ro coldcore/test black --check coldcore
docker run --rm -v ./:/src:ro coldcore/test mypy coldcore

.PHONY: docker-build lint test
39 changes: 8 additions & 31 deletions README.md
Expand Up @@ -95,6 +95,13 @@ by doing a few test transactions in testnet.
set `coldcard --rpc <url>` if desired.


### Development

Run tests and linting locally with `make test` and `make lint`. It's advisable to do
this before filing a PR, otherwise CI will likely fail due to [`black` formatting
requirements](https://github.com/psf/black).


## Design

### Zero install process
Expand Down Expand Up @@ -143,37 +150,7 @@ supported, but I'm happy to add others that fit the criteria of

### Auditing

The final script, `coldcore`, is dumbly compiled from the contents of `src/coldcore/`
for convenience during development (per `./bin/compile`).

If you want to read through, I recommend starting with the `src/coldcore` tree.

```
.
├── bin
│   ├── compile # generates final `coldcore` script
│   └── sign_release
├── coldcore
├── sigs # signatures for verification
│   └── coldcore-0.1.0-alpha.asc
└── src
├── coldcore
│   ├── crypto.py # a few basic cryptographic utilities
│   ├── __init__.py
│   ├── main.py # most logic is here; wallet ops, CLI, models
│   ├── test_coldcard.py
│   ├── test_crypto.py
│   ├── thirdparty
│   │   ├── bitcoin_rpc.py # taken from python-bitcoinlib
│   │   ├── clii.py # taken from jamesob/clii
│   │   ├── __init__.py
│   │   └── py.typed
│   └── ui.py # presentation logic, curses
├── requirements-dev.txt
└── setup.py # for development use only
```


All source is contained in `coldcore`.

## Status

Expand Down
66 changes: 0 additions & 66 deletions bin/compile

This file was deleted.

0 comments on commit 1f4abf5

Please sign in to comment.