diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index f28ee36..be215cb 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -3,17 +3,13 @@ name: CI on: [pull_request] jobs: - tests: + linux-tests: strategy: matrix: toolchain: - nightly - 1.43 - os: - - ubuntu-latest - - macOS-latest - - windows-latest - runs-on: ${{ matrix.os }} + runs-on: ubuntu-latest steps: - name: Checkout source code uses: actions/checkout@v2 @@ -23,34 +19,80 @@ jobs: toolchain: ${{ matrix.toolchain }} override: true profile: minimal - - name: Build on Rust ${{ matrix.toolchain }} default features - # We can't compile tor on windows, cross-compile only :) - if: matrix.os == 'windows-latest' - run: cargo build --verbose --color always - - name: Build on Rust ${{ matrix.toolchain }} all features - if: matrix.os != 'windows-latest' + # We need to download Tor for the tests. Notice that it's not + # needed if you don't run the tests + - name: Download Tor + run: sudo apt-get install -y tor + - name: Build on Rust ${{ matrix.toolchain }} run: cargo build --all-features --verbose --color always - - name: Test on Rust ${{ matrix.toolchain }} default features - # We can't compile tor on windows, cross-compile only :) - if: matrix.os == 'windows-latest' - run: cargo test --verbose --color always - - name: Test on Rust ${{ matrix.toolchain }} all features - if: matrix.os != 'windows-latest' + - name: Test on Rust ${{ matrix.toolchain }} run: cargo test --all-features --verbose --color always - name: Fuzz - if: matrix.os == 'ubuntu-latest' && matrix.toolchain == 'nightly' + if: matrix.toolchain == 'nightly' run: ./fuzz/run.sh - windows-tor-cross-compile: + macos-tests: + strategy: + matrix: + toolchain: + - nightly + - 1.43 + runs-on: macOS-latest + steps: + - name: Checkout source code + uses: actions/checkout@v2 + - name: Install Rust ${{ matrix.toolchain }} toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ matrix.toolchain }} + override: true + profile: minimal + # We need to download Tor for the tests. Notice that it's not + # needed if you don't run the tests + - name: Download deps + run: brew install tor autoconf automake + - name: Build on Rust ${{ matrix.toolchain }} + run: cargo build --all-features --verbose --color always + - name: Test on Rust ${{ matrix.toolchain }} + run: cargo test --all-features --verbose --color always + + windows-tests: strategy: matrix: - toolchain: - - nightly - - 1.43 + toolchain: + - nightly + - 1.43 + runs-on: windows-latest + steps: + - name: Checkout source code + uses: actions/checkout@v2 + - name: Install Rust ${{ matrix.toolchain }} toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ matrix.toolchain }} + override: true + profile: minimal + - name: Build on Rust ${{ matrix.toolchain }} + # We can't compile tor on windows, cross-compile only :) + run: cargo build --verbose --color always + - name: Test on Rust ${{ matrix.toolchain }} + # We can't compile tor on windows, cross-compile only :) + run: cargo test --verbose --color always + + # We only cross compile windows, without doing any test. + # In future we could download artifacts and make them run on CI as well, I guess? + windows-cross-compile-tor: + strategy: + matrix: + toolchain: + #- nightly + - 1.43 runs-on: ubuntu-latest steps: - name: Checkout source code uses: actions/checkout@v2 + - name: Install needed deps + run: sudo apt-get update && sudo apt-get install -y mingw-w64 tar - name: Install Rust ${{ matrix.toolchain }} toolchain uses: actions-rs/toolchain@v1 with: @@ -58,42 +100,14 @@ jobs: target: x86_64-pc-windows-gnu override: true profile: minimal - - name: Install MingW - run: sudo apt-get update && sudo apt-get install -y mingw-w64 - - name: Cross-compile for Windows - run: cargo build --all-features --verbose --color always --target x86_64-pc-windows-gnu - - # windows-tests: - # strategy: - # matrix: - # toolchain: - # #- nightly - # - 1.43 - # runs-on: windows-latest - # steps: - # - name: Checkout source code - # uses: actions/checkout@v2 - # - name: Install Tor - # run: choco install tor - # - name: Install Rust ${{ matrix.toolchain }} toolchain - # uses: actions-rs/toolchain@v1 - # with: - # toolchain: ${{ matrix.toolchain }} - # target: x86_64-pc-windows-gnu - # override: true - # profile: minimal - # - name: Debug - # run: rustup show - # # libsodium build.rs is broken: https://github.com/sodiumoxide/sodiumoxide/issues/377 - # - name: Fix libsodium compilation - # run: rustup default stable-gnu - # #rustup set default-host x86_64-pc-windows-gnu - # - name: Debug - # run: rustup show - # - name: Build on Rust ${{ matrix.toolchain }} - # run: cargo build -vv --color always --all-features - # - name: Test on Rust ${{ matrix.toolchain }} - # run: cargo test --all-features --verbose --color always + # libsodium build.rs is broken: https://github.com/sodiumoxide/sodiumoxide/issues/377 + # We need to manually download libsodium and give it to cargo while compiling + # Note that we could use the libsodium.a already provided in sodiumoxide, but it's tricky to find + # FIXME: we are not verifying sigs!! In CI who cares but don't forget to verify them in real life lol + - name: Download libsodium + run: wget https://download.libsodium.org/libsodium/releases/libsodium-1.0.18-mingw.tar.gz && tar xvf libsodium-1.0.18-mingw.tar.gz + - name: Build on Rust ${{ matrix.toolchain }} + run: SODIUM_LIB_DIR=$PWD/libsodium-win64/lib/ cargo build -vv --color always --all-features --target x86_64-pc-windows-gnu -j 1 rustfmt_check: runs-on: ubuntu-latest diff --git a/Cargo.toml b/Cargo.toml index 25ff807..30ddc6b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,3 +33,6 @@ log = "0.4" libtor = { version = "46.6", optional = true, features = ["vendored-openssl"] } [target.'cfg(not(target_os = "windows"))'.dependencies] libtor = { version = "46.6", optional = true } + +[patch.crates-io] +libtor-sys = { git = "https://github.com/afilini/libtor-sys", branch = "feat/link-binary-ci", optional = true }