From 0f3068f4884dfa439fcc3d87b21ff7c3c67208b6 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Wed, 15 Mar 2023 05:39:02 +0000 Subject: [PATCH 1/4] ci(windows): use choco to install openssl (#3003 ci: remove openssl install on windows --- .github/workflows/ci.yml | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 48380265a..88353fd30 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ jobs: 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-2022, triple: x86_64-pc-windows-msvc } + - { name: Windows, os: windows-latest, triple: x86_64-pc-windows-msvc } version: - 1.59.0 # MSRV - stable @@ -28,20 +28,16 @@ jobs: env: CI: 1 CARGO_INCREMENTAL: 0 - VCPKGRS_DYNAMIC: 1 steps: - uses: actions/checkout@v3 - # install OpenSSL on Windows - # TODO: GitHub actions docs state that OpenSSL is - # already installed on these Windows machines somewhere - - name: Set vcpkg root - if: matrix.target.triple == 'x86_64-pc-windows-msvc' - run: echo "VCPKG_ROOT=$env:VCPKG_INSTALLATION_ROOT" | Out-File -FilePath $env:GITHUB_ENV -Append - name: Install OpenSSL - if: matrix.target.triple == 'x86_64-pc-windows-msvc' - run: vcpkg install openssl:x64-windows + if: matrix.target.os == 'windows-latest' + run: choco install openssl + - name: Set OpenSSL dir in env + if: matrix.target.os == 'windows-latest' + run: echo 'OPENSSL_DIR=C:\Program Files\OpenSSL-Win64' | Out-File -FilePath $env:GITHUB_ENV -Append - name: Install ${{ matrix.version }} uses: actions-rs/toolchain@v1 From e68f87f84f3109b31de2f2361d4c06af691d8bfb Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Wed, 15 Mar 2023 13:32:55 +0000 Subject: [PATCH 2/4] add API diff to CI (#3002) --- .github/workflows/bench.yml | 6 +++- .github/workflows/ci-post-merge.yml | 8 +++-- .github/workflows/ci.yml | 12 ++++--- .github/workflows/clippy-fmt.yml | 51 +++++++++++++++++++++++------ .github/workflows/coverage.yml | 7 ++++ .github/workflows/upload-doc.yml | 10 ++++-- 6 files changed, 74 insertions(+), 20 deletions(-) diff --git a/.github/workflows/bench.yml b/.github/workflows/bench.yml index 3d16a7eb7..a1a31fb8d 100644 --- a/.github/workflows/bench.yml +++ b/.github/workflows/bench.yml @@ -6,7 +6,11 @@ on: - master permissions: - contents: read # to fetch code (actions/checkout) + contents: read # to fetch code (actions/checkout) + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true jobs: check_benchmark: diff --git a/.github/workflows/ci-post-merge.yml b/.github/workflows/ci-post-merge.yml index 30d13bf88..6ca17ef63 100644 --- a/.github/workflows/ci-post-merge.yml +++ b/.github/workflows/ci-post-merge.yml @@ -5,7 +5,11 @@ on: branches: [master] permissions: - contents: read # to fetch code (actions/checkout) + contents: read # to fetch code (actions/checkout) + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true jobs: build_and_test_nightly: @@ -81,7 +85,7 @@ jobs: - name: Clear the cargo caches run: | - cargo install cargo-cache --version 0.8.2 --no-default-features --features ci-autoclean + cargo install cargo-cache --version 0.8.3 --no-default-features --features ci-autoclean cargo-cache ci_feature_powerset_check: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 88353fd30..f8867ce22 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,6 +9,10 @@ on: permissions: contents: read # to fetch code (actions/checkout) +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: build_and_test: strategy: @@ -91,7 +95,7 @@ jobs: - name: Clear the cargo caches run: | - cargo install cargo-cache --version 0.8.2 --no-default-features --features ci-autoclean + cargo install cargo-cache --version 0.8.3 --no-default-features --features ci-autoclean cargo-cache io-uring: @@ -110,10 +114,8 @@ jobs: - name: tests (io-uring) timeout-minutes: 60 run: > - sudo bash -c "ulimit -Sl 512 - && ulimit -Hl 512 - && PATH=$PATH:/usr/share/rust/.cargo/bin - && RUSTUP_TOOLCHAIN=stable cargo test --lib --tests -p=actix-files --all-features" + sudo bash -c "ulimit -Sl 512 && ulimit -Hl 512 && PATH=$PATH:/usr/share/rust/.cargo/bin && RUSTUP_TOOLCHAIN=stable cargo test --lib --tests -p=actix-files --all-features" + rustdoc: name: doc tests diff --git a/.github/workflows/clippy-fmt.yml b/.github/workflows/clippy-fmt.yml index 877ca74e4..90e3b3a98 100644 --- a/.github/workflows/clippy-fmt.yml +++ b/.github/workflows/clippy-fmt.yml @@ -4,28 +4,42 @@ on: pull_request: types: [opened, synchronize, reopened] +permissions: + contents: read # to fetch code (actions/checkout) + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: fmt: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@nightly - with: { components: rustfmt } + + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: nightly + components: rustfmt + - run: cargo fmt --all -- --check clippy: + permissions: + checks: write # to add clippy checks to PR diffs + runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@stable + - uses: actions-rust-lang/setup-rust-toolchain@v1 with: { components: clippy } - name: Generate Cargo.lock run: cargo generate-lockfile - name: Cache Dependencies uses: Swatinem/rust-cache@v1.2.0 - + - name: Check with Clippy uses: actions-rs/clippy-check@v1 with: @@ -37,13 +51,30 @@ jobs: steps: - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@stable + - uses: actions-rust-lang/setup-rust-toolchain@v1 with: { components: rust-docs } - name: Check for broken intra-doc links - uses: actions-rs/cargo@v1 - env: - RUSTDOCFLAGS: "-D warnings" + env: { RUSTDOCFLAGS: "-D warnings" } + run: cargo doc --no-deps --all-features --workspace + + public-api-diff: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 with: - command: doc - args: --no-deps --all-features --workspace + ref: ${{ github.base_ref }} + + - uses: actions/checkout@v3 + + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: { toolchain: nightly } + + - uses: taiki-e/cache-cargo-install-action@v1 + with: { tool: cargo-public-api } + + - name: generate API diff + run: | + for f in $(find -mindepth 2 -maxdepth 2 -name Cargo.toml); do + cargo public-api --manifest-path "$f" diff ${{ github.event.pull_request.base.sha }}..${{ github.sha }} + done diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index bb6d7fb97..11538c3d6 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -6,6 +6,13 @@ on: push: branches: [master] +permissions: + contents: read # to fetch code (actions/checkout) + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: # job currently (1st Feb 2022) segfaults coverage: diff --git a/.github/workflows/upload-doc.yml b/.github/workflows/upload-doc.yml index 2464ebcd6..743e14412 100644 --- a/.github/workflows/upload-doc.yml +++ b/.github/workflows/upload-doc.yml @@ -4,11 +4,17 @@ on: push: branches: [master] -permissions: {} +permissions: + contents: read # to fetch code (actions/checkout) + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: build: permissions: - contents: write # to push changes in repo (jamesives/github-pages-deploy-action) + contents: write # to push changes in repo (jamesives/github-pages-deploy-action) runs-on: ubuntu-latest From 8dee8a14265f02d3486cd0a58d5f3a8ddbc5679e Mon Sep 17 00:00:00 2001 From: Elijah <83283675+tltsutltsu@users.noreply.github.com> Date: Sat, 1 Apr 2023 00:09:13 +0600 Subject: [PATCH 3/4] docs(actix-http-test): update test server example (#3007) --- actix-http-test/src/lib.rs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/actix-http-test/src/lib.rs b/actix-http-test/src/lib.rs index 55224dc46..8dcbe759d 100644 --- a/actix-http-test/src/lib.rs +++ b/actix-http-test/src/lib.rs @@ -34,7 +34,9 @@ use tokio::sync::mpsc; /// ```no_run /// use actix_http::HttpService; /// use actix_http_test::test_server; -/// use actix_web::{web, App, HttpResponse, Error}; +/// use actix_service::map_config; +/// use actix_service::ServiceFactoryExt; +/// use actix_web::{dev::AppConfig, web, App, Error, HttpResponse}; /// /// async fn my_handler() -> Result { /// Ok(HttpResponse::Ok().into()) @@ -42,14 +44,19 @@ use tokio::sync::mpsc; /// /// #[actix_web::test] /// async fn test_example() { -/// let mut srv = TestServer::start(|| -/// HttpService::new( -/// App::new().service(web::resource("/").to(my_handler)) -/// ) -/// ); +/// let srv = test_server(|| { +/// let app = App::new().service(web::resource("/").to(my_handler)); +/// +/// HttpService::build() +/// .h1(map_config(app, |_| AppConfig::default())) +/// .tcp() +/// .map_err(|_| ()) +/// }) +/// .await; /// /// let req = srv.get("/"); /// let response = req.send().await.unwrap(); +/// /// assert!(response.status().is_success()); /// } /// ``` From 97399e8c8ce584d005577604c10bd391e5da7268 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sun, 2 Apr 2023 03:27:14 +0100 Subject: [PATCH 4/4] simplify CI --- .github/workflows/ci-post-merge.yml | 2 +- .github/workflows/ci.yml | 36 ++++++++--------------------- .github/workflows/clippy-fmt.yml | 13 ++++------- .github/workflows/coverage.yml | 14 ++--------- 4 files changed, 17 insertions(+), 48 deletions(-) diff --git a/.github/workflows/ci-post-merge.yml b/.github/workflows/ci-post-merge.yml index 6ca17ef63..d47083575 100644 --- a/.github/workflows/ci-post-merge.yml +++ b/.github/workflows/ci-post-merge.yml @@ -48,7 +48,7 @@ jobs: - name: Install ${{ matrix.version }} uses: actions-rs/toolchain@v1 with: - toolchain: ${{ matrix.version }}-${{ matrix.target.triple }} + toolchain: ${{ matrix.version }} profile: minimal override: true diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f8867ce22..4c9149722 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,9 +29,7 @@ jobs: name: ${{ matrix.target.name }} / ${{ matrix.version }} runs-on: ${{ matrix.target.os }} - env: - CI: 1 - CARGO_INCREMENTAL: 0 + env: {} steps: - uses: actions/checkout@v3 @@ -43,12 +41,10 @@ jobs: if: matrix.target.os == 'windows-latest' run: echo 'OPENSSL_DIR=C:\Program Files\OpenSSL-Win64' | Out-File -FilePath $env:GITHUB_ENV -Append - - name: Install ${{ matrix.version }} - uses: actions-rs/toolchain@v1 + - name: Install Rust (${{ matrix.version }}) + uses: actions-rust-lang/setup-rust-toolchain@v1 with: - toolchain: ${{ matrix.version }}-${{ matrix.target.triple }} - profile: minimal - override: true + toolchain: ${{ matrix.version }} - name: Install cargo-hack uses: taiki-e/install-action@cargo-hack @@ -60,12 +56,6 @@ jobs: cargo add const-str@0.3 --dev -p=actix-web cargo add const-str@0.3 --dev -p=awc - - name: Generate Cargo.lock - uses: actions-rs/cargo@v1 - with: { command: generate-lockfile } - - name: Cache Dependencies - uses: Swatinem/rust-cache@v1.2.0 - - name: workaround MSRV issues if: matrix.version != 'stable' run: | @@ -104,12 +94,9 @@ jobs: steps: - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@stable - - - name: Generate Cargo.lock - run: cargo generate-lockfile - - name: Cache Dependencies - uses: Swatinem/rust-cache@v1.3.0 + - name: Install Rust + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: { toolchain: nightly } - name: tests (io-uring) timeout-minutes: 60 @@ -123,12 +110,9 @@ jobs: steps: - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@nightly - - - name: Generate Cargo.lock - run: cargo generate-lockfile - - name: Cache Dependencies - uses: Swatinem/rust-cache@v1.3.0 + - name: Install Rust (nightly) + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: { toolchain: nightly } - name: doc tests run: cargo ci-doctest diff --git a/.github/workflows/clippy-fmt.yml b/.github/workflows/clippy-fmt.yml index 90e3b3a98..a7da9b1c5 100644 --- a/.github/workflows/clippy-fmt.yml +++ b/.github/workflows/clippy-fmt.yml @@ -35,16 +35,11 @@ jobs: - uses: actions-rust-lang/setup-rust-toolchain@v1 with: { components: clippy } - - name: Generate Cargo.lock - run: cargo generate-lockfile - - name: Cache Dependencies - uses: Swatinem/rust-cache@v1.2.0 - - - name: Check with Clippy - uses: actions-rs/clippy-check@v1 + - uses: giraffate/clippy-action@v1 with: - args: --workspace --tests --examples --all-features - token: ${{ secrets.GITHUB_TOKEN }} + reporter: 'github-pr-check' + github_token: ${{ secrets.GITHUB_TOKEN }} + clippy_flags: --workspace --all-features --tests --examples --bins -- -Dclippy::todo lint-docs: runs-on: ubuntu-latest diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 11538c3d6..d537031c3 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -21,18 +21,8 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Install stable - uses: actions-rs/toolchain@v1 - with: - toolchain: stable-x86_64-unknown-linux-gnu - profile: minimal - override: true - - - name: Generate Cargo.lock - uses: actions-rs/cargo@v1 - with: { command: generate-lockfile } - - name: Cache Dependencies - uses: Swatinem/rust-cache@v1.2.0 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: { toolchain: nightly } - name: Generate coverage file run: |