Skip to content

Commit bd73a32

Browse files
add justfile, update readme, remove coveralls (#1440)
* remove virtualenv * unremove virtualenv version * messy justfile, but maybe CI works? * remove quote * actually run tests with correct versions * fix comment * better logging, less mypy * skip tox, different pyright approach on older versions * break out test jobs * fix justfile * another CI run * install this package * remvove tox, makefile, update CI a bunch * fix mypy * fix pyright dep * final pass
1 parent 39ce6f4 commit bd73a32

File tree

11 files changed

+172
-188
lines changed

11 files changed

+172
-188
lines changed

.github/workflows/ci.yml

Lines changed: 42 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -19,41 +19,47 @@ on:
1919

2020
jobs:
2121
lint:
22-
name: Lint & Mypy
22+
name: Static Checks
2323
runs-on: ubuntu-latest
2424
steps:
25+
- uses: extractions/setup-just@v2
2526
- uses: actions/checkout@v3
2627
- name: Set up Python 3
2728
uses: actions/setup-python@v4
2829
with:
2930
python-version: "3.10"
30-
- name: mypy
31-
run: make mypy
32-
- name: lint
33-
run: make lint
34-
- name: fmtcheck
35-
run: make fmtcheck
31+
- name: check examples w/ mypy (against [email protected])
32+
run: just typecheck-examples
33+
# skip deps on all these since mypy installed everything
34+
- name: check linting
35+
run: just --no-deps lint
36+
- name: check formatting
37+
run: just --no-deps format-check
38+
# pyright depends on node, which it handles and installs for itself as needed
39+
# we _could_ run setup-node to make it available for it if we're having reliability problems
40+
- name: check types (all Python versions)
41+
run: |
42+
set -eox
43+
44+
for minor in {6..12}; do
45+
just --no-deps typecheck $minor
46+
done
3647
3748
build:
3849
name: Build
3950
runs-on: ubuntu-latest
4051
steps:
52+
- uses: extractions/setup-just@v2
4153
- uses: actions/checkout@v3
4254

4355
- name: Set up Python 3
4456
uses: actions/setup-python@v4
4557
with:
4658
python-version: "3.10"
4759

48-
- name: Install tools
49-
run: make venv
50-
5160
- name: Build and check package
5261
run: |
53-
set -x
54-
source venv/bin/activate
55-
python setup.py clean --all sdist bdist_wheel --universal
56-
python -m twine check dist/*
62+
just build
5763
5864
- name: "Upload Artifact"
5965
uses: actions/upload-artifact@v3
@@ -69,45 +75,30 @@ jobs:
6975
strategy:
7076
fail-fast: false
7177
matrix:
72-
python:
73-
- { version: "3.6" , env: "py36" }
74-
- { version: "3.7" , env: "py37" }
75-
- { version: "3.8" , env: "py38" }
76-
- { version: "3.9" , env: "py39" }
77-
- { version: "3.10" , env: "py310" }
78-
- { version: "3.11" , env: "py311" }
79-
- { version: "3.12" , env: "py312" }
80-
- { version: "pypy-3.7" , env: "py3.7" }
81-
- { version: "pypy-3.8" , env: "py3.8" }
82-
- { version: "pypy-3.9" , env: "py3.9" }
83-
- { version: "pypy-3.10" , env: "py3.10" }
84-
name: Test (${{ matrix.python.version }})
78+
python_version:
79+
- "3.6"
80+
- "3.7"
81+
- "3.8"
82+
- "3.9"
83+
- "3.10"
84+
- "3.11"
85+
- "3.12"
86+
- "pypy-3.7"
87+
- "pypy-3.8"
88+
- "pypy-3.9"
89+
- "pypy-3.10"
90+
name: Test (${{ matrix.python_version }})
8591
steps:
92+
- uses: extractions/setup-just@v2
8693
- uses: actions/checkout@v3
87-
88-
- name: Set up Python ${{ matrix.python.version }} and 3.10
94+
- name: Set up Python ${{ matrix.python_version }}
8995
uses: actions/setup-python@v4
9096
with:
91-
python-version: |
92-
${{ matrix.python.version }}
93-
3.10
94-
97+
python-version: ${{ matrix.python_version }}
9598
- uses: stripe/openapi/actions/stripe-mock@master
9699

97-
- name: Typecheck with pyright
98-
run: PYRIGHT_ARGS="-- --pythonversion ${{ matrix.python.version }}" make pyright
99-
# Skip typecheking in pypy legs
100-
if: ${{ !contains(matrix.python.version, 'pypy') }}
101-
102-
- name: Test with pytest
103-
run: TOX_ARGS="-e ${{ matrix.python.env }}" make ci-test
104-
105-
- name: Calculate and publish coverage
106-
run: make coveralls
107-
if: env.COVERALLS_REPO_TOKEN && matrix.python.version == '3.10'
108-
env:
109-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
110-
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
100+
- name: "run tests"
101+
run: just test
111102

112103
publish:
113104
name: Publish
@@ -137,11 +128,12 @@ jobs:
137128
GPG_SIGNING_PRIVKEY: ${{ secrets.GPG_SIGNING_PRIVKEY }}
138129
GPG_SIGNING_PASSPHRASE: ${{ secrets.GPG_SIGNING_PASSPHRASE }}
139130
- name: Install tools
140-
run: make venv
141-
- name: Publish packages to PyPy
131+
run: just install-build-deps
132+
- name: Publish packages to PyPI
133+
# could probably move this into a just recipe too?
142134
run: |
143135
set -ex
144-
source venv/bin/activate
136+
source .venv/bin/activate
145137
export VERSION=$(cat VERSION)
146138
gpg --detach-sign --local-user $GPG_SIGNING_KEYID --pinentry-mode loopback --passphrase $GPG_SIGNING_PASSPHRASE -a dist/stripe-$VERSION.tar.gz
147139
gpg --detach-sign --local-user $GPG_SIGNING_KEYID --pinentry-mode loopback --passphrase $GPG_SIGNING_PASSPHRASE -a dist/stripe-$VERSION-py2.py3-none-any.whl

MANIFEST.in

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
include .coveragerc .flake8 CHANGELOG.md LICENSE LONG_DESCRIPTION.rst README.md VERSION pytest.ini tox.ini
1+
# this file specifies what's included in a source distribution (https://packaging.python.org/en/latest/glossary/#term-Source-Distribution-or-sdist)
2+
# see also: https://setuptools.pypa.io/en/latest/userguide/miscellaneous.html
3+
include .flake8 CHANGELOG.md LICENSE LONG_DESCRIPTION.rst README.md VERSION pytest.ini justfile
24
recursive-include tests *.py
35
recursive-include examples *.txt *.py

Makefile

Lines changed: 0 additions & 49 deletions
This file was deleted.

README.md

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
[![pypi](https://img.shields.io/pypi/v/stripe.svg)](https://pypi.python.org/pypi/stripe)
44
[![Build Status](https://github.com/stripe/stripe-python/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/stripe/stripe-python/actions?query=branch%3Amaster)
5-
[![Coverage Status](https://coveralls.io/repos/github/stripe/stripe-python/badge.svg?branch=master)](https://coveralls.io/github/stripe/stripe-python?branch=master)
65

76
The Stripe Python library provides convenient access to the Stripe API from
87
applications written in the Python language. It includes a pre-defined set of
@@ -341,54 +340,57 @@ go install github.com/stripe/stripe-mock@latest
341340
stripe-mock
342341
```
343342
344-
Run the following command to set up the development virtualenv:
343+
We use [just](https://github.com/casey/just) for conveniently running development tasks. You can use them directly, or copy the commands out of the `justfile`. To our help docs, run `just`. By default, all commands will use an virtualenv created by your default python version (whatever comes out of `python --version`). We recommend using [mise](https://mise.jdx.dev/lang/python.html) or [pyenv](https://github.com/pyenv/pyenv) to control that version.
345344
346-
```sh
347-
make
348-
```
349-
350-
Run all tests on all supported Python versions:
345+
Run the following command to set up the development virtualenv:
351346
352347
```sh
353-
make test
348+
just venv
349+
# or: python -m venv venv && venv/bin/python -I -m pip install -e .
354350
```
355351
356-
Run all tests for a specific Python version (modify `-e` according to your Python target):
352+
Run all tests:
357353
358354
```sh
359-
TOX_ARGS="-e py37" make test
355+
just test
356+
# or: venv/bin/pytest
360357
```
361358
362359
Run all tests in a single file:
363360
364361
```sh
365-
TOX_ARGS="-e py37 -- tests/api_resources/abstract/test_updateable_api_resource.py" make test
362+
just test tests/api_resources/abstract/test_updateable_api_resource.py
363+
# or: venv/bin/pytest tests/api_resources/abstract/test_updateable_api_resource.py
366364
```
367365
368366
Run a single test suite:
369367
370368
```sh
371-
TOX_ARGS="-e py37 -- tests/api_resources/abstract/test_updateable_api_resource.py::TestUpdateableAPIResource" make test
369+
just test tests/api_resources/abstract/test_updateable_api_resource.py::TestUpdateableAPIResource
370+
# or: venv/bin/pytest tests/api_resources/abstract/test_updateable_api_resource.py::TestUpdateableAPIResource
372371
```
373372
374373
Run a single test:
375374
376375
```sh
377-
TOX_ARGS="-e py37 -- tests/api_resources/abstract/test_updateable_api_resource.py::TestUpdateableAPIResource::test_save" make test
376+
just test tests/api_resources/abstract/test_updateable_api_resource.py::TestUpdateableAPIResource::test_save
377+
# or: venv/bin/pytest tests/api_resources/abstract/test_updateable_api_resource.py::TestUpdateableAPIResource::test_save
378378
```
379379
380380
Run the linter with:
381381
382382
```sh
383-
make lint
383+
just lint
384+
# or: venv/bin/python -m flake8 --show-source stripe tests setup.py
384385
```
385386
386387
The library uses [Ruff][ruff] for code formatting. Code must be formatted
387388
with Black before PRs are submitted, otherwise CI will fail. Run the formatter
388389
with:
389390
390391
```sh
391-
make fmt
392+
just format
393+
# or: venv/bin/ruff format . --quiet
392394
```
393395
394396
[api-keys]: https://dashboard.stripe.com/account/apikeys

deps/build-requirements.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# packages needed to package & release
2+
3+
twine
4+
setuptools

deps/dev-requirements.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# packages needed to run static analysis (lints, types, etc)
2+
# version requirements: any modern python version (currently 3.10)
3+
4+
# typechecking for all versions
5+
pyright == 1.1.336
6+
# general typechecking
7+
mypy == 1.7.0
8+
# formatting
9+
ruff == 0.4.4
10+
# linting
11+
flake8
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# These requirements must be installable on all our supported versions
1+
# packages needed to run unit tests (including extra supported http libraries)
2+
# version requirements: all supported versions (currently 3.6-3.12)
23

34
# This is the last version of httpx compatible with Python 3.6
45
httpx == 0.22.0; python_version == "3.6"
@@ -8,10 +9,7 @@ aiohttp == 3.8.6; python_version <= "3.7"
89
aiohttp == 3.9.4; python_version > "3.7"
910
anyio[trio] == 3.6.2
1011

11-
pytest-cov >= 2.8.1, < 2.11.0
1212
pytest-mock >= 2.0.0
1313
mock >= 4.0; python_version < "3.8"
1414
pytest-xdist >= 1.31.0
1515
pytest >= 6.0.0
16-
coverage >= 4.5.3, < 5
17-
coveralls

justfile

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
set quiet
2+
3+
import? '../sdk-codegen/justfile'
4+
5+
VENV_NAME := ".venv"
6+
7+
export PATH := `pwd` / VENV_NAME / "bin:" + env('PATH')
8+
9+
_default:
10+
just --list --unsorted
11+
12+
# ⭐ run all unit tests
13+
test *args: install-test-deps
14+
# configured in pyproject.toml
15+
pytest {{ args }}
16+
17+
# ⭐ check for potential mistakes
18+
lint: install-dev-deps
19+
python -m flake8 --show-source stripe tests setup.py
20+
21+
# verify types. optional argument to test as of a specific minor python version (e.g. `8` to test `python 3.8`); otherwise uses current version
22+
typecheck minor_py_version="": install-test-deps install-dev-deps
23+
# suppress version update warnings
24+
PYRIGHT_PYTHON_IGNORE_WARNINGS=1 pyright {{ if minor_py_version == "" { "" } else { "--pythonversion 3." + minor_py_version } }}
25+
26+
# ⭐ format all code
27+
format: install-dev-deps
28+
ruff format . --quiet
29+
30+
# verify formatting, but don't modify files
31+
format-check: install-dev-deps
32+
ruff format . --check --quiet
33+
34+
# remove venv
35+
clean:
36+
# clear old files too
37+
rm -rf {{ VENV_NAME }} venv .tox
38+
39+
# blow away and reinstall virtual env
40+
reset: clean && venv
41+
42+
# build the package for upload
43+
build: install-build-deps
44+
# --universal is deprecated, so we'll probably need to look at this eventually
45+
# given that we don't care about universal 2 and 3 packages, we probably don't need it?
46+
python -I setup.py clean --all sdist bdist_wheel --universal
47+
python -m twine check dist/*
48+
49+
# typecheck some examples w/ mypy
50+
typecheck-examples: _install-all
51+
# configured in pyproject.toml
52+
mypy
53+
54+
# install the tools for local development & static checks
55+
install-dev-deps: (install "dev")
56+
57+
# install everything for unit tests
58+
install-test-deps: (install "test")
59+
60+
# install dependencies to build the package
61+
install-build-deps: (install "build")
62+
63+
_install-all: install-dev-deps install-test-deps install-build-deps
64+
65+
# installs files out of a {group}-requirements.txt into the local venv; mostly used by other recipes
66+
install group: venv
67+
python -I -m pip install -r deps/{{ group }}-requirements.txt --disable-pip-version-check {{ if is_dependency() == "true" {"--quiet"} else {""} }}
68+
69+
# create a virtualenv if it doesn't exist; always installs the local package
70+
[private]
71+
venv:
72+
[ -d {{ VENV_NAME }} ] || ( \
73+
python -m venv {{ VENV_NAME }} && \
74+
{{ VENV_NAME }}/bin/python -I -m pip install -e . --quiet --disable-pip-version-check \
75+
)
76+
77+
# called by tooling
78+
[private]
79+
update-version version:
80+
@echo "{{ version }}" > VERSION
81+
@perl -pi -e 's|VERSION = "[.\d\w]+"|VERSION = "{{ version }}"|' stripe/_version.py

0 commit comments

Comments
 (0)