From 789e6a8a4689ca0d098ae2a87f81a86248f30187 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Wed, 24 Feb 2021 09:48:41 +0000 Subject: [PATCH] update ci (#284) --- .github/workflows/ci.yml | 103 ++++++++++++++++++++++++++++ .github/workflows/clippy-fmt.yml | 28 +++++--- .github/workflows/linux.yml | 82 ---------------------- .github/workflows/macos.yml | 43 ------------ .github/workflows/upload-doc.yml | 35 ++++++++++ .github/workflows/windows-mingw.yml | 45 ------------ .github/workflows/windows.yml | 69 ------------------- actix-router/src/resource.rs | 7 +- actix-tls/Cargo.toml | 8 ++- actix-tls/tests/test_connect.rs | 4 +- actix-tls/tests/test_resolvers.rs | 2 + 11 files changed, 172 insertions(+), 254 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/linux.yml delete mode 100644 .github/workflows/macos.yml create mode 100644 .github/workflows/upload-doc.yml delete mode 100644 .github/workflows/windows-mingw.yml delete mode 100644 .github/workflows/windows.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..3945573e --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,103 @@ +name: CI + +on: + pull_request: + types: [opened, synchronize, reopened] + push: + branches: [master] + +jobs: + build_and_test: + strategy: + fail-fast: false + matrix: + target: + - { name: Linux, os: ubuntu-latest, triple: x86_64-unknown-linux-gnu } + - { name: macOS, os: macos-latest, triple: x86_64-apple-darwin } + - { name: Windows, os: windows-latest, triple: x86_64-pc-windows-msvc } + - { name: Windows (MinGW), os: windows-latest, triple: x86_64-pc-windows-gnu } + - { name: Windows (32-bit), os: windows-latest, triple: i686-pc-windows-msvc } + version: + - 1.46.0 # MSRV + - stable + - nightly + + name: ${{ matrix.target.name }} / ${{ matrix.version }} + runs-on: ${{ matrix.target.os }} + + steps: + - name: Setup Routing + if: matrix.target.os == 'macos-latest' + run: sudo ifconfig lo0 alias 127.0.0.3 + + - uses: actions/checkout@v2 + + - name: Install ${{ matrix.version }} + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ matrix.version }}-${{ matrix.target.triple }} + profile: minimal + override: true + + - name: Install MSYS2 + if: matrix.target.triple == 'x86_64-pc-windows-gnu' + uses: msys2/setup-msys2@v2 + - name: Install MinGW Packages + if: matrix.target.triple == 'x86_64-pc-windows-gnu' + run: | + msys2 -c 'pacman -Sy --noconfirm pacman' + msys2 -c 'pacman --noconfirm -S base-devel pkg-config' + + - name: Generate Cargo.lock + uses: actions-rs/cargo@v1 + with: + command: generate-lockfile + - name: Cache Dependencies + uses: Swatinem/rust-cache@v1.2.0 + + - name: Install cargo-hack + uses: actions-rs/cargo@v1 + with: + command: install + args: cargo-hack + + - name: check minimal + uses: actions-rs/cargo@v1 + with: + command: hack + args: --clean-per-run check --workspace --no-default-features --tests + + - name: check full + uses: actions-rs/cargo@v1 + with: + command: check + args: --workspace --bins --examples --tests + + - name: tests + if: matrix.target.triple != 'x86_64-pc-windows-gnu' + uses: actions-rs/cargo@v1 + with: + command: test + args: --workspace --all-features --no-fail-fast -- --nocapture + + - name: Generate coverage file + if: > + matrix.target.os == 'ubuntu-latest' + && matrix.version == 'stable' + && github.ref == 'refs/heads/master' + run: | + cargo install cargo-tarpaulin + cargo tarpaulin --out Xml --verbose + - name: Upload to Codecov + if: > + matrix.target.os == 'ubuntu-latest' + && matrix.version == 'stable' + && github.ref == 'refs/heads/master' + uses: codecov/codecov-action@v1 + with: + file: cobertura.xml + + - name: Clear the cargo caches + run: | + cargo install cargo-cache --no-default-features --features ci-autoclean + cargo-cache diff --git a/.github/workflows/clippy-fmt.yml b/.github/workflows/clippy-fmt.yml index 12343dd4..3bef81db 100644 --- a/.github/workflows/clippy-fmt.yml +++ b/.github/workflows/clippy-fmt.yml @@ -1,34 +1,42 @@ +name: Lint + on: pull_request: types: [opened, synchronize, reopened] -name: Clippy and rustfmt Check jobs: - clippy_check: + fmt: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 + - name: Install Rust + uses: actions-rs/toolchain@v1 with: toolchain: stable - components: rustfmt profile: minimal + components: rustfmt override: true - - name: Check with rustfmt + - name: Rustfmt Check uses: actions-rs/cargo@v1 with: command: fmt args: --all -- --check - - uses: actions-rs/toolchain@v1 + clippy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Install Rust + uses: actions-rs/toolchain@v1 with: - toolchain: nightly - components: clippy + toolchain: stable profile: minimal + components: clippy override: true - - name: Check with Clippy + - name: Clippy Check uses: actions-rs/clippy-check@v1 with: token: ${{ secrets.GITHUB_TOKEN }} - args: --workspace --tests + args: --workspace --tests --all-features diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml deleted file mode 100644 index 8ea7823d..00000000 --- a/.github/workflows/linux.yml +++ /dev/null @@ -1,82 +0,0 @@ -name: CI (Linux) - -on: - pull_request: - types: [opened, synchronize, reopened] - push: - branches: - - master - - '1.0' - -jobs: - build_and_test: - strategy: - fail-fast: false - matrix: - version: - - 1.46.0 - - stable - - nightly - - name: ${{ matrix.version }} - x86_64-unknown-linux-gnu - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - - name: Install ${{ matrix.version }} - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{ matrix.version }}-x86_64-unknown-linux-gnu - profile: minimal - override: true - - - name: Generate Cargo.lock - uses: actions-rs/cargo@v1 - with: - command: generate-lockfile - - name: Cache cargo dirs - uses: actions/cache@v2 - with: - path: - ~/.cargo/registry - ~/.cargo/git - ~/.cargo/bin - key: ${{ matrix.version }}-x86_64-unknown-linux-gnu-cargo-trimmed-${{ hashFiles('**/Cargo.lock') }} - - name: Cache cargo build - uses: actions/cache@v2 - with: - path: target - key: ${{ matrix.version }}-x86_64-unknown-linux-gnu-cargo-build-trimmed-${{ hashFiles('**/Cargo.lock') }} - - - name: check build - uses: actions-rs/cargo@v1 - with: - command: check - args: --workspace --bins --examples --tests - - - name: tests - uses: actions-rs/cargo@v1 - timeout-minutes: 40 - with: - command: test - args: --workspace --exclude=actix-tls --no-fail-fast -- --nocapture - - - name: Generate coverage file - if: matrix.version == 'stable' && (github.ref == 'refs/heads/master' || github.event_name == 'pull_request') - run: | - cargo install cargo-tarpaulin - cargo tarpaulin --out Xml --workspace - - - name: Upload to Codecov - if: matrix.version == 'stable' && (github.ref == 'refs/heads/master' || github.event_name == 'pull_request') - uses: codecov/codecov-action@v1 - with: - file: cobertura.xml - - - name: Clear the cargo caches - run: | - rustup update stable - rustup override set stable - cargo install cargo-cache --no-default-features --features ci-autoclean - cargo-cache diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml deleted file mode 100644 index b2555bd3..00000000 --- a/.github/workflows/macos.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: CI (macOS) - -on: - pull_request: - types: [opened, synchronize, reopened] - push: - branches: - - master - - '1.0' - -jobs: - build_and_test: - strategy: - fail-fast: false - matrix: - version: - - stable - - nightly - - name: ${{ matrix.version }} - x86_64-apple-darwin - runs-on: macos-latest - - steps: - - uses: actions/checkout@v2 - - - name: Install ${{ matrix.version }} - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{ matrix.version }}-x86_64-apple-darwin - profile: minimal - override: true - - - name: check build - uses: actions-rs/cargo@v1 - with: - command: check - args: --workspace --bins --examples --tests - - - name: tests - uses: actions-rs/cargo@v1 - with: - command: test - args: --workspace --exclude=actix-tls --no-fail-fast -- --nocapture diff --git a/.github/workflows/upload-doc.yml b/.github/workflows/upload-doc.yml new file mode 100644 index 00000000..36044230 --- /dev/null +++ b/.github/workflows/upload-doc.yml @@ -0,0 +1,35 @@ +name: Upload documentation + +on: + push: + branches: [master] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: nightly-x86_64-unknown-linux-gnu + profile: minimal + override: true + + - name: Build Docs + uses: actions-rs/cargo@v1 + with: + command: doc + args: --workspace --all-features --no-deps + + - name: Tweak HTML + run: echo '' > target/doc/index.html + + - name: Deploy to GitHub Pages + uses: JamesIves/github-pages-deploy-action@3.7.1 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BRANCH: gh-pages + FOLDER: target/doc diff --git a/.github/workflows/windows-mingw.yml b/.github/workflows/windows-mingw.yml deleted file mode 100644 index 1fd5fc59..00000000 --- a/.github/workflows/windows-mingw.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: CI (Windows-mingw) - -on: - pull_request: - types: [opened, synchronize, reopened] - push: - branches: - - master - - '1.0' - -jobs: - build_and_test: - strategy: - fail-fast: false - matrix: - version: - - stable - - nightly - - name: ${{ matrix.version }} - x86_64-pc-windows-gnu - runs-on: windows-latest - - steps: - - uses: actions/checkout@v2 - - - name: Install ${{ matrix.version }} - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{ matrix.version }}-x86_64-pc-windows-gnu - profile: minimal - override: true - - - name: Install MSYS2 - uses: msys2/setup-msys2@v2 - - - name: Install packages - run: | - msys2 -c 'pacman -Sy --noconfirm pacman' - msys2 -c 'pacman --noconfirm -S base-devel pkg-config' - - - name: check build - uses: actions-rs/cargo@v1 - with: - command: check - args: --workspace --bins --examples --tests diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml deleted file mode 100644 index b2b57989..00000000 --- a/.github/workflows/windows.yml +++ /dev/null @@ -1,69 +0,0 @@ -name: CI (Windows) - -on: - pull_request: - types: [opened, synchronize, reopened] - push: - branches: - - master - - '1.0' - -env: - VCPKGRS_DYNAMIC: 1 - -jobs: - build_and_test: - strategy: - fail-fast: false - matrix: - version: - - stable - - nightly - target: - - x86_64-pc-windows-msvc - - i686-pc-windows-msvc - - name: ${{ matrix.version }} - ${{ matrix.target }} - runs-on: windows-latest - - steps: - - uses: actions/checkout@v2 - - - name: Install ${{ matrix.version }} - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{ matrix.version }}-${{ matrix.target }} - profile: minimal - override: true - - - name: Install OpenSSL (x64) - if: matrix.target == 'x86_64-pc-windows-msvc' - run: | - vcpkg integrate install - vcpkg install openssl:x64-windows - Get-ChildItem C:\vcpkg\installed\x64-windows\bin - Get-ChildItem C:\vcpkg\installed\x64-windows\lib - Copy-Item C:\vcpkg\installed\x64-windows\bin\libcrypto-1_1-x64.dll C:\vcpkg\installed\x64-windows\bin\libcrypto.dll - Copy-Item C:\vcpkg\installed\x64-windows\bin\libssl-1_1-x64.dll C:\vcpkg\installed\x64-windows\bin\libssl.dll - - - name: Install OpenSSL (x86) - if: matrix.target == 'i686-pc-windows-msvc' - run: | - vcpkg integrate install - vcpkg install openssl:x86-windows - Get-ChildItem C:\vcpkg\installed\x86-windows\bin - Get-ChildItem C:\vcpkg\installed\x86-windows\lib - Copy-Item C:\vcpkg\installed\x86-windows\bin\libcrypto-1_1.dll C:\vcpkg\installed\x86-windows\bin\libcrypto.dll - Copy-Item C:\vcpkg\installed\x86-windows\bin\libssl-1_1.dll C:\vcpkg\installed\x86-windows\bin\libssl.dll - - - name: check build - uses: actions-rs/cargo@v1 - with: - command: check - args: --workspace --bins --examples --tests - - - name: tests - uses: actions-rs/cargo@v1 - with: - command: test - args: --workspace --exclude=actix-tls --no-fail-fast -- --nocapture diff --git a/actix-router/src/resource.rs b/actix-router/src/resource.rs index 8dbef26c..98b4a709 100644 --- a/actix-router/src/resource.rs +++ b/actix-router/src/resource.rs @@ -670,8 +670,6 @@ pub(crate) fn insert_slash(path: &str) -> String { #[cfg(test)] mod tests { use super::*; - use http::Uri; - use std::convert::TryFrom; #[test] fn test_parse_static() { @@ -833,8 +831,11 @@ mod tests { assert!(re.is_match("/user/2345/sdg")); } + #[cfg(feature = "http")] #[test] fn test_parse_urlencoded_param() { + use std::convert::TryFrom; + let re = ResourceDef::new("/user/{id}/test"); let mut path = Path::new("/user/2345/test"); @@ -845,7 +846,7 @@ mod tests { assert!(re.match_path(&mut path)); assert_eq!(path.get("id").unwrap(), "qwe%25"); - let uri = Uri::try_from("/user/qwe%25/test").unwrap(); + let uri = http::Uri::try_from("/user/qwe%25/test").unwrap(); let mut path = Path::new(uri); assert!(re.match_path(&mut path)); assert_eq!(path.get("id").unwrap(), "qwe%25"); diff --git a/actix-tls/Cargo.toml b/actix-tls/Cargo.toml index db79d6ab..92f04e06 100755 --- a/actix-tls/Cargo.toml +++ b/actix-tls/Cargo.toml @@ -52,7 +52,7 @@ log = "0.4" tokio-util = { version = "0.6.3", default-features = false } # openssl -tls-openssl = { package = "openssl", version = "0.10", optional = true } +tls-openssl = { package = "openssl", version = "0.10.9", optional = true } tokio-openssl = { version = "0.6", optional = true } # rustls @@ -62,6 +62,12 @@ webpki-roots = { version = "0.21", optional = true } # native-tls tokio-native-tls = { version = "0.3", optional = true } +[target.'cfg(windows)'.dependencies.tls-openssl] +version = "0.10.9" +package = "openssl" +features = ["vendored"] +optional = true + [dev-dependencies] actix-rt = "2.0.0" actix-server = "2.0.0-beta.3" diff --git a/actix-tls/tests/test_connect.rs b/actix-tls/tests/test_connect.rs index e8e23757..564151ce 100755 --- a/actix-tls/tests/test_connect.rs +++ b/actix-tls/tests/test_connect.rs @@ -1,3 +1,5 @@ +#![cfg(feature = "connect")] + use std::{ io, net::{IpAddr, Ipv4Addr}, @@ -12,7 +14,7 @@ use futures_util::sink::SinkExt; use actix_tls::connect::{self as actix_connect, Connect}; -#[cfg(all(feature = "connect", feature = "openssl"))] +#[cfg(feature = "openssl")] #[actix_rt::test] async fn test_string() { let srv = TestServer::with(|| { diff --git a/actix-tls/tests/test_resolvers.rs b/actix-tls/tests/test_resolvers.rs index 0f49c486..40ee21fa 100644 --- a/actix-tls/tests/test_resolvers.rs +++ b/actix-tls/tests/test_resolvers.rs @@ -1,3 +1,5 @@ +#![cfg(feature = "connect")] + use std::{ io, net::{Ipv4Addr, SocketAddr},