-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Facundo Tuesca <facundo.tuesca@trailofbits.com>
- Loading branch information
1 parent
2953cf5
commit 087934e
Showing
16 changed files
with
1,335 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
version: 2 | ||
|
||
updates: | ||
- package-ecosystem: pip | ||
directory: / | ||
groups: | ||
python: | ||
patterns: | ||
- "*" | ||
schedule: | ||
interval: daily | ||
|
||
- package-ecosystem: github-actions | ||
directory: / | ||
groups: | ||
actions: | ||
patterns: | ||
- "*" | ||
schedule: | ||
interval: daily |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Lint | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
working-directory: ./convert-attestations | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Install uv | ||
uses: astral-sh/setup-uv@v4 | ||
with: | ||
enable-cache: true | ||
cache-dependency-glob: convert-attestations/pyproject.toml | ||
|
||
- name: lint | ||
run: make lint INSTALL_EXTRA=lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Unit tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
test-python-package: | ||
strategy: | ||
matrix: | ||
python: | ||
- "3.13" | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
working-directory: ./convert-attestations | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Install uv | ||
uses: astral-sh/setup-uv@v4 | ||
with: | ||
enable-cache: true | ||
cache-dependency-glob: convert-attestations/pyproject.toml | ||
|
||
- name: Install Python ${{ matrix.python }} | ||
run: uv python install ${{ matrix.python }} | ||
|
||
- name: test | ||
run: make test INSTALL_EXTRA=test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
env/ | ||
pip-wheel-metadata/ | ||
*.egg-info/ | ||
__pycache__/ | ||
.coverage* | ||
.idea | ||
html/ | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
SHELL := /bin/bash | ||
|
||
PY_IMPORT = convert_attestations | ||
|
||
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 ?= env | ||
|
||
# On Windows, venv scripts/shims are under `Scripts` instead of `bin`. | ||
VENV_BIN := $(VENV)/bin | ||
ifeq ($(OS),Windows_NT) | ||
VENV_BIN := $(VENV)/Scripts | ||
endif | ||
|
||
# Optionally overridden by the user in the `release` target. | ||
BUMP_ARGS := | ||
|
||
# Optionally overridden by the user in the `test` target. | ||
TESTS := | ||
|
||
# Optionally overridden by the user/CI, to limit the installation to a specific | ||
# subset of development dependencies. | ||
INSTALL_EXTRA := dev | ||
|
||
# If the user selects a specific test pattern to run, set `pytest` to fail fast | ||
# and only run tests that match the pattern. | ||
# Otherwise, run all tests and enable coverage assertions, since we expect | ||
# complete test coverage. | ||
ifneq ($(TESTS),) | ||
TEST_ARGS := -x -k $(TESTS) | ||
COV_ARGS := | ||
else | ||
TEST_ARGS := | ||
COV_ARGS := --fail-under 100 | ||
endif | ||
|
||
.PHONY: all | ||
all: | ||
@echo "Run my targets individually!" | ||
|
||
.PHONY: dev | ||
dev: $(VENV)/pyvenv.cfg | ||
.PHONY: run | ||
run: $(VENV)/pyvenv.cfg | ||
# Once we can specify the default VENV name in uv, use `uv run` here | ||
# https://github.com/astral-sh/uv/issues/1422 | ||
@. $(VENV_BIN)/activate && convert-attestations $(ARGS) | ||
|
||
$(VENV)/pyvenv.cfg: pyproject.toml | ||
uv venv $(VENV) | ||
@. $(VENV_BIN)/activate && uv pip install -e '.[$(INSTALL_EXTRA)]' | ||
|
||
.PHONY: lint | ||
lint: $(VENV)/pyvenv.cfg | ||
. $(VENV_BIN)/activate && \ | ||
ruff format --check && \ | ||
ruff check && \ | ||
mypy | ||
. $(VENV_BIN)/activate && \ | ||
interrogate -c pyproject.toml . | ||
|
||
.PHONY: reformat | ||
reformat: | ||
. $(VENV_BIN)/activate && \ | ||
ruff format && \ | ||
ruff check --fix | ||
|
||
.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) | ||
|
||
.PHONY: doc | ||
doc: | ||
@echo "No documentation set up" | ||
|
||
.PHONY: package | ||
package: $(VENV)/pyvenv.cfg | ||
uv build | ||
|
||
.PHONY: edit | ||
edit: | ||
$(EDITOR) $(ALL_PY_SRCS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
[project] | ||
name = "convert-attestations" | ||
dynamic = ["version"] | ||
description = "" | ||
readme = "README.md" | ||
license = { file = "LICENSE" } | ||
authors = [ | ||
{ name = "Trail of Bits", email = "opensource@trailofbits.com" }, | ||
] | ||
classifiers = [ | ||
"Programming Language :: Python :: 3", | ||
"License :: OSI Approved :: Apache Software License", | ||
] | ||
dependencies = ["pypi-attestations == 0.0.19"] | ||
requires-python = ">=3.13" | ||
|
||
[tool.setuptools.dynamic] | ||
version = { attr = "convert_attestations.__version__" } | ||
|
||
[project.optional-dependencies] | ||
doc = [] | ||
test = ["pytest", "pytest-cov", "pretend", "coverage[toml]"] | ||
lint = [ | ||
# NOTE: ruff is under active development, so we pin conservatively here | ||
# and let Dependabot periodically perform this update. | ||
"ruff ~= 0.6.2", | ||
"mypy >= 1.0", | ||
"types-html5lib", | ||
"types-requests", | ||
"types-toml", | ||
"interrogate", | ||
] | ||
dev = ["convert-attestations[doc,test,lint]", "twine", "build"] | ||
|
||
[project.scripts] | ||
"convert-attestations" = "convert_attestations._cli:main" | ||
|
||
[project.urls] | ||
Homepage = "https://pypi.org/project/convert-attestations" | ||
Documentation = "https://trailofbits.github.io/convert-attestations/" | ||
Issues = "https://github.com/trailofbits/convert-attestations/issues" | ||
Source = "https://github.com/trailofbits/convert-attestations" | ||
|
||
[tool.coverage.run] | ||
# don't attempt code coverage for the CLI entrypoints | ||
omit = ["src/convert_attestations/_cli.py"] | ||
|
||
[tool.mypy] | ||
mypy_path = "src" | ||
packages = "convert_attestations" | ||
allow_redefinition = true | ||
check_untyped_defs = true | ||
disallow_incomplete_defs = true | ||
disallow_untyped_defs = true | ||
ignore_missing_imports = true | ||
no_implicit_optional = true | ||
show_error_codes = true | ||
sqlite_cache = true | ||
strict_equality = true | ||
warn_no_return = true | ||
warn_redundant_casts = true | ||
warn_return_any = true | ||
warn_unreachable = true | ||
warn_unused_configs = true | ||
warn_unused_ignores = true | ||
|
||
[tool.ruff] | ||
line-length = 100 | ||
include = ["src/**/*.py", "test/**/*.py"] | ||
|
||
[tool.ruff.lint] | ||
select = ["ALL"] | ||
# D203 and D213 are incompatible with D211 and D212 respectively. | ||
# COM812 and ISC001 can cause conflicts when using ruff as a formatter. | ||
# See https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules. | ||
ignore = ["D203", "D213", "COM812", "ISC001"] | ||
|
||
[tool.ruff.lint.per-file-ignores] | ||
"src/convert_attestations/_cli.py" = [ | ||
"T201", # allow `print` in cli module | ||
] | ||
"test/**/*.py" = [ | ||
"D", # no docstrings in tests | ||
"S101", # asserts are expected in tests | ||
] | ||
[tool.interrogate] | ||
# don't enforce documentation coverage for packaging, testing, the virtual | ||
# environment, or the CLI (which is documented separately). | ||
exclude = ["env", "test", "src/convert_attestations/_cli.py"] | ||
ignore-semiprivate = true | ||
fail-under = 100 | ||
|
||
[tool.uv] | ||
prerelease = "allow" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
"""The `convert-attestations` APIs.""" | ||
|
||
__version__ = "0.0.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
"""The `python -m convert-attestations` entrypoint.""" | ||
|
||
if __name__ == "__main__": # pragma: no cover | ||
from convert_attestations._cli import main | ||
|
||
main() |
Oops, something went wrong.