Skip to content

Commit 052492b

Browse files
authored
Merge pull request #61 from sicpa-dlab/main
Release 0.3.1
2 parents 153620f + 0bf6051 commit 052492b

File tree

11 files changed

+904
-176
lines changed

11 files changed

+904
-176
lines changed

.github/scripts/current_version.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"""Print current version of package as GHA output."""
2+
3+
import tomli
4+
5+
with open("pyproject.toml", "rb") as f:
6+
project = tomli.load(f)
7+
8+
print("::set-output name=current_version::" + project["tool"]["poetry"]["version"])

.github/workflows/release.yml

+49-56
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,16 @@ jobs:
3131

3232
steps:
3333
- uses: actions/checkout@v2
34-
35-
- uses: actions/setup-python@v2
34+
- name: Setup Python
35+
id: setup
36+
uses: actions/setup-python@v4
3637
with:
3738
python-version: '3.x'
38-
39+
- name: Install dependencies
40+
run: pip install tomli
3941
- name: Get current version
4042
id: current_version
41-
run: |
42-
python -m pip install . --no-deps
43-
out="$(pip show ${{ env.PKG_NAME }} | grep 'Version:' | awk '{print $2}')"
44-
echo "$out"
45-
echo "::set-output name=current_version::$out"
46-
shell: bash
47-
43+
run: python ./.github/scripts/current_version.py
4844
- name: Get release info
4945
id: release_info
5046
run: |
@@ -66,7 +62,6 @@ jobs:
6662
upload_url="$(echo "$release_info" | jq -r '.upload_url')"
6763
echo "::set-output name=upload_url::$upload_url"
6864
echo "$upload_url"
69-
shell: bash
7065
7166
- name: check if already deployed to PyPI
7267
id: check_in_pypi
@@ -87,27 +82,32 @@ jobs:
8782
runs-on: ubuntu-latest
8883
needs: checks
8984
steps:
90-
- uses: actions/checkout@v2
85+
- uses: actions/checkout@v3
86+
87+
- name: Install poetry
88+
run: pipx install poetry
9189

92-
- uses: actions/setup-python@v2
90+
- uses: actions/setup-python@v4
91+
id: setup
9392
with:
9493
python-version: '3.x'
94+
cache: 'poetry'
95+
96+
- name: Install dependencies
97+
if: steps.setup.outputs.cache-hit != 'true'
98+
run: poetry install
9599

96100
- name: build dist
97101
id: build_assets
98102
if: ${{ !(needs.checks.outputs.asset_tgz_url && needs.checks.outputs.asset_whl_url) }}
99103
run: |
100-
python -m pip install --upgrade pip
101-
python -m pip install --upgrade build
102-
python -m build
103-
ls dist
104+
poetry build
104105
105106
asset_tgz_name="$(find dist -name '*.tar.gz' -printf '%f')"
106107
echo "::set-output name=asset_tgz_name::$asset_tgz_name"
107108
108109
asset_whl_name="$(find dist -name '*.whl' -printf '%f')"
109110
echo "::set-output name=asset_whl_name::$asset_whl_name"
110-
shell: bash
111111
112112
- name: Create Release
113113
id: create_release
@@ -157,7 +157,10 @@ jobs:
157157
runs-on: ubuntu-latest
158158
needs: [checks, release-github]
159159
steps:
160-
- uses: actions/checkout@v2
160+
- uses: actions/checkout@v3
161+
162+
- name: Install poetry
163+
run: pipx install poetry
161164

162165
- name: download GitHub artifacts
163166
run: |
@@ -167,62 +170,52 @@ jobs:
167170
| jq -r ".assets[] | select(.name | contains(\"${{ env.PKG_NAME }}\")) | .browser_download_url" \
168171
| wget -i -
169172
ls
170-
shell: bash
171173
172-
# NOTE uncomment once community actions are allowed for the github org
173-
# - name: Publish to PyPI
174-
# uses: pypa/[email protected]
175-
# with:
176-
# user: __token__
177-
# password: ${{ secrets.PYPI_API_TOKEN }}
178-
179-
- uses: actions/setup-python@v2
174+
- uses: actions/setup-python@v4
180175
with:
181176
python-version: '3.x'
182177

183-
- name: Prepare python env
184-
run: |
185-
python -m pip install --upgrade pip
186-
python -m pip install --upgrade twine
187-
shell: bash
188-
189178
- name: Publish to PyPI
190179
env:
191-
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
192-
run: python -m twine upload --non-interactive --username __token__ dist/*
193-
shell: bash
180+
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_API_TOKEN }}
181+
run: poetry publish
194182

195183
deploy-test-pypi:
196184
name: Deploy to TestPyPI
197185
if: github.ref != 'refs/heads/stable' && github.event_name == 'workflow_dispatch'
198186
runs-on: ubuntu-latest
199187
steps:
200-
- uses: actions/checkout@v2
188+
- uses: actions/checkout@v3
189+
190+
- name: Get current version
191+
id: current_version
192+
run: |
193+
pip install tomli
194+
python ./.github/scripts/current_version.py
201195
202-
- uses: actions/setup-python@v2
196+
- name: Install poetry
197+
run: pipx install poetry
198+
199+
- uses: actions/setup-python@v4
200+
id: setup
203201
with:
204202
python-version: '3.x'
203+
cache: 'poetry'
204+
205+
- name: Install dependencies
206+
if: steps.setup.outputs.cache-hit != 'true'
207+
run: poetry install
205208

206209
- name: set dev version
207210
run: |
208-
sed -i -r "s~__version__ = \"(.+)\"~__version__ = \"\1.dev${{ github.event.inputs.devN }}\"~" ./didcomm/__init__.py
209-
grep version ./setup.py
210-
shell: bash
211+
poetry version "${{ steps.current_version.outputs.current_version }}.dev${{ github.event.inputs.devN }}"
211212
212213
- name: build dist
213-
run: |
214-
python -m pip install --upgrade pip
215-
python -m pip install --upgrade build
216-
python -m build
217-
ls dist
218-
shell: bash
219-
220-
- name: install twine
221-
run: python -m pip install --upgrade twine
222-
shell: bash
214+
run: poetry build
223215

224-
- name: Publish to TestPyPI
216+
- name: Publish to Test PyPI
225217
env:
226-
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }}
227-
run: python -m twine upload --non-interactive --username __token__ --repository testpypi dist/*
228-
shell: bash
218+
POETRY_PYPI_TOKEN_TEST_PYPI: ${{ secrets.PYPI_API_TOKEN }}
219+
run: |
220+
poetry config repositories.test-pypi https://test.pypi.org/legacy/
221+
poetry publish -r test-pypi

.github/workflows/verify.yml

+29-36
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,19 @@ jobs:
1616
runs-on: ubuntu-latest
1717
if: github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'stable'
1818
steps:
19-
- uses: actions/checkout@v2
19+
- uses: actions/checkout@v3
2020

21-
- uses: actions/setup-python@v2
21+
- uses: actions/setup-python@v4
22+
id: setup
2223
with:
2324
python-version: '3.x'
2425

26+
- name: Install dependencies
27+
run: pip install tomli
28+
2529
- name: Get current version
2630
id: current_version
27-
run: |
28-
python -m pip install --upgrade pip
29-
pip install . --no-deps
30-
out="$(pip show ${{ env.PKG_NAME }} | grep 'Version:' | awk '{print $2}')"
31-
echo "$out"
32-
echo "::set-output name=current_version::$out"
33-
shell: bash
31+
run: python ./.github/scripts/current_version.py
3432

3533
- name: Check version format
3634
run: |
@@ -56,31 +54,33 @@ jobs:
5654
static-black:
5755
runs-on: ubuntu-latest
5856
steps:
59-
- uses: actions/checkout@v2
57+
- uses: actions/checkout@v3
6058

6159
- name: Set up Python 3.7
62-
uses: actions/setup-python@v2
60+
id: setup
61+
uses: actions/setup-python@v4
6362
with:
64-
python-version: 3.7
63+
python-version: '3.7'
6564

6665
- name: Install black
67-
run: pip install black
66+
run: pipx install black
6867

6968
- name: Black Format Check
7069
run: black --check .
7170

7271
static-flake8:
7372
runs-on: ubuntu-latest
7473
steps:
75-
- uses: actions/checkout@v2
74+
- uses: actions/checkout@v3
7675

77-
- name: Set up Python
78-
uses: actions/setup-python@v2
76+
- name: Set up Python 3.7
77+
id: setup
78+
uses: actions/setup-python@v4
7979
with:
80-
python-version: 3.7
80+
python-version: '3.7'
8181

8282
- name: Install flake8
83-
run: pip install flake8
83+
run: pipx install flake8
8484

8585
- name: Lint with flake8
8686
run: flake8 .
@@ -97,28 +97,21 @@ jobs:
9797
- {python-version: '3.7', toxenv: py37}
9898
runs-on: ${{ matrix.os }}
9999
steps:
100-
- uses: actions/checkout@v2
100+
- uses: actions/checkout@v3
101+
102+
- name: Install poetry
103+
run: pipx install poetry
101104

102105
- name: Set up Python ${{ matrix.python-version }}
103-
uses: actions/setup-python@v2
106+
id: setup
107+
uses: actions/setup-python@v4
104108
with:
105109
python-version: ${{ matrix.python-version }}
110+
cache: 'poetry'
106111

107-
- name: pip update
108-
run: python -m pip install -U pip
109-
110-
- name: resolve pip cache dir
111-
id: pip_cache_dir
112-
run: echo "::set-output name=value::$(pip cache dir)"
113-
114-
- name: cache pip
115-
uses: actions/cache@v2
116-
with:
117-
path: ${{ steps.pip_cache_dir.outputs.value }}
118-
key: ${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('setup.py') }}
119-
120-
- name: Install tox
121-
run: pip install tox
112+
- name: Install dependencies
113+
if: steps.setup.outputs.cache-hit != 'true'
114+
run: poetry install
122115

123116
- name: Test with pytest
124-
run: tox -e ${{ matrix.toxenv }}
117+
run: poetry run tox -e ${{ matrix.toxenv }}

MANIFEST.in

-5
This file was deleted.

didcomm/core/from_prior.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from typing import Optional
22

33
from authlib.common.encoding import to_unicode, to_bytes, json_loads, urlsafe_b64decode
4-
from authlib.jose import JsonWebToken
4+
from authlib.jose import jwt
55
from authlib.jose.errors import BadSignatureError
66

77
from didcomm.common.resolvers import ResolversConfig
@@ -58,8 +58,6 @@ async def pack_from_prior_in_place(
5858

5959
issuer_did_or_kid = issuer_kid or from_prior["iss"]
6060

61-
jwt = JsonWebToken()
62-
6361
secret = await find_signing_key(issuer_did_or_kid, resolvers_config)
6462
private_key = extract_key(
6563
secret, align_kid=True
@@ -104,7 +102,6 @@ async def unpack_from_prior_in_place(
104102
public_key = extract_key(verification_method)
105103

106104
try:
107-
jwt = JsonWebToken()
108105
message["from_prior"] = jwt.decode(to_bytes(from_prior_jwt), public_key)
109106
except BadSignatureError as exc:
110107
raise MalformedMessageError(

docs/testing.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
## Development Environment Setup
1515

1616
```bash
17-
pip install -e .[tests]
17+
poetry install
1818
```
1919

2020
## Static Testing
@@ -24,33 +24,33 @@ pip install -e .[tests]
2424
Run [flake8](https://flake8.pycqa.org/en/latest/) as follows:
2525

2626
```bash
27-
$ flake8 .
27+
$ poetry run flake8 .
2828
```
2929

3030
### black
3131

3232
Run [black](https://black.readthedocs.io/en/stable/usage_and_configuration/index.html) for a dry check as follows:
3333

3434
```bash
35-
$ black --check .
35+
$ poetry run black --check .
3636
```
3737

3838
or to auto-format:
3939

4040
```bash
41-
$ black .
41+
$ poetry run black .
4242
```
4343

4444
## Unit Testing
4545

4646
To run [pytest](https://docs.pytest.org/en/stable/) in your environment:
4747

4848
```bash
49-
pytest
49+
poetry run pytest
5050
```
5151

5252
To run tests in all supported environments (like CI does) using [tox](https://tox.wiki/en/latest/index.html):
5353

5454
```bash
55-
tox
55+
poetry run tox
5656
```

0 commit comments

Comments
 (0)