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

Configure project to use pyproject.toml and consistent CI and test tooling #544

Merged
merged 10 commits into from
Oct 16, 2024
Merged
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
16 changes: 0 additions & 16 deletions .github/workflows/black.yml

This file was deleted.

23 changes: 23 additions & 0 deletions .github/workflows/mypy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Mypy
on: workflow_dispatch

jobs:
mypy_py3:
name: Mypy check
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.9
cache: 'pip'
- name: Checkout
uses: actions/checkout@master
- name: Install Dependencies
run: |
pip install mypy
- name: mypy
run: |
make mypy
52 changes: 0 additions & 52 deletions .github/workflows/python-package.yml

This file was deleted.

12 changes: 10 additions & 2 deletions .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,24 @@ on:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
ruff_py3:
name: Ruff syntax check
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.9
cache: 'pip'
- name: Checkout
uses: actions/checkout@master
- name: Install Dependencies
run: |
pip install --user ruff
pip install ruff
- name: ruff
run: |
ruff check --output-format github .
make ruff
38 changes: 38 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Tests
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:
name: Run Python Tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10'] # , '3.11']

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install Python dependencies
run: |
make install
make test-requirements
- name: Test with pytest
run: |
set -o pipefail
make test-ci | tee pytest-coverage.txt

- name: Pytest coverage comment
continue-on-error: true # Workflows running on a fork can't post comments
uses: MishaKav/pytest-coverage-comment@main
if: github.event_name == 'pull_request'
with:
pytest-coverage-path: ./pytest-coverage.txt
junitxml-path: ./pytest.xml
34 changes: 25 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,23 +1,39 @@
PWD = $(shell pwd)

check:
flake8
autofix:
ruff format .
ruff check --fix .

check: ruff mypy

ruff:
ruff format --check .
ruff check -q .
black --check .
pytest -q

mypy:
mypy

test:
python3 -m pytest

test-ci:
python3 -m pytest -v

install:
python3 -m pip install --upgrade -e .

test-requirements:
python3 -m pip install --upgrade -r test-requirements.txt

clean:
rm -rf $(PWD)/build $(PWD)/dist $(PWD)/mvt.egg-info
rm -rf $(PWD)/build $(PWD)/dist $(PWD)/src/mvt.egg-info

dist:
python3 setup.py sdist bdist_wheel
python3 -m pip install --upgrade build
python3 -m build

upload:
python3 -m twine upload dist/*

test-upload:
python3 -m twine upload --repository testpypi dist/*

pylint:
pylint --rcfile=setup.cfg mvt
14 changes: 0 additions & 14 deletions dev/mvt-android

This file was deleted.

14 changes: 0 additions & 14 deletions dev/mvt-ios

This file was deleted.

102 changes: 102 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
[project]
name = "mvt"
dynamic = ["version"]
authors = [
{name = "Claudio Guarnieri", email = "[email protected]"}
]
maintainers = [
{name = "Etienne Maynier", email = "[email protected]"},
{name = "Donncha Ó Cearbhaill", email = "[email protected]"},
{name = "Rory Flynn", email = "[email protected]"}
]
description = "Mobile Verification Toolkit"
readme = "README.md"
keywords = ["security", "mobile", "forensics", "malware"]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Information Technology",
"Operating System :: OS Independent",
"Programming Language :: Python"
]
dependencies = [
"click >=8.1.3",
"rich >=12.6.0",
"tld >=0.12.6",
"requests >=2.28.1",
"simplejson >=3.17.6",
"packaging >=21.3",
"appdirs >=1.4.4",
"iOSbackup >=0.9.923",
"adb-shell[usb] >=0.4.3",
"libusb1 >=3.0.0",
"cryptography >=42.0.5",
"pyyaml >=6.0",
"pyahocorasick >= 2.0.0",
]
requires-python = ">= 3.8"

[project.urls]
homepage = "https://docs.mvt.re/en/latest/"
repository = "https://github.com/mvt-project/mvt"

[project.scripts]
mvt-ios = "mvt.ios:cli"
mvt-android = "mvt.android:cli"

[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"

[tool.coverage.run]
omit = [
"tests/*",
]

[tool.coverage.html]
directory= "htmlcov"

[tool.mypy]
install_types = true
non_interactive = true
ignore_missing_imports = true
packages = "src"

[tool.pytest.ini_options]
addopts = "-ra -q --cov=mvt --cov-report html --junitxml=pytest.xml --cov-report=term-missing:skip-covered"
testpaths = [
"tests"
]

[tool.ruff.lint]
select = ["C90", "E", "F", "W"] # flake8 default set
ignore = [
"E501", # don't enforce line length violations
"C901", # complex-structure

# These were previously ignored but don't seem to be required:
# "E265", # no-space-after-block-comment
# "F401", # unused-import
# "E127", # not included in ruff
# "W503", # not included in ruff
# "E226", # missing-whitespace-around-arithmetic-operator
# "E203", # whitespace-before-punctuation
]

[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F401"] # unused-import

[tool.ruff.lint.mccabe]
max-complexity = 10

[tool.setuptools]
include-package-data = true
package-dir = {"" = "src"}

[tool.setuptools.packages.find]
where = ["src"]

[tool.setuptools.package-data]
mvt = ["ios/data/*.json"]

[tool.setuptools.dynamic]
version = {attr = "mvt.common.version.MVT_VERSION"}
6 changes: 0 additions & 6 deletions ruff.toml

This file was deleted.

14 changes: 0 additions & 14 deletions scripts/lint.sh

This file was deleted.

Loading
Loading