Run ./scripts/fmt_all.sh in CI (#2290)
* pppp * fix * xx * add clang18 * fix * chg * purge existing clang.. * tmate * trigger * bruh * finally.. * Don't fmt when not in cargo-fmt * fix * aaaaaa * fuck
This commit is contained in:
parent
1e2fac6f53
commit
e99fcad326
37
.github/workflows/build_and_test.yml
vendored
37
.github/workflows/build_and_test.yml
vendored
@ -117,7 +117,7 @@ jobs:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: ./.github/workflows/ubuntu-prepare
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- name: Add nightly rustfmt and clippy
|
||||
- name: Add nightly clippy
|
||||
run: rustup toolchain install nightly --component miri --allow-downgrade
|
||||
# --- miri undefined behavior test --
|
||||
- name: Run miri tests
|
||||
@ -136,22 +136,19 @@ jobs:
|
||||
run: sudo apt purge llvm* clang* lld* lldb* opt*
|
||||
- name: Install and cache deps
|
||||
run: sudo apt update && sudo apt install ninja-build shellcheck libgtk-3-dev gcc-arm-linux-gnueabi g++-arm-linux-gnueabi libslirp-dev libz3-dev
|
||||
- name: Add nightly rustfmt and clippy
|
||||
run: rustup toolchain install nightly --component rustfmt --component clippy --component miri --allow-downgrade
|
||||
- name: Add nightly clippy
|
||||
run: rustup toolchain install nightly --component clippy --component miri --allow-downgrade
|
||||
- uses: actions/checkout@v3
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
with: { shared-key: "ubuntu" }
|
||||
- name: Install LLVM and Clang
|
||||
uses: KyleMayes/install-llvm-action@v1
|
||||
uses: KyleMayes/install-llvm-action@v2
|
||||
with:
|
||||
directory: ${{ runner.temp }}/llvm
|
||||
version: 17
|
||||
# ---- format check ----
|
||||
# pcguard edges and pcguard hitcounts are not compatible and we need to build them seperately
|
||||
- name: Check pcguard edges
|
||||
run: cargo check --features=sancov_pcguard_edges
|
||||
- name: Run clang-format style check for C/C++ programs.
|
||||
run: clang-format -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
|
||||
# ---- build normal and examples ----
|
||||
@ -172,19 +169,18 @@ jobs:
|
||||
|
||||
- name: Install and cache deps
|
||||
run: sudo apt update && sudo apt install ninja-build shellcheck libgtk-3-dev gcc-arm-linux-gnueabi g++-arm-linux-gnueabi libslirp-dev libz3-dev
|
||||
- name: Add nightly rustfmt and clippy
|
||||
- name: Add nightly clippy
|
||||
run: rustup toolchain install nightly --component clippy --allow-downgrade && rustup default nightly
|
||||
- uses: actions/checkout@v3
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
with: { shared-key: "ubuntu" }
|
||||
- name: Install LLVM and Clang
|
||||
uses: KyleMayes/install-llvm-action@v1
|
||||
uses: KyleMayes/install-llvm-action@v2
|
||||
with:
|
||||
directory: ${{ runner.temp }}/llvm
|
||||
version: 17
|
||||
- name: Run clippy
|
||||
run: ./scripts/clippy.sh
|
||||
|
||||
# --- test embedding the libafl_libfuzzer_runtime library
|
||||
# Fix me plz
|
||||
# - name: Test Build libafl_libfuzzer with embed
|
||||
@ -234,7 +230,7 @@ jobs:
|
||||
- name: Remove existing clang and LLVM
|
||||
run: sudo apt purge llvm* clang*
|
||||
- name: Install LLVM and Clang
|
||||
uses: KyleMayes/install-llvm-action@v1
|
||||
uses: KyleMayes/install-llvm-action@v2
|
||||
with:
|
||||
directory: ${{ runner.temp }}/llvm
|
||||
version: 17
|
||||
@ -259,8 +255,15 @@ jobs:
|
||||
override: true
|
||||
components: rustfmt
|
||||
- uses: actions/checkout@v3
|
||||
- name: Remove existing clang and LLVM
|
||||
run: sudo apt purge llvm* clang*
|
||||
- name: Install LLVM and Clang
|
||||
uses: KyleMayes/install-llvm-action@v2
|
||||
with:
|
||||
directory: ${{ runner.temp }}/llvm
|
||||
version: 17
|
||||
- name: Format Check
|
||||
run: cargo fmt -- --check
|
||||
run: ./scripts/fmt_all.sh check
|
||||
|
||||
fuzzers-preflight:
|
||||
runs-on: ubuntu-latest
|
||||
@ -386,7 +389,7 @@ jobs:
|
||||
profile: minimal
|
||||
toolchain: nightly
|
||||
override: true
|
||||
components: rustfmt, rust-src
|
||||
components: rust-src
|
||||
- uses: actions/checkout@v3
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- name: Add targets
|
||||
@ -406,7 +409,7 @@ jobs:
|
||||
profile: minimal
|
||||
toolchain: nightly
|
||||
override: true
|
||||
components: rustfmt, clippy, rust-src
|
||||
components: clippy, rust-src
|
||||
- uses: actions/checkout@v3
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- name: Add targets
|
||||
@ -488,8 +491,8 @@ jobs:
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: stable
|
||||
- name: Add nightly rustfmt and clippy
|
||||
run: rustup toolchain install nightly --component rustfmt --component clippy --allow-downgrade && rustup default nightly
|
||||
- name: Add nightly 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
|
||||
@ -503,7 +506,7 @@ jobs:
|
||||
- name: Run Tests
|
||||
run: cargo test
|
||||
- name: Clippy
|
||||
run: cargo +nightly clippy --tests --all
|
||||
run: cargo +nightly clippy --tests --all --exclude libafl_nyx --exclude symcc_runtime --exclude runtime_test
|
||||
|
||||
ios:
|
||||
runs-on: macOS-latest
|
||||
|
@ -13,12 +13,12 @@ runs:
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: stable
|
||||
- name: Add stable rustfmt and clippy
|
||||
- name: Add stable clippy
|
||||
shell: bash
|
||||
run: rustup toolchain install stable --component rustfmt --component clippy --allow-downgrade
|
||||
- name: Add nightly rustfmt and clippy
|
||||
run: rustup toolchain install stable --component clippy --allow-downgrade
|
||||
- name: Add nightly clippy
|
||||
shell: bash
|
||||
run: rustup toolchain install nightly --component rustfmt --component clippy --allow-downgrade
|
||||
run: rustup toolchain install nightly --component clippy --allow-downgrade
|
||||
- name: Add no_std toolchain
|
||||
shell: bash
|
||||
run: rustup toolchain install nightly-x86_64-unknown-linux-gnu ; rustup component add rust-src --toolchain nightly-x86_64-unknown-linux-gnu
|
||||
|
@ -16,12 +16,12 @@ runs:
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: stable
|
||||
- name: Add stable rustfmt and clippy
|
||||
- name: Add stable clippy
|
||||
shell: bash
|
||||
run: rustup toolchain install stable --component rustfmt --component clippy --allow-downgrade
|
||||
- name: Add nightly rustfmt and clippy
|
||||
run: rustup toolchain install stable --component clippy --allow-downgrade
|
||||
- name: Add nightly clippy
|
||||
shell: bash
|
||||
run: rustup toolchain install nightly --component rustfmt --component clippy --allow-downgrade
|
||||
run: rustup toolchain install nightly --component clippy --allow-downgrade
|
||||
- name: Remove obsolete llvm (Linux)
|
||||
if: runner.os == 'Linux'
|
||||
shell: bash
|
||||
|
@ -49,14 +49,11 @@ do
|
||||
|
||||
cd "$fuzzer" || exit 1
|
||||
# Clippy checks
|
||||
if [ "$1" != "--no-fmt" ]; then
|
||||
|
||||
echo "[*] Checking fmt for $fuzzer"
|
||||
cargo fmt --all -- --check || exit 1
|
||||
if [ "$1" != "--no-clippy" ]; then
|
||||
echo "[*] Running clippy for $fuzzer"
|
||||
cargo clippy || exit 1
|
||||
else
|
||||
echo "[+] Skipping fmt and clippy for $fuzzer (--no-fmt specified)"
|
||||
echo "[+] Skipping fmt and clippy for $fuzzer (--no-clippy specified)"
|
||||
fi
|
||||
|
||||
if [ -e ./Makefile.toml ] && grep -qF "skip_core_tasks = true" Makefile.toml; then
|
||||
|
@ -32,7 +32,10 @@ async fn run_cargo_fmt(path: PathBuf, is_check: bool, verbose: bool) -> io::Resu
|
||||
|
||||
if !res.status.success() {
|
||||
println!("{}", from_utf8(&res.stderr).unwrap());
|
||||
return Err(io::Error::new(ErrorKind::Other, "Cargo fmt failed."));
|
||||
return Err(io::Error::new(
|
||||
ErrorKind::Other,
|
||||
format!("Cargo fmt failed. Run cargo fmt for {:#?}", path),
|
||||
));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@ -88,8 +91,14 @@ struct Cli {
|
||||
#[tokio::main]
|
||||
async fn main() -> io::Result<()> {
|
||||
let cli = Cli::parse();
|
||||
let libafl_root_dir = project_root::get_project_root().expect("Could not locate project root.");
|
||||
let libafl_root_dir = match project_root::get_project_root() {
|
||||
Ok(p) => p,
|
||||
Err(_) => std::env::current_dir()
|
||||
.expect("Failed to get current directory")
|
||||
.into(),
|
||||
};
|
||||
|
||||
println!("Using {:#?} as the project root", libafl_root_dir);
|
||||
let rust_excluded_directories = RegexSet::new([
|
||||
r".*target.*",
|
||||
r".*utils/noaslr.*",
|
||||
@ -107,6 +116,7 @@ async fn main() -> io::Result<()> {
|
||||
r".*dlmalloc\.c$",
|
||||
r".*QEMU-Nyx.*",
|
||||
r".*AFLplusplus.*",
|
||||
r".*cms_transform_fuzzer.cc.*",
|
||||
])
|
||||
.expect("Could not create the regex set from the given regex");
|
||||
|
||||
@ -134,8 +144,9 @@ async fn main() -> io::Result<()> {
|
||||
tokio_joinset.spawn(run_cargo_fmt(project, cli.check, cli.verbose));
|
||||
}
|
||||
|
||||
let (clang, warning) = if which("clang-format-18").is_ok() {
|
||||
(Some("clang-format-18"), None)
|
||||
let (clang, warning) = if which("clang-format-17").is_ok() {
|
||||
// can't use 18 for ci.
|
||||
(Some("clang-format-17"), None)
|
||||
} else if which("clang-format").is_ok() {
|
||||
(
|
||||
Some("clang-format"),
|
||||
@ -147,7 +158,7 @@ async fn main() -> io::Result<()> {
|
||||
Some("clang-format not found. Skipping C formatting..."),
|
||||
)
|
||||
};
|
||||
|
||||
// println!("Using {:#?} to format...", clang);
|
||||
if let Some(clang) = clang {
|
||||
let c_files_to_fmt: Vec<PathBuf> = WalkDir::new(&libafl_root_dir)
|
||||
.into_iter()
|
||||
|
Loading…
x
Reference in New Issue
Block a user