From 0b677c4be7074ac442f70fce446500c5c9378c46 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Sun, 8 Oct 2023 23:51:36 +0900 Subject: [PATCH] wip --- .cirrus.yml | 64 +++++----- .external-types.toml | 9 ++ .github/workflows/ci.yml | 262 +++++++++++++++++++++------------------ Cargo.toml | 2 +- README.md | 16 +-- src/lib.rs | 4 +- 6 files changed, 189 insertions(+), 168 deletions(-) create mode 100644 .external-types.toml diff --git a/.cirrus.yml b/.cirrus.yml index a0c8143..ab8bdf3 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -1,4 +1,4 @@ -only_if: $CIRRUS_TAG == '' && ($CIRRUS_PR != '' || $CIRRUS_BRANCH == 'master') +only_if: $CIRRUS_TAG == '' && ($CIRRUS_PR != '' || $CIRRUS_BRANCH == 'taiki-e/nosigpipe') auto_cancellation: $CIRRUS_BRANCH != 'master' env: CARGO_INCREMENTAL: '0' @@ -11,23 +11,23 @@ env: RUSTFLAGS: -D warnings RUSTUP_MAX_RETRIES: '10' -freebsd_task: - name: test ($TARGET) - freebsd_instance: - image_family: freebsd-12-4 - matrix: - - env: - TARGET: x86_64-unknown-freebsd - - env: - TARGET: i686-unknown-freebsd - setup_script: - # https://github.com/cirruslabs/cirrus-ci-docs/issues/483 - - sudo sysctl net.inet.tcp.blackhole=0 - - pkg install -y git - - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain stable --target $TARGET - test_script: - - . $HOME/.cargo/env - - cargo test --target $TARGET +# freebsd_task: +# name: test ($TARGET) +# freebsd_instance: +# image_family: freebsd-12-4 +# matrix: +# - env: +# TARGET: x86_64-unknown-freebsd +# - env: +# TARGET: i686-unknown-freebsd +# setup_script: +# # https://github.com/cirruslabs/cirrus-ci-docs/issues/483 +# - sudo sysctl net.inet.tcp.blackhole=0 +# - pkg install -y git +# - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain stable --target $TARGET +# test_script: +# - . $HOME/.cargo/env +# - cargo test --target $TARGET netbsd_task: name: test ($TARGET) @@ -45,17 +45,17 @@ netbsd_task: - . $HOME/.cargo/env - cargo test -openbsd_task: - name: test ($TARGET) - compute_engine_instance: - image_project: pg-ci-images - # https://github.com/anarazel/pg-vm-images/blob/main/packer/openbsd.pkrvars.hcl - image: family/pg-ci-openbsd-vanilla-7-2 - platform: openbsd - env: - TARGET: x86_64-unknown-openbsd - setup_script: - # OpenBSD is tier 3 target, so install rust from package manager instead of rustup - - pkg_add git rust - test_script: - - cargo test +# openbsd_task: +# name: test ($TARGET) +# compute_engine_instance: +# image_project: pg-ci-images +# # https://github.com/anarazel/pg-vm-images/blob/main/packer/openbsd.pkrvars.hcl +# image: family/pg-ci-openbsd-vanilla-7-2 +# platform: openbsd +# env: +# TARGET: x86_64-unknown-openbsd +# setup_script: +# # OpenBSD is tier 3 target, so install rust from package manager instead of rustup +# - pkg_add git rust +# test_script: +# - cargo test diff --git a/.external-types.toml b/.external-types.toml new file mode 100644 index 0000000..bd7027f --- /dev/null +++ b/.external-types.toml @@ -0,0 +1,9 @@ +# cargo-check-external-types configuration +# https://crates.io/crates/cargo-check-external-types + +# The following are types that are allowed to be exposed in our public API. +# The standard library is allowed by default. +allowed_external_types = [ + "futures_core::*", + "futures_io::*", +] diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1e59d5a..8485eb6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,7 @@ on: pull_request: push: branches: - - master + - taiki-e/nosigpipe schedule: - cron: '0 2 * * 0' @@ -26,132 +26,148 @@ defaults: shell: bash jobs: - test: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - rust: [nightly, beta, stable] - steps: - - uses: actions/checkout@v4 - - name: Install Rust - # --no-self-update is necessary because the windows environment cannot self-update rustup.exe. - run: rustup update ${{ matrix.rust }} --no-self-update && rustup default ${{ matrix.rust }} - - run: cargo build --all --all-features --all-targets - - name: Run cargo check (without dev-dependencies to catch missing feature flags) - if: startsWith(matrix.rust, 'nightly') - run: cargo check -Z features=dev_dep - - name: Add rust-src - if: startsWith(matrix.rust, 'nightly') - run: rustup component add rust-src -# https://github.com/smol-rs/async-io/pull/144#issuecomment-1666927490 -# - name: Check selected Tier 3 targets -# if: startsWith(matrix.rust, 'nightly') && matrix.os == 'ubuntu-latest' -# run: cargo check -Z build-std --target=riscv32imc-esp-espidf - - run: cargo test +# test: +# runs-on: ${{ matrix.os }} +# strategy: +# fail-fast: false +# matrix: +# os: [ubuntu-latest, windows-latest, macos-latest] +# rust: [nightly, beta, stable] +# steps: +# - uses: actions/checkout@v4 +# - name: Install Rust +# # --no-self-update is necessary because the windows environment cannot self-update rustup.exe. +# run: rustup update ${{ matrix.rust }} --no-self-update && rustup default ${{ matrix.rust }} +# - run: cargo build --all --all-features --all-targets +# - name: Run cargo check (without dev-dependencies to catch missing feature flags) +# if: startsWith(matrix.rust, 'nightly') +# run: cargo check -Z features=dev_dep +# - name: Add rust-src +# if: startsWith(matrix.rust, 'nightly') +# run: rustup component add rust-src +# # https://github.com/smol-rs/async-io/pull/144#issuecomment-1666927490 +# # - name: Check selected Tier 3 targets +# # if: startsWith(matrix.rust, 'nightly') && matrix.os == 'ubuntu-latest' +# # run: cargo check -Z build-std --target=riscv32imc-esp-espidf +# - run: cargo test - # Copied from: https://github.com/rust-lang/stacker/pull/19/files - windows_gnu: - runs-on: windows-latest - strategy: - matrix: - rust: [nightly] - target: - - x86_64-pc-windows-gnu - steps: - - uses: actions/checkout@v4 - - name: Install Rust - # --no-self-update is necessary because the windows environment cannot self-update rustup.exe. - run: rustup update ${{ matrix.rust }} --no-self-update && rustup default ${{ matrix.rust }} - - run: rustup target add ${{ matrix.target }} - # https://github.com/rust-lang/rust/issues/49078 - - name: Fix windows-gnu rust-mingw - run : | - for i in crt2.o dllcrt2.o libmingwex.a libmsvcrt.a ; do - cp -f "/C/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/x86_64-w64-mingw32/lib/$i" "`rustc --print sysroot`/lib/rustlib/x86_64-pc-windows-gnu/lib" - done - - run: cargo build --target ${{ matrix.target }} --all --all-features --all-targets - - run: cargo test --target ${{ matrix.target }} +# # Copied from: https://github.com/rust-lang/stacker/pull/19/files +# windows_gnu: +# runs-on: windows-latest +# strategy: +# matrix: +# rust: [nightly] +# target: +# - x86_64-pc-windows-gnu +# steps: +# - uses: actions/checkout@v4 +# - name: Install Rust +# # --no-self-update is necessary because the windows environment cannot self-update rustup.exe. +# run: rustup update ${{ matrix.rust }} --no-self-update && rustup default ${{ matrix.rust }} +# - run: rustup target add ${{ matrix.target }} +# # https://github.com/rust-lang/rust/issues/49078 +# - name: Fix windows-gnu rust-mingw +# run : | +# for i in crt2.o dllcrt2.o libmingwex.a libmsvcrt.a ; do +# cp -f "/C/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/x86_64-w64-mingw32/lib/$i" "`rustc --print sysroot`/lib/rustlib/x86_64-pc-windows-gnu/lib" +# done +# - run: cargo build --target ${{ matrix.target }} --all --all-features --all-targets +# - run: cargo test --target ${{ matrix.target }} - cross: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest, macos-latest] - steps: - - uses: actions/checkout@v4 - - name: Install Rust - run: rustup update stable - - name: Install cross - uses: taiki-e/install-action@cross - # We don't test BSDs, since we already test them in Cirrus. - - name: Android - if: startsWith(matrix.os, 'ubuntu') - run: cross test --target arm-linux-androideabi - - name: iOS - if: startsWith(matrix.os, 'macos') - run: | - rustup target add aarch64-apple-ios - cross build --target aarch64-apple-ios - - name: Linux x32 - if: startsWith(matrix.os, 'ubuntu') - run: | - rustup target add x86_64-unknown-linux-gnux32 - cross check --target x86_64-unknown-linux-gnux32 - - name: Fuchsia - if: startsWith(matrix.os, 'ubuntu') - run: | - rustup target add x86_64-unknown-fuchsia - cargo build --target x86_64-unknown-fuchsia - - name: illumos - if: startsWith(matrix.os, 'ubuntu') - run: | - rustup target add x86_64-unknown-illumos - cargo build --target x86_64-unknown-illumos +# cross: +# runs-on: ${{ matrix.os }} +# strategy: +# fail-fast: false +# matrix: +# os: [ubuntu-latest, macos-latest] +# steps: +# - uses: actions/checkout@v4 +# - name: Install Rust +# run: rustup update stable +# - name: Install cross +# uses: taiki-e/install-action@cross +# # We don't test BSDs, since we already test them in Cirrus. +# - name: Android +# if: startsWith(matrix.os, 'ubuntu') +# run: cross test --target arm-linux-androideabi +# - name: iOS +# if: startsWith(matrix.os, 'macos') +# run: | +# rustup target add aarch64-apple-ios +# cross build --target aarch64-apple-ios +# - name: Linux x32 +# if: startsWith(matrix.os, 'ubuntu') +# run: | +# rustup target add x86_64-unknown-linux-gnux32 +# cross check --target x86_64-unknown-linux-gnux32 +# - name: Fuchsia +# if: startsWith(matrix.os, 'ubuntu') +# run: | +# rustup target add x86_64-unknown-fuchsia +# cargo build --target x86_64-unknown-fuchsia +# - name: illumos +# if: startsWith(matrix.os, 'ubuntu') +# run: | +# rustup target add x86_64-unknown-illumos +# cargo build --target x86_64-unknown-illumos - msrv: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest, windows-latest] - # When updating this, the reminder to update the minimum supported - # Rust version in Cargo.toml. - rust: ['1.63'] - steps: - - uses: actions/checkout@v4 - - name: Install Rust - # --no-self-update is necessary because the windows environment cannot self-update rustup.exe. - run: rustup update ${{ matrix.rust }} --no-self-update && rustup default ${{ matrix.rust }} - - run: cargo build +# msrv: +# runs-on: ${{ matrix.os }} +# strategy: +# fail-fast: false +# matrix: +# os: [ubuntu-latest, windows-latest] +# # When updating this, the reminder to update the minimum supported +# # Rust version in Cargo.toml. +# rust: ['1.63'] +# steps: +# - uses: actions/checkout@v4 +# - name: Install Rust +# # --no-self-update is necessary because the windows environment cannot self-update rustup.exe. +# run: rustup update ${{ matrix.rust }} --no-self-update && rustup default ${{ matrix.rust }} +# - run: cargo build - clippy: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Install Rust - run: rustup update stable - - run: cargo clippy --all-features --all-targets +# clippy: +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v4 +# - name: Install Rust +# run: rustup update stable +# - run: cargo clippy --all-features --all-targets - fmt: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Install Rust - run: rustup update stable - - run: cargo fmt --all --check +# fmt: +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v4 +# - name: Install Rust +# run: rustup update stable +# - run: cargo fmt --all --check + +# security_audit: +# permissions: +# checks: write +# contents: read +# issues: write +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v4 +# # https://github.com/rustsec/audit-check/issues/2 +# - uses: rustsec/audit-check@master +# with: +# token: ${{ secrets.GITHUB_TOKEN }} - security_audit: - permissions: - checks: write - contents: read - issues: write - runs-on: ubuntu-latest + dragonfly: + runs-on: macos-12 steps: - - uses: actions/checkout@v4 - # https://github.com/rustsec/audit-check/issues/2 - - uses: rustsec/audit-check@master - with: - token: ${{ secrets.GITHUB_TOKEN }} + - uses: actions/checkout@v3 + - name: Test Dragonfly BSD + id: test + uses: vmactions/dragonflybsd-vm@v0 + with: + envs: CARGO_INCREMENTAL CARGO_NET_GIT_FETCH_WITH_CLI CARGO_NET_RETRY RUST_BACKTRACE RUSTFLAGS RUSTDOCFLAGS RUSTUP_MAX_RETRIES + usesh: true + # Dragonfly BSD is tier 3 target, so install rust from package manager instead of rustup + prepare: | + pkg install -y git rust + run: | + cargo test diff --git a/Cargo.toml b/Cargo.toml index 4c58a1e..533317f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,7 +30,7 @@ futures-io = { version = "0.3.28", default-features = false, features = ["std"] futures-lite = { version = "1.11.0", default-features = false } parking = "2.0.0" polling = "3.0.0" -rustix = { version = "0.38.2", default-features = false, features = ["fs", "net", "std"] } +rustix = { git = "https://github.com/taiki-e/rustix", branch = "nosigpipe", default-features = false, features = ["fs", "net", "std"] } slab = "0.4.2" tracing = { version = "0.1.37", default-features = false } waker-fn = "1.1.0" diff --git a/README.md b/README.md index 2e961f6..858e9be 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # async-io -[![Build](https://github.com/smol-rs/async-io/workflows/Build%20and%20test/badge.svg)]( +[![Build](https://github.com/smol-rs/async-io/actions/workflows/ci.yml/badge.svg)]( https://github.com/smol-rs/async-io/actions) [![License](https://img.shields.io/badge/license-Apache--2.0_OR_MIT-blue.svg)]( https://github.com/smol-rs/async-io) @@ -64,15 +64,9 @@ let stream = Async::::connect(addr).or(async { ## License -Licensed under either of - - * Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) - * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) - -at your option. - -#### Contribution +Licensed under either of [Apache License, Version 2.0](LICENSE-APACHE) or +[MIT license](LICENSE-MIT) at your option. Unless you explicitly state otherwise, any contribution intentionally submitted -for inclusion in the work by you, as defined in the Apache-2.0 license, shall be -dual licensed as above, without any additional terms or conditions. +for inclusion in the work by you, as defined in the Apache-2.0 license, shall +be dual licensed as above, without any additional terms or conditions. diff --git a/src/lib.rs b/src/lib.rs index 525a408..19c082f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2099,7 +2099,9 @@ fn connect( target_os = "ios", target_os = "tvos", target_os = "watchos", - target_os = "freebsd" + target_os = "freebsd", + target_os = "netbsd", + target_os = "dragonfly", ))] rn::sockopt::set_socket_nosigpipe(&socket, true)?;