mirror of
https://github.com/vee1e/mitmproxy.git
synced 2026-09-01 18:27:18 +00:00
switch to uv (#7662)
This commit is contained in:
parent
c281f76366
commit
f29f146ed1
11 changed files with 1991 additions and 232 deletions
55
.github/awscli-requirements.txt
vendored
55
.github/awscli-requirements.txt
vendored
|
|
@ -1,55 +0,0 @@
|
|||
# This file was autogenerated by uv via the following command:
|
||||
# uv export
|
||||
awscli==1.36.40 \
|
||||
--hash=sha256:971c3b150c06068bc26867fe295753547780f63fcf8256d41cd38760e44d46ca \
|
||||
--hash=sha256:e2a88f88dc16d5c0f26379afd6f254097e53e8b34c82164e59f4165db6ee6dfa
|
||||
botocore==1.35.99 \
|
||||
--hash=sha256:1eab44e969c39c5f3d9a3104a0836c24715579a455f12b3979a31d7cde51b3c3 \
|
||||
--hash=sha256:b22d27b6b617fc2d7342090d6129000af2efd20174215948c0d7ae2da0fab445
|
||||
colorama==0.4.6 \
|
||||
--hash=sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44 \
|
||||
--hash=sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6
|
||||
docutils==0.16 \
|
||||
--hash=sha256:0c5b78adfbf7762415433f5515cd5c9e762339e23369dbe8000d84a4bf4ab3af \
|
||||
--hash=sha256:c2de3a60e9e7d07be26b7f2b00ca0309c207e06c100f9cc2a94931fc75a478fc
|
||||
jmespath==1.0.1 \
|
||||
--hash=sha256:02e2e4cc71b5bcab88332eebf907519190dd9e6e82107fa7f83b1003a6252980 \
|
||||
--hash=sha256:90261b206d6defd58fdd5e85f478bf633a2901798906be2ad389150c5c60edbe
|
||||
pyasn1==0.6.1 \
|
||||
--hash=sha256:0d632f46f2ba09143da3a8afe9e33fb6f92fa2320ab7e886e2d0f7672af84629 \
|
||||
--hash=sha256:6f580d2bdd84365380830acf45550f2511469f673cb4a5ae3857a3170128b034
|
||||
python-dateutil==2.9.0.post0 \
|
||||
--hash=sha256:37dd54208da7e1cd875388217d5e00ebd4179249f90fb72437e91a35459a0ad3 \
|
||||
--hash=sha256:a8b2bc7bffae282281c8140a97d3aa9c14da0b136dfe83f850eea9a5f7470427
|
||||
pyyaml==6.0.2 \
|
||||
--hash=sha256:0833f8694549e586547b576dcfaba4a6b55b9e96098b36cdc7ebefe667dfed48 \
|
||||
--hash=sha256:0ffe8360bab4910ef1b9e87fb812d8bc0a308b0d0eef8c8f44e0254ab3b07133 \
|
||||
--hash=sha256:17e311b6c678207928d649faa7cb0d7b4c26a0ba73d41e99c4fff6b6c3276484 \
|
||||
--hash=sha256:1f71ea527786de97d1a0cc0eacd1defc0985dcf6b3f17bb77dcfc8c34bec4dc5 \
|
||||
--hash=sha256:41e4e3953a79407c794916fa277a82531dd93aad34e29c2a514c2c0c5fe971cc \
|
||||
--hash=sha256:50187695423ffe49e2deacb8cd10510bc361faac997de9efef88badc3bb9e2d1 \
|
||||
--hash=sha256:68ccc6023a3400877818152ad9a1033e3db8625d899c72eacb5a668902e4d652 \
|
||||
--hash=sha256:70b189594dbe54f75ab3a1acec5f1e3faa7e8cf2f1e08d9b561cb41b845f69d5 \
|
||||
--hash=sha256:7e7401d0de89a9a855c839bc697c079a4af81cf878373abd7dc625847d25cbd8 \
|
||||
--hash=sha256:80bab7bfc629882493af4aa31a4cfa43a4c57c83813253626916b8c7ada83476 \
|
||||
--hash=sha256:8388ee1976c416731879ac16da0aff3f63b286ffdd57cdeb95f3f2e085687563 \
|
||||
--hash=sha256:8b9c7197f7cb2738065c481a0461e50ad02f18c78cd75775628afb4d7137fb3b \
|
||||
--hash=sha256:9b22676e8097e9e22e36d6b7bda33190d0d400f345f23d4065d48f4ca7ae0425 \
|
||||
--hash=sha256:bc2fa7c6b47d6bc618dd7fb02ef6fdedb1090ec036abab80d4681424b84c1183 \
|
||||
--hash=sha256:c70c95198c015b85feafc136515252a261a84561b7b1d51e3384e0655ddf25ab \
|
||||
--hash=sha256:ce826d6ef20b1bc864f0a68340c8b3287705cae2f8b4b1d932177dcc76721725 \
|
||||
--hash=sha256:d584d9ec91ad65861cc08d42e834324ef890a082e591037abe114850ff7bbc3e \
|
||||
--hash=sha256:ef6107725bd54b262d6dedcc2af448a266975032bc85ef0172c5f059da6325b4 \
|
||||
--hash=sha256:efdca5630322a10774e8e98e1af481aad470dd62c3170801852d752aa7a783ba
|
||||
rsa==4.7.2 \
|
||||
--hash=sha256:78f9a9bf4e7be0c5ded4583326e7461e3a3c5aae24073648b4bdfa797d78c9d2 \
|
||||
--hash=sha256:9d689e6ca1b3038bc82bf8d23e944b6b6037bc02301a574935b2dd946e0353b9
|
||||
s3transfer==0.10.4 \
|
||||
--hash=sha256:244a76a24355363a68164241438de1b72f8781664920260c48465896b712a41e \
|
||||
--hash=sha256:29edc09801743c21eb5ecbc617a152df41d3c287f67b615f73e5f750583666a7
|
||||
six==1.17.0 \
|
||||
--hash=sha256:4721f391ed90541fddacab5acf947aa0d3dc7d27b2e1e8eda2be8970586c3274 \
|
||||
--hash=sha256:ff70335d468e7eb6ec65b95b99d3a2836546063f63acc5171de367e834932a81
|
||||
urllib3==2.3.0 \
|
||||
--hash=sha256:1cee9ad369867bfdbbb48b7dd50374c0967a0bb7710050facf0dd6911440e3df \
|
||||
--hash=sha256:f8c5449b3cf0861679ce7e0503c7b44b5ec981bec0d1d3795a07f1ba96f0204d
|
||||
6
.github/workflows/autofix.yml
vendored
6
.github/workflows/autofix.yml
vendored
|
|
@ -13,10 +13,10 @@ jobs:
|
|||
autofix:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: mhils/workflows/checkout@84f586083d4f70fef0b1f18ff2dced74004b40df
|
||||
- uses: mhils/workflows/setup-python@84f586083d4f70fef0b1f18ff2dced74004b40df
|
||||
- uses: mhils/workflows/checkout@0880de3f0d9875bfccf8ddd50c6c991d709bc812
|
||||
- uses: mhils/workflows/setup-uv@0880de3f0d9875bfccf8ddd50c6c991d709bc812
|
||||
- uses: mhils/workflows/uv-sync@0880de3f0d9875bfccf8ddd50c6c991d709bc812
|
||||
|
||||
- run: pip install -e .[dev]
|
||||
- run: ruff check --fix-only .
|
||||
- run: ruff format .
|
||||
|
||||
|
|
|
|||
119
.github/workflows/main.yml
vendored
119
.github/workflows/main.yml
vendored
|
|
@ -18,25 +18,20 @@ concurrency:
|
|||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
uses: mhils/workflows/.github/workflows/python-tox.yml@84f586083d4f70fef0b1f18ff2dced74004b40df
|
||||
with:
|
||||
cmd: tox -e lint
|
||||
tox:
|
||||
strategy:
|
||||
matrix:
|
||||
env: [lint, filename_matching, mypy, individual_coverage, old-dependencies, test-offline]
|
||||
name: ${{ matrix.env }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: mhils/workflows/checkout@0880de3f0d9875bfccf8ddd50c6c991d709bc812
|
||||
- uses: mhils/workflows/setup-uv@0880de3f0d9875bfccf8ddd50c6c991d709bc812
|
||||
- uses: mhils/workflows/uv-sync@0880de3f0d9875bfccf8ddd50c6c991d709bc812
|
||||
with:
|
||||
args: --only-group tox
|
||||
|
||||
filename-matching:
|
||||
uses: mhils/workflows/.github/workflows/python-tox.yml@84f586083d4f70fef0b1f18ff2dced74004b40df
|
||||
with:
|
||||
cmd: tox -e filename_matching
|
||||
|
||||
mypy:
|
||||
uses: mhils/workflows/.github/workflows/python-tox.yml@84f586083d4f70fef0b1f18ff2dced74004b40df
|
||||
with:
|
||||
cmd: tox -e mypy
|
||||
|
||||
individual-coverage:
|
||||
uses: mhils/workflows/.github/workflows/python-tox.yml@84f586083d4f70fef0b1f18ff2dced74004b40df
|
||||
with:
|
||||
cmd: tox -e individual_coverage
|
||||
- run: tox -e ${{ matrix.env }}
|
||||
|
||||
test:
|
||||
strategy:
|
||||
|
|
@ -53,33 +48,18 @@ jobs:
|
|||
py: "3.12"
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: mhils/workflows/checkout@84f586083d4f70fef0b1f18ff2dced74004b40df
|
||||
- uses: mhils/workflows/setup-python@84f586083d4f70fef0b1f18ff2dced74004b40df
|
||||
- uses: mhils/workflows/checkout@0880de3f0d9875bfccf8ddd50c6c991d709bc812
|
||||
- uses: mhils/workflows/setup-uv@0880de3f0d9875bfccf8ddd50c6c991d709bc812
|
||||
- uses: mhils/workflows/uv-sync@0880de3f0d9875bfccf8ddd50c6c991d709bc812
|
||||
with:
|
||||
python-version: ${{ matrix.py }}
|
||||
- run: pip install tox
|
||||
- run: tox -e py
|
||||
if: matrix.os != 'ubuntu-latest'
|
||||
- name: Run tox -e py (without internet)
|
||||
run: |
|
||||
# install dependencies (requires internet connectivity)
|
||||
tox -e py --notest
|
||||
# run tests with loopback only. We need to sudo for unshare, which means we need an absolute path for tox.
|
||||
sudo unshare --net -- sh -c "ip link set lo up; $(which tox) -e py"
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
args: --only-group tox
|
||||
|
||||
- run: tox -e py${{ matrix.py }}
|
||||
- uses: codecov/codecov-action@v5
|
||||
with:
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
files: ./coverage.xml
|
||||
|
||||
test-old-dependencies:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: mhils/workflows/checkout@84f586083d4f70fef0b1f18ff2dced74004b40df
|
||||
- uses: mhils/workflows/setup-python@84f586083d4f70fef0b1f18ff2dced74004b40df
|
||||
- run: pip install tox-uv
|
||||
- run: tox -e old-dependencies
|
||||
|
||||
build:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
|
|
@ -91,15 +71,24 @@ jobs:
|
|||
platform: macos-x86_64
|
||||
- image: windows-2019
|
||||
platform: windows
|
||||
- image: ubuntu-20.04 # Oldest available version so we get oldest glibc possible.
|
||||
- image: ubuntu-latest
|
||||
platform: linux-x86_64
|
||||
- image: ubuntu-22.04-arm # Oldest available version so we get oldest glibc possible.
|
||||
container: debian:11 # Old version so we get oldest glibc possible.
|
||||
- image: ubuntu-24.04-arm
|
||||
platform: linux-arm64
|
||||
container: debian:11 # Old version so we get oldest glibc possible.
|
||||
runs-on: ${{ matrix.image }}
|
||||
container:
|
||||
image: ${{ matrix.container }}
|
||||
steps:
|
||||
- uses: mhils/workflows/checkout@84f586083d4f70fef0b1f18ff2dced74004b40df
|
||||
- uses: mhils/workflows/setup-python@84f586083d4f70fef0b1f18ff2dced74004b40df
|
||||
- run: pip install .[dev] # pyinstaller 5.9 does not like pyproject.toml + editable installs.
|
||||
- if: matrix.container
|
||||
run: |
|
||||
apt-get update
|
||||
apt-get install --no-install-recommends -y git ca-certificates binutils
|
||||
- uses: mhils/workflows/checkout@0880de3f0d9875bfccf8ddd50c6c991d709bc812
|
||||
- uses: mhils/workflows/setup-uv@0880de3f0d9875bfccf8ddd50c6c991d709bc812
|
||||
- uses: mhils/workflows/uv-sync@0880de3f0d9875bfccf8ddd50c6c991d709bc812
|
||||
- run: uv pip install . # pyinstaller 5.9 does not like pyproject.toml + editable installs.
|
||||
|
||||
- if: runner.os == 'macOS' && github.repository == 'mitmproxy/mitmproxy'
|
||||
&& (startsWith(github.ref, 'refs/heads/') || startsWith(github.ref, 'refs/tags/'))
|
||||
|
|
@ -132,9 +121,8 @@ jobs:
|
|||
path: release/dist
|
||||
|
||||
build-wheel:
|
||||
uses: mhils/workflows/.github/workflows/python-build.yml@84f586083d4f70fef0b1f18ff2dced74004b40df
|
||||
uses: mhils/workflows/.github/workflows/python-build.yml@0880de3f0d9875bfccf8ddd50c6c991d709bc812
|
||||
with:
|
||||
python-version-file: .github/python-version.txt
|
||||
artifact: binaries.wheel
|
||||
|
||||
build-windows-installer:
|
||||
|
|
@ -145,10 +133,10 @@ jobs:
|
|||
startsWith(github.ref, 'refs/tags/')
|
||||
)
|
||||
steps:
|
||||
- uses: mhils/workflows/checkout@84f586083d4f70fef0b1f18ff2dced74004b40df
|
||||
- uses: mhils/workflows/setup-python@84f586083d4f70fef0b1f18ff2dced74004b40df
|
||||
|
||||
- run: pip install .[dev] # pyinstaller 5.9 does not like pyproject.toml + editable installs.
|
||||
- uses: mhils/workflows/checkout@0880de3f0d9875bfccf8ddd50c6c991d709bc812
|
||||
- uses: mhils/workflows/setup-uv@0880de3f0d9875bfccf8ddd50c6c991d709bc812
|
||||
- uses: mhils/workflows/uv-sync@0880de3f0d9875bfccf8ddd50c6c991d709bc812
|
||||
- run: uv pip install . # pyinstaller 5.9 does not like pyproject.toml + editable installs.
|
||||
- run: python -u release/build.py installbuilder-installer msix-installer
|
||||
env:
|
||||
CI_BUILD_KEY: ${{ secrets.CI_BUILD_KEY }}
|
||||
|
|
@ -161,7 +149,7 @@ jobs:
|
|||
test-web-ui:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: mhils/workflows/checkout@84f586083d4f70fef0b1f18ff2dced74004b40df
|
||||
- uses: mhils/workflows/checkout@0880de3f0d9875bfccf8ddd50c6c991d709bc812
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version-file: .github/node-version.txt
|
||||
|
|
@ -187,7 +175,7 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
needs: build-wheel
|
||||
steps:
|
||||
- uses: mhils/workflows/checkout@84f586083d4f70fef0b1f18ff2dced74004b40df
|
||||
- uses: mhils/workflows/checkout@0880de3f0d9875bfccf8ddd50c6c991d709bc812
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: binaries.wheel
|
||||
|
|
@ -200,13 +188,14 @@ jobs:
|
|||
docs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: mhils/workflows/checkout@84f586083d4f70fef0b1f18ff2dced74004b40df
|
||||
- uses: mhils/workflows/setup-python@84f586083d4f70fef0b1f18ff2dced74004b40df
|
||||
- uses: mhils/workflows/checkout@0880de3f0d9875bfccf8ddd50c6c991d709bc812
|
||||
- uses: mhils/workflows/setup-uv@0880de3f0d9875bfccf8ddd50c6c991d709bc812
|
||||
- uses: mhils/workflows/uv-sync@0880de3f0d9875bfccf8ddd50c6c991d709bc812
|
||||
- run: |
|
||||
wget -q https://github.com/gohugoio/hugo/releases/download/v0.139.3/hugo_extended_0.139.3_linux-amd64.deb
|
||||
echo "3e58800d1fee57269208d07d104ae1a6ab886615344099f2dca0c6ad5279bc11 hugo_extended_0.139.3_linux-amd64.deb" | sha256sum -c
|
||||
sudo dpkg -i hugo*.deb
|
||||
- run: pip install -e .[dev]
|
||||
|
||||
- run: ./docs/build.py
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
|
|
@ -225,19 +214,15 @@ jobs:
|
|||
check:
|
||||
if: always()
|
||||
needs:
|
||||
- lint
|
||||
- filename-matching
|
||||
- mypy
|
||||
- individual-coverage
|
||||
- tox
|
||||
- test
|
||||
- test-docker
|
||||
- test-old-dependencies
|
||||
- test-web-ui
|
||||
- build
|
||||
- build-wheel
|
||||
- build-windows-installer
|
||||
- docs
|
||||
uses: mhils/workflows/.github/workflows/alls-green.yml@84f586083d4f70fef0b1f18ff2dced74004b40df
|
||||
uses: mhils/workflows/.github/workflows/alls-green.yml@0880de3f0d9875bfccf8ddd50c6c991d709bc812
|
||||
with:
|
||||
jobs: ${{ toJSON(needs) }}
|
||||
allowed-skips: build-windows-installer
|
||||
|
|
@ -257,7 +242,7 @@ jobs:
|
|||
needs: check
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: mhils/workflows/checkout@84f586083d4f70fef0b1f18ff2dced74004b40df
|
||||
- uses: mhils/workflows/checkout@0880de3f0d9875bfccf8ddd50c6c991d709bc812
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: binaries.wheel
|
||||
|
|
@ -335,11 +320,11 @@ jobs:
|
|||
R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
|
||||
R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
|
||||
steps:
|
||||
- uses: mhils/workflows/checkout@84f586083d4f70fef0b1f18ff2dced74004b40df
|
||||
- uses: mhils/workflows/setup-python@84f586083d4f70fef0b1f18ff2dced74004b40df
|
||||
- run: pip install -r .github/awscli-requirements.txt
|
||||
- if: startsWith(github.ref, 'refs/tags/')
|
||||
run: sudo apt-get install -y twine
|
||||
- uses: mhils/workflows/checkout@0880de3f0d9875bfccf8ddd50c6c991d709bc812
|
||||
- uses: mhils/workflows/setup-uv@0880de3f0d9875bfccf8ddd50c6c991d709bc812
|
||||
- uses: mhils/workflows/uv-sync@0880de3f0d9875bfccf8ddd50c6c991d709bc812
|
||||
with:
|
||||
args: --only-group deploy
|
||||
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
|
|
|
|||
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
|
|
@ -28,7 +28,7 @@ jobs:
|
|||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version-file: .github/node-version.txt
|
||||
- uses: mhils/workflows/setup-python@84f586083d4f70fef0b1f18ff2dced74004b40df
|
||||
- uses: mhils/workflows/setup-python@0880de3f0d9875bfccf8ddd50c6c991d709bc812
|
||||
- run: ./release/release.py ${{ inputs.version }} ${{ inputs.skip-branch-status-check }}
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # this token works with the GraphQL API
|
||||
|
|
|
|||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -28,7 +28,6 @@ bower_components
|
|||
*.map
|
||||
sslkeylogfile.log
|
||||
.tox/
|
||||
.python-version
|
||||
coverage.xml
|
||||
web/coverage/
|
||||
.mypy_cache/
|
||||
|
|
|
|||
|
|
@ -14,52 +14,33 @@ forward, please consider contributing in the following areas:
|
|||
|
||||
## Development Setup
|
||||
|
||||
To get started hacking on mitmproxy, please install the latest version of Python and do the following:
|
||||
To get started hacking on mitmproxy, please install the latest version of [uv] and do the following:
|
||||
|
||||
[uv]: https://docs.astral.sh/uv/
|
||||
|
||||
```shell
|
||||
git clone https://github.com/mitmproxy/mitmproxy.git
|
||||
cd mitmproxy
|
||||
uv run mitmproxy --version
|
||||
```
|
||||
|
||||
`uv run` will transparently create a virtual Python environment in `mitmproxy/.venv`,
|
||||
and install mitmproxy with all dependencies into it.
|
||||
|
||||
To run commands from the Python environment, you can either prefix them with `uv run`, or activate the virtualenv
|
||||
and then use the commands directly:
|
||||
|
||||
##### Linux / macOS
|
||||
|
||||
```shell
|
||||
# 1) Verify that these commands work:
|
||||
python3 --version
|
||||
python3 -m pip --help
|
||||
python3 -m venv --help
|
||||
# 2) Install:
|
||||
git clone https://github.com/mitmproxy/mitmproxy.git
|
||||
cd mitmproxy
|
||||
python3 -m venv venv
|
||||
venv/bin/pip install -e ".[dev]"
|
||||
```
|
||||
|
||||
##### Windows
|
||||
|
||||
```shell
|
||||
# 1) Verify that this command works:
|
||||
python --version
|
||||
# 2) Install:
|
||||
git clone https://github.com/mitmproxy/mitmproxy.git
|
||||
cd mitmproxy
|
||||
python -m venv venv
|
||||
venv\Scripts\pip install -e .[dev]
|
||||
```
|
||||
|
||||
This will clone mitmproxy's source code into a directory with the same name,
|
||||
and then create an isolated Python environment (a [virtualenv](https://virtualenv.pypa.io/)) into which all dependencies are installed.
|
||||
Mitmproxy itself is installed as "editable", so any changes to the source in the repository will be reflected live in the virtualenv.
|
||||
|
||||
The main executables for the project – `mitmdump`, `mitmproxy`, and `mitmweb` – are all created within the virtualenv.
|
||||
After activating the virtualenv, they will be on your $PATH, and you can run them like any other command:
|
||||
|
||||
##### Linux / macOS
|
||||
|
||||
```shell
|
||||
source venv/bin/activate
|
||||
source .venv/bin/activate
|
||||
mitmdump --version
|
||||
```
|
||||
|
||||
##### Windows
|
||||
|
||||
```shell
|
||||
venv\Scripts\activate
|
||||
.venv\Scripts\activate
|
||||
mitmdump --version
|
||||
```
|
||||
|
||||
|
|
@ -69,20 +50,20 @@ If you've followed the procedure above, you already have all the development req
|
|||
basic test suite with [tox](https://tox.readthedocs.io/):
|
||||
|
||||
```shell
|
||||
tox -e py # runs Python tests
|
||||
uv run tox
|
||||
```
|
||||
|
||||
Our CI system has additional tox environments that are run on every pull request (see [tox.ini](./tox.ini)).
|
||||
|
||||
For speedier testing, you can also run [pytest](http://pytest.org/) directly on individual test files or folders:
|
||||
|
||||
```shell
|
||||
cd test/mitmproxy/addons
|
||||
pytest --cov mitmproxy.addons.anticache --cov-report term-missing --looponfail test_anticache.py
|
||||
uv run pytest --cov mitmproxy.addons.anticache --cov-report term-missing --looponfail test_anticache.py
|
||||
```
|
||||
|
||||
Please ensure that all patches are accompanied by matching changes in the test suite. The project tries to maintain 100%
|
||||
test coverage and enforces this strictly for some parts of the codebase.
|
||||
Our CI system has additional tox environments that are run on every pull request (see [pyproject.toml](./pyproject.toml)).
|
||||
|
||||
|
||||
### Code Style
|
||||
|
||||
|
|
@ -91,7 +72,7 @@ Keeping to a consistent code style throughout the project makes it easier to con
|
|||
We enforce the following check for all PRs:
|
||||
|
||||
```shell
|
||||
tox -e lint
|
||||
uv run tox -e lint
|
||||
```
|
||||
|
||||
If a linting error is detected, the automated pull request checks will fail and block merging.
|
||||
|
|
|
|||
123
pyproject.toml
123
pyproject.toml
|
|
@ -58,30 +58,38 @@ dependencies = [
|
|||
"zstandard>=0.15,<=0.23.0",
|
||||
]
|
||||
|
||||
[project.optional-dependencies]
|
||||
[dependency-groups]
|
||||
dev = [
|
||||
"click>=7.0,<=8.1.8",
|
||||
"hypothesis>=6.104.2,<=6.130.6",
|
||||
"pdoc>=14.5.1,<=15.0.1",
|
||||
"click==8.1.8",
|
||||
"hypothesis==6.130.6",
|
||||
"pdoc==15.0.1",
|
||||
"pyinstaller==6.12.0",
|
||||
"pyinstaller-hooks-contrib==2025.2",
|
||||
"pytest-asyncio>=0.23.6,<=0.26.0",
|
||||
"pytest-cov>=5.0.0,<=6.1.0",
|
||||
"pytest-timeout>=2.3.1,<=2.3.1",
|
||||
"pytest-xdist>=3.5.0,<=3.6.1",
|
||||
"pytest>=8.2.2,<=8.3.5",
|
||||
"requests>=2.9.1,<=2.32.3",
|
||||
"tox>=4.15.1,<=4.25.0",
|
||||
"wheel>=0.36.2,<=0.45.1",
|
||||
"build>=0.10.0,<=1.2.2.post1",
|
||||
"mypy>=1.10.1,<=1.15.0",
|
||||
"ruff>=0.5.0,<=0.11.2",
|
||||
"types-certifi>=2021.10.8.3,<=2021.10.8.3",
|
||||
"types-Flask>=1.1.6,<=1.1.6",
|
||||
"types-Werkzeug>=1.0.9,<=1.0.9",
|
||||
"types-requests>=2.32.0.20240622,<=2.32.0.20250328",
|
||||
"types-cryptography>=3.3.23.2,<=3.3.23.2",
|
||||
"types-pyOpenSSL>=23.3.0.0,<=24.1.0.20240722",
|
||||
"pytest-asyncio==0.26.0",
|
||||
"pytest-cov==6.1.0",
|
||||
"pytest-timeout==2.3.1",
|
||||
"pytest-xdist==3.6.1",
|
||||
"pytest==8.3.5",
|
||||
"requests==2.32.3",
|
||||
"wheel==0.45.1",
|
||||
"build==1.2.2.post1",
|
||||
"mypy==1.15.0",
|
||||
"ruff==0.11.2",
|
||||
"types-certifi==2021.10.8.3",
|
||||
"types-Flask==1.1.6",
|
||||
"types-Werkzeug==1.0.9",
|
||||
"types-requests==2.32.0.20250328",
|
||||
"types-cryptography==3.3.23.2",
|
||||
"types-pyOpenSSL==24.1.0.20240722",
|
||||
{include-group = "tox"},
|
||||
]
|
||||
deploy = [
|
||||
"awscli==1.38.34",
|
||||
"twine==6.1.0",
|
||||
]
|
||||
tox = [
|
||||
"tox==4.25.0",
|
||||
"tox-uv==1.25.0",
|
||||
]
|
||||
|
||||
[project.urls]
|
||||
|
|
@ -272,51 +280,40 @@ section-order = ["future", "standard-library", "third-party", "local-folder","fi
|
|||
no-lines-before = ["first-party"]
|
||||
known-first-party = ["test", "mitmproxy", "mitmproxy_rs"]
|
||||
|
||||
[tool.tox]
|
||||
legacy_tox_ini = """
|
||||
[tox]
|
||||
envlist = py, lint, mypy
|
||||
skipsdist = True
|
||||
toxworkdir={env:TOX_WORK_DIR:.tox}
|
||||
[tool.tox.env_run_base]
|
||||
runner = "uv-venv-lock-runner"
|
||||
package = "editable"
|
||||
dependency_groups = ["dev"]
|
||||
commands = [
|
||||
["mitmdump", "--version"],
|
||||
["pytest",
|
||||
"-vv",
|
||||
"--cov-report", "xml",
|
||||
"--continue-on-collection-errors",
|
||||
"--cov=mitmproxy",
|
||||
"--cov=release",
|
||||
{ replace = "posargs", default = ["--timeout", "60"], extend = true }
|
||||
],
|
||||
]
|
||||
|
||||
[testenv]
|
||||
deps =
|
||||
-e .[dev]
|
||||
setenv = HOME = {envtmpdir}
|
||||
commands =
|
||||
mitmdump --version
|
||||
pytest --timeout 60 -vv \
|
||||
--cov-report xml \
|
||||
--continue-on-collection-errors \
|
||||
--cov=mitmproxy --cov=release \
|
||||
{posargs}
|
||||
[tool.tox.env.test-offline]
|
||||
commands = [["bash", "test/run-tests-offline.sh"]]
|
||||
allowlist_externals = ["bash"]
|
||||
|
||||
[testenv:old-dependencies]
|
||||
uv_resolution = lowest-direct
|
||||
[tool.tox.env.lint]
|
||||
commands = [["ruff", "check", "."]]
|
||||
package = "skip"
|
||||
|
||||
[testenv:lint]
|
||||
commands =
|
||||
ruff check .
|
||||
[tool.tox.env.filename_matching]
|
||||
commands = [["python", "./test/filename_matching.py"]]
|
||||
package = "skip"
|
||||
|
||||
[testenv:filename_matching]
|
||||
deps =
|
||||
commands =
|
||||
python ./test/filename_matching.py
|
||||
[tool.tox.env.mypy]
|
||||
commands = [["mypy"]]
|
||||
|
||||
[testenv:mypy]
|
||||
commands =
|
||||
mypy {posargs}
|
||||
[tool.tox.env.individual_coverage]
|
||||
commands = [["python", { default = ["./test/individual_coverage.py"], replace = "posargs", extend = true }]]
|
||||
|
||||
[testenv:individual_coverage]
|
||||
commands =
|
||||
python ./test/individual_coverage.py {posargs}
|
||||
|
||||
[testenv:wheeltest]
|
||||
recreate = True
|
||||
deps =
|
||||
commands =
|
||||
pip install {posargs}
|
||||
mitmproxy --version
|
||||
mitmdump --version
|
||||
mitmweb --version
|
||||
"""
|
||||
[tool.tox.env.old-dependencies]
|
||||
uv_resolution = "lowest-direct"
|
||||
runner = "uv-venv-runner"
|
||||
|
|
|
|||
|
|
@ -58,7 +58,6 @@ def wheel():
|
|||
ver = "*"
|
||||
(whl,) = DIST_DIR.glob(f"mitmproxy-{ver}-py3-none-any.whl")
|
||||
print(f"Found wheel package: {whl}")
|
||||
subprocess.check_call(["tox", "-e", "wheeltest", "--", whl])
|
||||
|
||||
|
||||
class ZipFile2(zipfile.ZipFile):
|
||||
|
|
|
|||
3
test/run-tests-offline.sh
Executable file
3
test/run-tests-offline.sh
Executable file
|
|
@ -0,0 +1,3 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
sudo unshare --net -- sh -c "ip link set lo up; $(which pytest)"
|
||||
Loading…
Add table
Add a link
Reference in a new issue