From df4ce9fab7ec04b063da1ec09603d328213f96b1 Mon Sep 17 00:00:00 2001 From: bin liu Date: Fri, 16 Oct 2020 15:54:45 +0800 Subject: [PATCH] ci: add `cargo clippy` for agent To run `cargo clippy`, this commit includes changes: - add a new Makefile target to run `cargo clippy` - move `make`/`make check` to last step to let a fast retrun if `fmt`/`clippy` failed Fixes: #951 Signed-off-by: bin liu --- .travis.yml | 12 +++++++----- src/agent/Makefile | 6 ++++++ versions.yaml | 2 +- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 247421c730..36bfe742d5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,7 @@ os: linux # https://docs.travis-ci.com/user/caching#clearing-caches language: rust rust: - - 1.44.1 + - 1.47.0 cache: cargo: true directories: @@ -36,9 +36,9 @@ install: - rustup target add x86_64-unknown-linux-musl - sudo ln -sf /usr/bin/g++ /bin/musl-g++ - rustup component add rustfmt - - make -C ${TRAVIS_BUILD_DIR}/src/agent - - make -C ${TRAVIS_BUILD_DIR}/src/agent check - - sudo -E PATH=$PATH make -C ${TRAVIS_BUILD_DIR}/src/agent check + - rustup component add clippy + - make -C ${TRAVIS_BUILD_DIR}/src/agent clippy + - "ci/static-checks.sh" before_script: - "ci/install_go.sh" @@ -47,7 +47,9 @@ before_script: - sudo -E PATH=$PATH GOPATH=$GOPATH make -C ${TRAVIS_BUILD_DIR}/src/runtime test script: - - "ci/static-checks.sh" + - make -C ${TRAVIS_BUILD_DIR}/src/agent + - make -C ${TRAVIS_BUILD_DIR}/src/agent check + - sudo -E PATH=$PATH make -C ${TRAVIS_BUILD_DIR}/src/agent check jobs: include: diff --git a/src/agent/Makefile b/src/agent/Makefile index 6a5e7aef2c..92fbcdf020 100644 --- a/src/agent/Makefile +++ b/src/agent/Makefile @@ -121,6 +121,12 @@ optimize: $(SOURCES) | show-summary show-header show-header: @printf "%s - version %s (commit %s)\n\n" "$(TARGET)" "$(VERSION)" "$(COMMIT_MSG)" +clippy: $(GENERATED_CODE) + cargo clippy --all-targets --all-features --release \ + -- \ + -Aclippy::redundant_allocation \ + -D warnings + $(GENERATED_FILES): %: %.in @sed $(foreach r,$(GENERATED_REPLACEMENTS),-e 's|@$r@|$($r)|g') "$<" > "$@" diff --git a/versions.yaml b/versions.yaml index f9ba333f0a..8a469c16d9 100644 --- a/versions.yaml +++ b/versions.yaml @@ -289,7 +289,7 @@ languages: description: | 'newest-version' is the latest version known to work when building Kata - newest-version: "1.44.1" + newest-version: "1.47.0" specs: description: "Details of important specifications"