From d8b29c73d979300850842de71013daa45cb70e29 Mon Sep 17 00:00:00 2001 From: Daniel Bluhm Date: Mon, 30 Oct 2023 11:10:47 -0400 Subject: [PATCH 1/2] ci: setup github actions Signed-off-by: Daniel Bluhm --- .github/workflows/code-quality-check.yml | 18 ++++++++++++++++++ .github/workflows/publish.yml | 24 ++++++++++++++++++++++++ .github/workflows/tests.yml | 24 ++++++++++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 .github/workflows/code-quality-check.yml create mode 100644 .github/workflows/publish.yml create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/code-quality-check.yml b/.github/workflows/code-quality-check.yml new file mode 100644 index 0000000..66ac130 --- /dev/null +++ b/.github/workflows/code-quality-check.yml @@ -0,0 +1,18 @@ +name: Code Quality Check + +"on": + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + format: + name: Format and Lint Check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: psf/black@stable + - uses: chartboost/ruff-action@v1 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..de1f1c0 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,24 @@ +name: Publish +on: + release: + types: [created] + +jobs: + deploy: + runs-on: ubuntu-latest + permissions: + id-token: write + + steps: + - uses: actions/checkout@v3 + - name: Setup Python + uses: pdm-project/setup-pdm@v3 + with: + python-version: 3.9 + cache: true + - name: Install dependencies + run: pdm install + - name: Run pytest + run: pdm run pytest + - name: Publish + run: pdm publish diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..5f82860 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,24 @@ +name: Tests +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + test: + name: Tests + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.9", "3.10", "3.11"] + steps: + - uses: actions/checkout@v3 + - uses: pdm-project/setup-pdm@v3 + with: + python-version: ${{ matrix.python-version }} + cache: true + - name: Install dependencies + run: pdm install + - name: Run pytest + run: pdm run pytest From 9d6a763f3ca639370212ce0e46531deb46954da7 Mon Sep 17 00:00:00 2001 From: Daniel Bluhm Date: Mon, 30 Oct 2023 11:25:07 -0400 Subject: [PATCH 2/2] style: formatting fixes Signed-off-by: Daniel Bluhm --- didcomm_messaging/multiformats/multibase.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/didcomm_messaging/multiformats/multibase.py b/didcomm_messaging/multiformats/multibase.py index 10b88bf..f66163c 100644 --- a/didcomm_messaging/multiformats/multibase.py +++ b/didcomm_messaging/multiformats/multibase.py @@ -41,17 +41,20 @@ def decode(self, value: str) -> bytes: class Base64UrlEncoder(MultibaseEncoder): """Base64URL encoding.""" + name = "base64url" character = "u" def encode(self, value: bytes) -> str: """Encode a byte string using the base64url encoding.""" import base64 + return base64.urlsafe_b64encode(value).decode().rstrip("=") def decode(self, value: str) -> bytes: """Decode a base64url encoded string.""" import base64 + return base64.urlsafe_b64decode(value + "=" * (-len(value) % 4))