From 207e7dbdff6f0f8c80fa9d57d73c31e6c7e938a2 Mon Sep 17 00:00:00 2001 From: Dominik Maier Date: Thu, 4 Jan 2024 21:50:14 +0100 Subject: [PATCH] Move Clippy to extra CI steps (#1370) * Move Clippy to extra CI steps * clippy? * Last try with nightly * no clue why but hey * cleanup * more * revert * check ubuntu works * f * debug * clippy_ci * remove tmate * regex --------- Co-authored-by: Dongjia "toka" Zhang --- .github/workflows/build_and_test.yml | 85 ++++++++++++++++++++++---- libafl_concolic/symcc_runtime/build.rs | 2 +- 2 files changed, 75 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 3f4faec194..32e38fb237 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -24,6 +24,9 @@ jobs: profile: minimal toolchain: nightly override: true + - name: Install mimetype + if: runner.os == 'Linux' + run: sudo apt-get install libfile-mimeinfo-perl - name: install mdbook uses: baptiste0928/cargo-install@v1.3.0 with: @@ -90,8 +93,6 @@ jobs: run: clang-format-13 -n -Werror --style=file $(find . -type f \( -name '*.cpp' -o -iname '*.hpp' -o -name '*.cc' -o -name '*.cxx' -o -name '*.cc' -o -name '*.h' \) | grep -v '/target/' | grep -v 'libpng-1\.6\.37' | grep -v 'stb_image\.h' | grep -v 'dlmalloc\.c' | grep -v 'QEMU-Nyx') - name: run shellcheck run: shellcheck ./scripts/*.sh - - name: Run clippy - run: ./scripts/clippy.sh # ---- doc check ---- - name: Build Docs @@ -107,6 +108,28 @@ jobs: # --- miri undefined behavior test -- - name: Run miri tests run: RUST_BACKTRACE=1 MIRIFLAGS="-Zmiri-disable-isolation" cargo +nightly miri test + + ubuntu-clippy: + runs-on: ubuntu-22.04 + steps: + - name: Remove Dotnet & Haskell + run: rm -rf /usr/share/dotnet && rm -rf /opt/ghc + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + - name: Install and cache deps + uses: awalsh128/cache-apt-pkgs-action@v1.1.0 + with: + packages: llvm-15 clang-15 llvm-15-dev ninja-build clang-format-13 shellcheck libgtk-3-dev gcc-arm-linux-gnueabi g++-arm-linux-gnueabi libslirp-dev libz3-dev + - name: get clang version + run: command -v llvm-config-15 && clang-15 -v + - name: Add nightly rustfmt and clippy + run: rustup toolchain install nightly --component clippy --allow-downgrade && rustup default nightly + - uses: actions/checkout@v3 + - uses: Swatinem/rust-cache@v2 + - name: Run clippy + run: ./scripts/clippy.sh # Clean up files to save up disk space - name: Cleanup @@ -347,7 +370,7 @@ jobs: profile: minimal toolchain: nightly override: true - components: rustfmt, clippy, rust-src + components: rustfmt, rust-src - uses: actions/checkout@v3 - uses: Swatinem/rust-cache@v2 - name: Add targets @@ -358,6 +381,20 @@ jobs: run: cd ./fuzzers/baby_no_std && cargo +nightly run || test $? -ne 0 || exit 1 - name: no_std tests run: cd ./libafl && cargo test --no-default-features + + nostd-clippy: + runs-on: ubuntu-latest + steps: + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: nightly + override: true + components: rustfmt, clippy, rust-src + - uses: actions/checkout@v3 + - uses: Swatinem/rust-cache@v2 + - name: Add targets + run: rustup target add arm-linux-androideabi && rustup target add thumbv6m-none-eabi - name: libafl armv6m-none-eabi (32 bit no_std) clippy run: cd ./libafl && cargo clippy --target thumbv6m-none-eabi --no-default-features - name: Build no_std no_alloc bolts @@ -381,10 +418,6 @@ jobs: - uses: Swatinem/rust-cache@v2 - name: Windows Build run: cargo build --verbose - - name: Run clippy - uses: actions-rs/cargo@v1 - with: - command: clippy - name: Build docs run: cargo doc - name: Set LIBCLANG_PATH @@ -402,7 +435,21 @@ jobs: run: cd fuzzers/frida_gdiplus/ && cargo make test - name: Build fuzzers/tinyinst_simple run: cd fuzzers/tinyinst_simple/ && cargo make test - + + windows-clippy: + runs-on: windows-latest + steps: + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + - uses: actions/checkout@v3 + - uses: Swatinem/rust-cache@v2 + - name: Run clippy + uses: actions-rs/cargo@v1 + with: + command: clippy + macos: runs-on: macOS-latest steps: @@ -411,7 +458,7 @@ jobs: profile: minimal toolchain: stable - name: Add nightly rustfmt and clippy - run: rustup toolchain install nightly --component rustfmt --component clippy --allow-downgrade + run: rustup toolchain install nightly --component rustfmt --component clippy --allow-downgrade && rustup default nightly - name: Install ucd-generate run: cargo install -f ucd-generate - name: Install deps @@ -422,13 +469,29 @@ jobs: - uses: Swatinem/rust-cache@v2 - name: MacOS Build run: cargo build --verbose - - name: Run clippy - run: ./scripts/clippy.sh - name: Increase map sizes run: ./scripts/shmem_limits_macos.sh - name: Run Tests run: cargo test + macos-clippy: + runs-on: macOS-latest + steps: + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + - name: Add nightly rustfmt and clippy + run: rustup toolchain install nightly --component clippy --allow-downgrade && rustup default nightly + - name: Install deps + run: brew install z3 gtk+3 + - name: Install cxxbridge + run: cargo install cxxbridge-cmd + - uses: actions/checkout@v3 + - uses: Swatinem/rust-cache@v2 + - name: Run clippy + run: ./scripts/clippy.sh + other_targets: runs-on: macOS-latest steps: diff --git a/libafl_concolic/symcc_runtime/build.rs b/libafl_concolic/symcc_runtime/build.rs index 21cc9c35ed..add62d5a09 100644 --- a/libafl_concolic/symcc_runtime/build.rs +++ b/libafl_concolic/symcc_runtime/build.rs @@ -14,7 +14,7 @@ const SYMCC_RUNTIME_FUNCTION_NAME_PREFIX: &str = "_cpp_"; thread_local! { static FUNCTION_NAME_REGEX: RefCell = RefCell::new(Regex::new(r"pub fn (\w+)").unwrap()); - static EXPORTED_FUNCTION_REGEX: RefCell = RefCell::new(RegexBuilder::new(r"(pub fn \w+\([^\)]*\)[^;]*);") + static EXPORTED_FUNCTION_REGEX: RefCell = RefCell::new(RegexBuilder::new(r"(pub fn \w+\s*\([^\)]*\)[^;]*);") .multi_line(true) .build() .unwrap());