Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to pytest, add Github action for test suite #186

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
**/__pycache__
**/*.egg-info
/pkcs11/*.c
/pkcs11/*.so
/build/
/dist/
31 changes: 12 additions & 19 deletions .github/workflows/quality.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,29 @@
name: Code quality
on:
push:
pull_request:

jobs:

run:
runs-on: ubuntu-latest

steps:

- name: Acquire sources
uses: actions/checkout@v4.1.1

- name: Install uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true

- name: Setup Python
uses: actions/setup-python@v5.0.0
with:
python-version: "3.12"
python-version: "3.13"
architecture: x64

- name: Apply caching of dependencies
uses: actions/cache@v4.0.0
with:
path: ~/.cache/pip
key: pip-${{ hashFiles('**/requirements-*.txt') }}
- name: Install dev dependencies
run: uv sync --python-preference only-system

- name: Install dependencies
run: |
pip install -U pip setuptools wheel
pip install -r requirements.txt -r dev-requirements.txt
- name: ruff format
run: uv run ruff format --diff .

- name: Run ruff
run: |
ruff format --diff .
ruff check --diff .
- name: ruff check
run: uv run ruff check --diff .
51 changes: 51 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Tests
on:
push:
env:
PKCS11_MODULE: /home/runner/lib/softhsm/libsofthsm2.so
jobs:
run:
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "3.12"
- "3.13"

steps:
- name: Acquire sources
uses: actions/checkout@v4.1.1

- name: Install uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true

- name: Setup Python
uses: actions/setup-python@v5.0.0
with:
python-version: ${{ matrix.python-version }}
architecture: x64

- name: Create venv
run: uv venv --python-preference only-system --python ${{ matrix.python-version }}

- name: Update setuptools
run: uv pip install setuptools

# Locally compile softhsmv2. For unknown reasons, the version installed by Ubuntu fails on
# Github Actions (while working e.g. in Docker).
- name: Install Softhsm
run: |
curl https://dist.opendnssec.org/source/softhsm-2.6.1.tar.gz | tar -zxv
(cd softhsm-2.6.1 && ./configure --prefix=$HOME --disable-p11-kit --disable-gost && make all install CC="gcc" CXX="g++")

- name: Install the project
run: uv sync --all-extras --python-preference only-system --python ${{ matrix.python-version }}

- name: Run tests
run: PATH=/home/runner/bin:$PATH uv run --python ${{ matrix.python-version }} pytest -v tests/test_aes.py::test_encrypt
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
*.so
*.c
__pycache__

/build
/.idea/
/build/
/dist/
/docs/_build
/python_pkcs11.egg-info/
Expand Down
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.13
45 changes: 0 additions & 45 deletions .travis.yml

This file was deleted.

21 changes: 21 additions & 0 deletions Dockerfile.debian
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
ARG IMAGE=debian:stable
FROM $IMAGE

RUN apt-get update && \
DEBIAN_FRONTEND="noninteractive" apt-get install -y gcc python3 python3-dev softhsm2 openssl && \
rm -rf /var/lib/apt/lists/*

COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/

WORKDIR /test

ADD uv.lock pyproject.toml .
ADD pkcs11/ pkcs11/
ADD extern/ extern/

ENV UV_LINK_MODE=copy
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --all-extras

ADD tests/ tests/
CMD ["uv", "run", "pytest", "-v"]
Loading
Loading