Skip to content

Commit

Permalink
Add some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkaMaul committed Sep 25, 2024
1 parent e63c81a commit bcc3678
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 2 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Unit tests

on:
push:
branches:
- main
pull_request:

jobs:
test:
strategy:
matrix:
python:
- "3.12"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
cache: "pip"
cache-dependency-path: pyproject.toml

- name: install uv
run: >
curl --no-progress-meter --location --fail
--proto '=https' --tlsv1.2
"https://astral.sh/uv/install.sh"
| sh
- name: Setup rust
uses: dtolnay/rust-toolchain@1482605bfc5719782e1267fd0c0cc350fe7646b8
with:
components: rustfmt
toolchain: 1.81.0

- name: test
run: make test INSTALL_EXTRA=test
15 changes: 13 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
SHELL := /bin/bash

ALL_PY_SRCS := $(shell find src -name '*.py')
PY_IMPORT = sigstore_tsp

ALL_PY_SRCS := $(shell find src -name '*.py') \
$(shell find test -name '*.py')

# Optionally overriden by the user, if they're using a virtual environment manager.
VENV ?= .venv
Expand Down Expand Up @@ -61,4 +64,12 @@ reformat:

.PHONY: doc
doc:
@echo "No documentation set up"
@echo "No documentation set up"


.PHONY: test tests
test tests: $(VENV)/pyvenv.cfg
. $(VENV_BIN)/activate && \
pytest --cov=$(PY_IMPORT) $(T) $(TEST_ARGS) && \
python -m coverage report -m $(COV_ARGS)
cargo test --manifest-path rust/Cargo.toml
Empty file added test/__init__.py
Empty file.
6 changes: 6 additions & 0 deletions test/test_init.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import sigstore_tsp

def test_version() -> None:
version = getattr(sigstore_tsp, "__version__", None)
assert version is not None
assert isinstance(version, str)

0 comments on commit bcc3678

Please sign in to comment.