Skip to content

Commit

Permalink
Move macOS binaries into separate package (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
mhils authored Aug 23, 2023
1 parent 7387ffe commit 8da0355
Show file tree
Hide file tree
Showing 59 changed files with 119 additions and 193 deletions.
12 changes: 0 additions & 12 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,3 @@ updates:
directory: "/"
schedule:
interval: "monthly"
- package-ecosystem: cargo
directory: "/ffi"
schedule:
interval: "monthly"
- package-ecosystem: cargo
directory: "/mitmproxy-windows/redirector"
schedule:
interval: "monthly"
- package-ecosystem: cargo
directory: "/wireguard-test-client"
schedule:
interval: "monthly"
4 changes: 3 additions & 1 deletion .github/scripts/build-macos-redirector.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -eou pipefail

if [ -n "${APPLE_ID+x}" ]; then
if [ -n "${APPLE_ID-}" ]; then
echo "Signing keys available, building signed binary..."

APPLE_TEAM_ID=S8XHQB96PW
Expand Down Expand Up @@ -53,4 +53,6 @@ if [ -n "${APPLE_ID+x}" ]; then
else
echo "Signing keys not available, building unsigned binary..."
xcodebuild -scheme macos-redirector CODE_SIGNING_ALLOWED="NO" build
mkdir dist
touch dist/dev-build
fi
12 changes: 2 additions & 10 deletions .github/workflows/autofix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- run: brew install swift-protobuf
- run: protoc --swift_out=./macos-redirector/ipc --proto_path=./src/packet_sources/ ipc.proto
- run: protoc --swift_out=./mitmproxy-macos/redirector/ipc --proto_path=./src/packet_sources/ ipc.proto
- uses: autofix-ci/action@8caa572fd27b0019a65e4c695447089c8d3138b9

rustfmt:
Expand All @@ -35,15 +35,7 @@ jobs:
args: --workspace --exclude windows-redirector --exclude macos-certificate-truster
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-autofix-${{ hashFiles('**/Cargo.lock') }}
- uses: Swatinem/rust-cache@e207df5d269b42b69c8bc5101da26f7d31feddb4 # v2.6.2

- run: rustup toolchain install ${{ env.rust_clippy }} --profile minimal --component rustfmt --component clippy
- run: rustup default ${{ env.rust_clippy }}
Expand Down
152 changes: 70 additions & 82 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,7 @@ jobs:
args: --exclude windows-redirector --exclude macos-certificate-truster
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- uses: Swatinem/rust-cache@e207df5d269b42b69c8bc5101da26f7d31feddb4 # v2.6.2
- name: Set up Rust toolchain
run: rustup toolchain install ${{ matrix.rust }} --profile minimal
- uses: actions/setup-python@v4
Expand All @@ -62,47 +54,62 @@ jobs:
command: test
args: --workspace --verbose ${{ matrix.args }}

build-windows:
runs-on: windows-latest
build:
strategy:
matrix:
include:
- os: windows-latest
- os: ubuntu-latest
args: --compatibility manylinux2014 --zig --sdist
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
args: --compatibility manylinux2014 --zig --target aarch64-unknown-linux-gnu
- os: macos-latest
target: aarch64-apple-darwin
args: --target universal2-apple-darwin
runs-on: ${{ matrix.os }}
name: build-wheel (${{ matrix.os }}, ${{ matrix.target || 'x64' }})
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: windows-redirector-${{ hashFiles('**/Cargo.lock') }}
- uses: Swatinem/rust-cache@e207df5d269b42b69c8bc5101da26f7d31feddb4 # v2.6.2
- run: rustup toolchain install stable --profile minimal
- run: rustup default stable
- if: matrix.target
run: rustup target add ${{ matrix.target }}
- run: rustup show
- uses: actions/setup-python@v4
with:
python-version-file: .github/python-version.txt
- name: Install build from PyPI
uses: install-pinned/build@11bbf2deeb1a44228c45910f3b57e346927960b4

- run: cargo build --release --package windows-redirector
- run: python -m build --wheel mitmproxy-windows --outdir target/wheels/
- name: Install maturin[zig] from PyPI
uses: install-pinned/maturin-with-zig@930de5c8284dfb26f11fd30a35a0df4c15ee4f8b

- if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
run: |
VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r .packages[0].version)
sed -i "s/mitmproxy_windows/mitmproxy_windows==$VERSION/g" mitmproxy-rs/pyproject.toml
sed -i "s/mitmproxy_macos/mitmproxy_macos==$VERSION/g" mitmproxy-rs/pyproject.toml
- run: maturin build --release ${{ matrix.args }}
working-directory: ./mitmproxy-rs

- uses: actions/upload-artifact@v3
with:
name: wheels
path: target/wheels

build-macos:
build-macos-app:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
id: cache-app
with:
path: macos-redirector/dist/
key: macos-${{ hashFiles('macos-redirector/**', '.github/scripts/build-macos-redirector.sh') }}
path: mitmproxy-macos/redirector/dist/
key: macos-${{ hashFiles('mitmproxy-macos/redirector/**', '.github/scripts/build-macos-redirector.sh') }}
- if: steps.cache-app.outputs.cache-hit != 'true'
run: ../.github/scripts/build-macos-redirector.sh
working-directory: macos-redirector
run: $GITHUB_WORKSPACE/.github/scripts/build-macos-redirector.sh
working-directory: mitmproxy-macos/redirector
env:
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_APP_PASSWORD: ${{ secrets.APPLE_APP_PASSWORD }}
Expand All @@ -113,83 +120,64 @@ jobs:
- uses: actions/upload-artifact@v3
with:
name: macos-app
path: macos-redirector/dist/
path: mitmproxy-macos/redirector/dist/

build:
needs: build-macos
build-os-wheels:
needs: build-macos-app
strategy:
matrix:
include:
- os: windows-latest
- os: ubuntu-latest
args: --compatibility manylinux2014 --zig --sdist
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
args: --compatibility manylinux2014 --zig --target aarch64-unknown-linux-gnu
- os: macos-latest
target: aarch64-apple-darwin
args: --target universal2-apple-darwin
runs-on: ${{ matrix.os }}
name: build-wheel (${{ matrix.os }}, ${{ matrix.target || 'x64' }})
- os: windows
build-rust: --package windows-redirector
- os: macos
build-rust: --package macos-certificate-truster
runs-on: ${{ matrix.os }}-latest
name: build mitmproxy-${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

# Build Rust
- uses: Swatinem/rust-cache@e207df5d269b42b69c8bc5101da26f7d31feddb4 # v2.6.2
- run: rustup toolchain install stable --profile minimal
- run: rustup default stable
- if: matrix.target
run: rustup target add ${{ matrix.target }}
- run: rustup show
- uses: actions/setup-python@v4
with:
python-version-file: .github/python-version.txt

- name: Install maturin[zig] from PyPI
uses: install-pinned/maturin-with-zig@930de5c8284dfb26f11fd30a35a0df4c15ee4f8b

- if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
run: |
VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r .packages[0].version)
sed -i "s/mitmproxy_windows/mitmproxy_windows==$VERSION/g" ffi/pyproject.toml
- run: cargo build --release ${{ matrix.build-rust }}

- if: runner.os == 'macOS'
run: cargo build --release --package macos-certificate-truster
# Download macOS app
- if: runner.os == 'macOS'
uses: actions/download-artifact@v3
with:
name: macos-app
path: macos-redirector/dist/

- run: maturin build --release ${{ matrix.args }}
working-directory: ./ffi
path: mitmproxy-macos/redirector/dist/

# Build & upload wheel
- uses: actions/setup-python@v4
with:
python-version-file: .github/python-version.txt
- name: Install build from PyPI
uses: install-pinned/build@3f4552ef2aab2ffefe2461e1cb506609d0dbf07a
- run: python -m build --wheel ./mitmproxy-${{ matrix.os }} --outdir target/wheels/
- uses: actions/upload-artifact@v3
with:
name: wheels
path: target/wheels
deploy:
uses: mhils/workflows/.github/workflows/python-deploy.yml@main
needs: [test, build]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
with:
artifact: wheels
# repository: testpypi
# environment: deploy-testpypi
secrets:
password: ${{ secrets.PYPI_TOKEN }}

check:
if: always()
needs:
- test
- build
- build-os-wheels
uses: mhils/workflows/.github/workflows/alls-green.yml@main
with:
jobs: ${{ toJSON(needs) }}

deploy:
uses: mhils/workflows/.github/workflows/python-deploy.yml@main
needs: check
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
with:
artifact: wheels
# repository: testpypi
# environment: deploy-testpypi
secrets:
password: ${{ secrets.PYPI_TOKEN }}
14 changes: 3 additions & 11 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- uses: Swatinem/rust-cache@e207df5d269b42b69c8bc5101da26f7d31feddb4 # v2.6.2

- name: Install maturin[zig] from PyPI
uses: install-pinned/maturin-with-zig@930de5c8284dfb26f11fd30a35a0df4c15ee4f8b
Expand All @@ -38,10 +30,10 @@ jobs:
uses: install-pinned/pdoc@9c418cd240bd030d158f48187a6aa9946439b51e

- run: maturin build
working-directory: ./ffi
working-directory: ./mitmproxy-rs
- run: pip install --no-index --find-links target/wheels/ mitmproxy_rs

- run: stubtest --allowlist ffi/stubtest-allowlist.txt --mypy-config-file ffi/pyproject.toml mitmproxy_rs
- run: stubtest --allowlist mitmproxy-rs/stubtest-allowlist.txt --mypy-config-file mitmproxy-rs/pyproject.toml mitmproxy_rs

- run: pdoc -o docs/ mitmproxy_rs

Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ virtualenv activated and run the following:
pip install maturin
git clone https://github.com/mitmproxy/mitmproxy_rs.git

cd mitmproxy_rs/ffi
cd mitmproxy_rs/mitmproxy-rs
maturin develop
```

Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[workspace]
members = [
".",
"ffi",
"mitmproxy-rs",
"mitmproxy-windows/redirector",
"wireguard-test-client",
"macos-certificate-truster",
"mitmproxy-macos/certificate-truster",
]

[workspace.package]
Expand Down
66 changes: 0 additions & 66 deletions ffi/build.rs

This file was deleted.

Loading

0 comments on commit 8da0355

Please sign in to comment.