Skip to content

Commit

Permalink
Merge pull request #61 from sicpa-dlab/main
Browse files Browse the repository at this point in the history
Release 0.3.1
  • Loading branch information
chumbert authored Oct 20, 2022
2 parents 153620f + 0bf6051 commit 052492b
Show file tree
Hide file tree
Showing 11 changed files with 904 additions and 176 deletions.
8 changes: 8 additions & 0 deletions .github/scripts/current_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"""Print current version of package as GHA output."""

import tomli

with open("pyproject.toml", "rb") as f:
project = tomli.load(f)

print("::set-output name=current_version::" + project["tool"]["poetry"]["version"])
105 changes: 49 additions & 56 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,16 @@ jobs:

steps:
- uses: actions/checkout@v2

- uses: actions/setup-python@v2
- name: Setup Python
id: setup
uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: Install dependencies
run: pip install tomli
- name: Get current version
id: current_version
run: |
python -m pip install . --no-deps
out="$(pip show ${{ env.PKG_NAME }} | grep 'Version:' | awk '{print $2}')"
echo "$out"
echo "::set-output name=current_version::$out"
shell: bash

run: python ./.github/scripts/current_version.py
- name: Get release info
id: release_info
run: |
Expand All @@ -66,7 +62,6 @@ jobs:
upload_url="$(echo "$release_info" | jq -r '.upload_url')"
echo "::set-output name=upload_url::$upload_url"
echo "$upload_url"
shell: bash
- name: check if already deployed to PyPI
id: check_in_pypi
Expand All @@ -87,27 +82,32 @@ jobs:
runs-on: ubuntu-latest
needs: checks
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Install poetry
run: pipx install poetry

- uses: actions/setup-python@v2
- uses: actions/setup-python@v4
id: setup
with:
python-version: '3.x'
cache: 'poetry'

- name: Install dependencies
if: steps.setup.outputs.cache-hit != 'true'
run: poetry install

- name: build dist
id: build_assets
if: ${{ !(needs.checks.outputs.asset_tgz_url && needs.checks.outputs.asset_whl_url) }}
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade build
python -m build
ls dist
poetry build
asset_tgz_name="$(find dist -name '*.tar.gz' -printf '%f')"
echo "::set-output name=asset_tgz_name::$asset_tgz_name"
asset_whl_name="$(find dist -name '*.whl' -printf '%f')"
echo "::set-output name=asset_whl_name::$asset_whl_name"
shell: bash
- name: Create Release
id: create_release
Expand Down Expand Up @@ -157,7 +157,10 @@ jobs:
runs-on: ubuntu-latest
needs: [checks, release-github]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Install poetry
run: pipx install poetry

- name: download GitHub artifacts
run: |
Expand All @@ -167,62 +170,52 @@ jobs:
| jq -r ".assets[] | select(.name | contains(\"${{ env.PKG_NAME }}\")) | .browser_download_url" \
| wget -i -
ls
shell: bash
# NOTE uncomment once community actions are allowed for the github org
# - name: Publish to PyPI
# uses: pypa/gh-action-pypi-publish@v1.4.2
# with:
# user: __token__
# password: ${{ secrets.PYPI_API_TOKEN }}

- uses: actions/setup-python@v2
- uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: Prepare python env
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade twine
shell: bash

- name: Publish to PyPI
env:
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: python -m twine upload --non-interactive --username __token__ dist/*
shell: bash
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_API_TOKEN }}
run: poetry publish

deploy-test-pypi:
name: Deploy to TestPyPI
if: github.ref != 'refs/heads/stable' && github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Get current version
id: current_version
run: |
pip install tomli
python ./.github/scripts/current_version.py
- uses: actions/setup-python@v2
- name: Install poetry
run: pipx install poetry

- uses: actions/setup-python@v4
id: setup
with:
python-version: '3.x'
cache: 'poetry'

- name: Install dependencies
if: steps.setup.outputs.cache-hit != 'true'
run: poetry install

- name: set dev version
run: |
sed -i -r "s~__version__ = \"(.+)\"~__version__ = \"\1.dev${{ github.event.inputs.devN }}\"~" ./didcomm/__init__.py
grep version ./setup.py
shell: bash
poetry version "${{ steps.current_version.outputs.current_version }}.dev${{ github.event.inputs.devN }}"
- name: build dist
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade build
python -m build
ls dist
shell: bash

- name: install twine
run: python -m pip install --upgrade twine
shell: bash
run: poetry build

- name: Publish to TestPyPI
- name: Publish to Test PyPI
env:
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }}
run: python -m twine upload --non-interactive --username __token__ --repository testpypi dist/*
shell: bash
POETRY_PYPI_TOKEN_TEST_PYPI: ${{ secrets.PYPI_API_TOKEN }}
run: |
poetry config repositories.test-pypi https://test.pypi.org/legacy/
poetry publish -r test-pypi
65 changes: 29 additions & 36 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,19 @@ jobs:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'stable'
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: actions/setup-python@v2
- uses: actions/setup-python@v4
id: setup
with:
python-version: '3.x'

- name: Install dependencies
run: pip install tomli

- name: Get current version
id: current_version
run: |
python -m pip install --upgrade pip
pip install . --no-deps
out="$(pip show ${{ env.PKG_NAME }} | grep 'Version:' | awk '{print $2}')"
echo "$out"
echo "::set-output name=current_version::$out"
shell: bash
run: python ./.github/scripts/current_version.py

- name: Check version format
run: |
Expand All @@ -56,31 +54,33 @@ jobs:
static-black:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Set up Python 3.7
uses: actions/setup-python@v2
id: setup
uses: actions/setup-python@v4
with:
python-version: 3.7
python-version: '3.7'

- name: Install black
run: pip install black
run: pipx install black

- name: Black Format Check
run: black --check .

static-flake8:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v2
- name: Set up Python 3.7
id: setup
uses: actions/setup-python@v4
with:
python-version: 3.7
python-version: '3.7'

- name: Install flake8
run: pip install flake8
run: pipx install flake8

- name: Lint with flake8
run: flake8 .
Expand All @@ -97,28 +97,21 @@ jobs:
- {python-version: '3.7', toxenv: py37}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Install poetry
run: pipx install poetry

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
id: setup
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'poetry'

- name: pip update
run: python -m pip install -U pip

- name: resolve pip cache dir
id: pip_cache_dir
run: echo "::set-output name=value::$(pip cache dir)"

- name: cache pip
uses: actions/cache@v2
with:
path: ${{ steps.pip_cache_dir.outputs.value }}
key: ${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('setup.py') }}

- name: Install tox
run: pip install tox
- name: Install dependencies
if: steps.setup.outputs.cache-hit != 'true'
run: poetry install

- name: Test with pytest
run: tox -e ${{ matrix.toxenv }}
run: poetry run tox -e ${{ matrix.toxenv }}
5 changes: 0 additions & 5 deletions MANIFEST.in

This file was deleted.

5 changes: 1 addition & 4 deletions didcomm/core/from_prior.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Optional

from authlib.common.encoding import to_unicode, to_bytes, json_loads, urlsafe_b64decode
from authlib.jose import JsonWebToken
from authlib.jose import jwt
from authlib.jose.errors import BadSignatureError

from didcomm.common.resolvers import ResolversConfig
Expand Down Expand Up @@ -58,8 +58,6 @@ async def pack_from_prior_in_place(

issuer_did_or_kid = issuer_kid or from_prior["iss"]

jwt = JsonWebToken()

secret = await find_signing_key(issuer_did_or_kid, resolvers_config)
private_key = extract_key(
secret, align_kid=True
Expand Down Expand Up @@ -104,7 +102,6 @@ async def unpack_from_prior_in_place(
public_key = extract_key(verification_method)

try:
jwt = JsonWebToken()
message["from_prior"] = jwt.decode(to_bytes(from_prior_jwt), public_key)
except BadSignatureError as exc:
raise MalformedMessageError(
Expand Down
12 changes: 6 additions & 6 deletions docs/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
## Development Environment Setup

```bash
pip install -e .[tests]
poetry install
```

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

```bash
$ flake8 .
$ poetry run flake8 .
```

### black

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

```bash
$ black --check .
$ poetry run black --check .
```

or to auto-format:

```bash
$ black .
$ poetry run black .
```

## Unit Testing

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

```bash
pytest
poetry run pytest
```

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

```bash
tox
poetry run tox
```
Loading

0 comments on commit 052492b

Please sign in to comment.