Skip to content

Commit

Permalink
CI: Create branch release/0.22. Update CI & Clippy config for it.
Browse files Browse the repository at this point in the history
Jobs just silently wait forever since they are waiting for an 18.04
runner and there are none anymore. Fix that.

Ubuntu 22.04 doesn't have clang-10. Fix that by syncing mk/* with
the versions in the *ring* main branch.

To minimize changes to the source code, turn off newer Clippy lints.

Fix typo in `cargo clippy` invocation.

Upgrade to latest cargo deny.
  • Loading branch information
briansmith committed Aug 29, 2023
1 parent 0b7cbf2 commit a76377f
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 48 deletions.
24 changes: 12 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
# Don't run duplicate `push` jobs for the repo owner's PRs.
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository

runs-on: ubuntu-18.04
runs-on: ubuntu-22.04

steps:
- uses: actions-rs/toolchain@v1
Expand All @@ -22,7 +22,7 @@ jobs:
# Don't run duplicate `push` jobs for the repo owner's PRs.
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository

runs-on: ubuntu-18.04
runs-on: ubuntu-22.04

steps:
- uses: actions-rs/toolchain@v1
Expand All @@ -33,13 +33,13 @@ jobs:

- uses: actions/checkout@v2

- run: cargo clippy --all-features ---all-targets -- --deny warnings
- run: cargo clippy --all-features --all-targets -- --deny warnings

audit:
# Don't run duplicate `push` jobs for the repo owner's PRs.
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository

runs-on: ubuntu-18.04
runs-on: ubuntu-22.04

steps:
- uses: actions-rs/toolchain@v1
Expand Down Expand Up @@ -67,7 +67,7 @@ jobs:
# Don't run duplicate `push` jobs for the repo owner's PRs.
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository

runs-on: ubuntu-18.04
runs-on: ubuntu-22.04

steps:
- uses: actions-rs/toolchain@v1
Expand All @@ -81,9 +81,9 @@ jobs:
~/.cargo/bin/cargo-deny
~/.cargo/.crates.toml
~/.cargo/.crates2.json
key: ${{ runner.os }}-v2-cargo-deny-locked-0.8.5
key: ${{ runner.os }}-v2-cargo-deny-locked-0.14.1

- run: cargo install cargo-deny --locked --vers "0.8.5"
- run: cargo install cargo-deny --locked --vers "0.14.1"

- uses: actions/checkout@v2

Expand All @@ -94,7 +94,7 @@ jobs:
# Don't run duplicate `push` jobs for the repo owner's PRs.
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository

runs-on: ubuntu-18.04
runs-on: ubuntu-22.04

strategy:
matrix:
Expand Down Expand Up @@ -162,16 +162,16 @@ jobs:

include:
- target: arm-unknown-linux-gnueabihf
host_os: ubuntu-18.04
host_os: ubuntu-22.04

- target: i686-pc-windows-msvc
host_os: windows-latest

- target: x86_64-unknown-linux-musl
host_os: ubuntu-18.04
host_os: ubuntu-22.04

- target: x86_64-unknown-linux-gnu
host_os: ubuntu-18.04
host_os: ubuntu-22.04

steps:
- if: ${{ contains(matrix.host_os, 'ubuntu') }}
Expand Down Expand Up @@ -224,7 +224,7 @@ jobs:
# TODO: targets
include:
- target: x86_64-unknown-linux-musl
host_os: ubuntu-18.04
host_os: ubuntu-22.04

steps:
- if: ${{ contains(matrix.host_os, 'ubuntu') }}
Expand Down
32 changes: 21 additions & 11 deletions mk/cargo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,18 @@ IFS=$'\n\t'
rustflags_self_contained="-Clink-self-contained=yes -Clinker=rust-lld"
qemu_aarch64="qemu-aarch64 -L /usr/aarch64-linux-gnu"
qemu_arm="qemu-arm -L /usr/arm-linux-gnueabihf"
qemu_mipsel="qemu-mipsel -L /usr/mipsel-linux-gnu"

# Avoid putting the Android tools in `$PATH` because there are tools in this
# directory like `clang` that would conflict with the same-named tools that may
# be needed to compile the build script, or to compile for other targets.
if [ -n "${ANDROID_SDK_ROOT-}" ]; then
android_tools=$ANDROID_SDK_ROOT/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin
if [ -n "${ANDROID_HOME-}" ]; then
# Keep the next line in sync with the corresponding line in install-build-tools.sh.
ndk_version=25.2.9519653
ANDROID_NDK_ROOT=${ANDROID_NDK_ROOT:-${ANDROID_HOME}/ndk/$ndk_version}
fi
if [ -n "${ANDROID_NDK_ROOT-}" ]; then
android_tools=${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/linux-x86_64/bin
fi

for arg in $*; do
Expand All @@ -39,15 +45,12 @@ for arg in $*; do
done

# See comments in install-build-tools.sh.
llvm_version=10
if [ -n "${RING_COVERAGE-}" ]; then
llvm_version=11
fi
llvm_version=15

case $target in
aarch64-linux-android)
export CC_aarch64_linux_android=$android_tools/aarch64-linux-android21-clang
export AR_aarch64_linux_android=$android_tools/aarch64-linux-android-ar
export AR_aarch64_linux_android=$android_tools/llvm-ar
export CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=$android_tools/aarch64-linux-android21-clang
;;
aarch64-unknown-linux-gnu)
Expand All @@ -70,9 +73,9 @@ case $target in
export CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_RUNNER="$qemu_arm"
;;
armv7-linux-androideabi)
export CC_armv7_linux_androideabi=$android_tools/armv7a-linux-androideabi18-clang
export AR_armv7_linux_androideabi=$android_tools/arm-linux-androideabi-ar
export CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER=$android_tools/armv7a-linux-androideabi18-clang
export CC_armv7_linux_androideabi=$android_tools/armv7a-linux-androideabi19-clang
export AR_armv7_linux_androideabi=$android_tools/llvm-ar
export CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER=$android_tools/armv7a-linux-androideabi19-clang
;;
armv7-unknown-linux-musleabihf)
export CC_armv7_unknown_linux_musleabihf=clang-$llvm_version
Expand All @@ -90,6 +93,12 @@ case $target in
export AR_i686_unknown_linux_musl=llvm-ar-$llvm_version
export CARGO_TARGET_I686_UNKNOWN_LINUX_MUSL_RUSTFLAGS="$rustflags_self_contained"
;;
mipsel-unknown-linux-gnu)
export CC_mipsel_unknown_linux_gnu=mipsel-linux-gnu-gcc
export AR_mipsel_unknown_linux_gnu=mipsel-linux-gnu-gcc-ar
export CARGO_TARGET_MIPSEL_UNKNOWN_LINUX_GNU_LINKER=mipsel-linux-gnu-gcc
export CARGO_TARGET_MIPSEL_UNKNOWN_LINUX_GNU_RUNNER="$qemu_mipsel"
;;
x86_64-unknown-linux-musl)
export CC_x86_64_unknown_linux_musl=clang-$llvm_version
export AR_x86_64_unknown_linux_musl=llvm-ar-$llvm_version
Expand All @@ -105,6 +114,7 @@ case $target in
export CC_wasm32_unknown_unknown=clang-$llvm_version
export AR_wasm32_unknown_unknown=llvm-ar-$llvm_version
export CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUNNER=wasm-bindgen-test-runner
export WASM_BINDGEN_TEST_TIMEOUT=60
;;
*)
;;
Expand Down Expand Up @@ -134,7 +144,7 @@ if [ -n "${RING_COVERAGE-}" ]; then
declare -x "${runner_var}=mk/runner ${!runner_var-}"

rustflags_var=CARGO_TARGET_${target_upper}_RUSTFLAGS
declare -x "${rustflags_var}=-Zinstrument-coverage ${!rustflags_var-}"
declare -x "${rustflags_var}=-Cinstrument-coverage ${!rustflags_var-}"
fi

cargo "$@"
Expand Down
68 changes: 44 additions & 24 deletions mk/install-build-tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,32 @@ function install_packages {
use_clang=
case $target in
--target*android*)
mkdir -p "${ANDROID_SDK_ROOT}/licenses"
android_license_file="${ANDROID_SDK_ROOT}/licenses/android-sdk-license"
# https://blog.rust-lang.org/2023/01/09/android-ndk-update-r25.html says
# "Going forward the Android platform will target the most recent LTS NDK,
# allowing Rust developers to access platform features sooner. These updates
# should occur yearly and will be announced in release notes." Assume that
# means that we should always prefer to be using the latest 25.x.y version of
# the NDK until the Rust project announces that we should use a higher major
# version number.
#
# TODO: This should probably be implemented as a map of Rust toolchain version
# to NDK version; e.g. our MSRV might (only) support an older NDK than the
# latest stable Rust toolchain.
#
# Keep the following line in sync with the corresponding line in cargo.sh.
ndk_version=25.2.9519653

mkdir -p "${ANDROID_HOME}/licenses"
android_license_file="${ANDROID_HOME}/licenses/android-sdk-license"
accept_android_license=24333f8a63b6825ea9c5514f83c2829b004d1fee
grep --quiet --no-messages "$accept_android_license" "$android_license_file" \
|| echo $accept_android_license >> "$android_license_file"
sudo "${ANDROID_SDK_ROOT}/tools/bin/sdkmanager" ndk-bundle
"${ANDROID_HOME}/cmdline-tools/latest/bin/sdkmanager" "ndk;$ndk_version"

# XXX: Older Rust toolchain versions link with `-lgcc` instead of `-lunwind`;
# see https://github.com/rust-lang/rust/pull/85806.
find -L ${ANDROID_NDK_ROOT:-${ANDROID_HOME}/ndk/$ndk_version} -name libunwind.a \
-execdir sh -c 'echo "INPUT(-lunwind)" > libgcc.a' \;
;;
esac

Expand Down Expand Up @@ -65,31 +85,31 @@ case $target in
--target=i686-unknown-linux-musl|--target=x86_64-unknown-linux-musl)
use_clang=1
;;
--target=mipsel-unknown-linux-gnu)
install_packages \
gcc-mipsel-linux-gnu \
libc6-dev-mipsel-cross \
qemu-user
;;
--target=wasm32-unknown-unknown)
# The version of wasm-bindgen-cli must match the wasm-bindgen version.
wasm_bindgen_version=$(cargo metadata --format-version 1 | jq -r '.packages | map(select( .name == "wasm-bindgen")) | map(.version) | .[0]')
cargo install wasm-bindgen-cli --vers "$wasm_bindgen_version" --bin wasm-bindgen-test-runner
case ${features-} in
*wasm32_c*)
use_clang=1
;;
*)
;;
esac
cargo install wasm-bindgen-cli --bin wasm-bindgen-test-runner
use_clang=1
;;
--target=*)
;;
esac

if [ -n "$use_clang" ]; then
llvm_version=10
if [ -n "${RING_COVERAGE-}" ]; then
# https://github.com/rust-lang/rust/pull/79365 upgraded the coverage file
# format to one that only LLVM 11+ can use
llvm_version=11
sudo apt-key add mk/llvm-snapshot.gpg.key
sudo add-apt-repository "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-$llvm_version main"
sudo apt-get update
case "$OSTYPE" in
linux*)
ubuntu_codename=$(lsb_release --codename --short)
llvm_version=15
sudo apt-key add mk/llvm-snapshot.gpg.key
sudo add-apt-repository "deb http://apt.llvm.org/$ubuntu_codename/ llvm-toolchain-$ubuntu_codename-$llvm_version main"
sudo apt-get update
# We need to use `llvm-nm` in `mk/check-symbol-prefixes.sh`.
install_packages llvm-$llvm_version
if [ -n "$use_clang" ]; then
install_packages clang-$llvm_version
fi
install_packages clang-$llvm_version llvm-$llvm_version
fi
;;
esac
8 changes: 7 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,20 @@
#![doc(html_root_url = "https://briansmith.org/rustdoc/")]
#![cfg_attr(not(feature = "std"), no_std)]
#![allow(
clippy::clone_on_copy,
clippy::derive_partial_eq_without_eq,
clippy::doc_markdown,
clippy::explicit_auto_deref,
clippy::if_not_else,
clippy::inline_always,
clippy::items_after_statements,
clippy::missing_errors_doc,
clippy::module_name_repetitions,
clippy::needless_borrow,
clippy::redundant_closure,
clippy::single_match,
clippy::single_match_else
clippy::single_match_else,
clippy::useless_asref
)]
#![deny(clippy::as_conversions)]

Expand Down
1 change: 1 addition & 0 deletions tests/dns_name_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ static DNS_NAME_VALIDITY: &[(&[u8], bool)] = &[

// (IP address, is valid DNS name). The comments here refer to the validity of
// the string as an IP address, not as a DNS name validity.
#[allow(clippy::octal_escapes)]
static IP_ADDRESS_DNS_VALIDITY: &[(&[u8], bool)] = &[
(b"", false),
(b"1", false),
Expand Down

0 comments on commit a76377f

Please sign in to comment.