From 2fa28a6f19b970f9fd731293f89360e396d9a719 Mon Sep 17 00:00:00 2001 From: mulhern Date: Mon, 13 Nov 2023 19:39:50 -0500 Subject: [PATCH 1/4] .gitignore: exclude files from profiling Signed-off-by: mulhern --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index f4b92ce7..c01bd29d 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,6 @@ Cargo.lock *.bk *.swo *.swp + +*.profraw +*.profdata From 8f21158a5e7b1dc6849a7c38b9a2c807bc262765 Mon Sep 17 00:00:00 2001 From: mulhern Date: Mon, 13 Nov 2023 14:18:11 -0500 Subject: [PATCH 2/4] Add PROFILE_FLAGS to profileable targets Signed-off-by: mulhern --- Makefile | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 030bece9..b9709f1b 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,8 @@ +ifeq ($(origin PROFILE), undefined) +else + PROFILE_FLAGS = -C instrument-coverage +endif + ifeq ($(origin FEDORA_RELEASE), undefined) else FEDORA_RELEASE_ARGS = --release=${FEDORA_RELEASE} @@ -46,16 +51,16 @@ fmt-ci: cd devicemapper-rs-sys && cargo fmt -- --check build: - RUSTFLAGS="${DENY}" cargo build + RUSTFLAGS="${DENY} ${PROFILE_FLAGS}" cargo build build-tests: - RUSTFLAGS="${DENY}" cargo test --no-run + RUSTFLAGS="${DENY} ${PROFILE_FLAGS}" cargo test --no-run test: - RUSTFLAGS="${DENY}" RUST_BACKTRACE=1 cargo test -- --skip sudo_ --skip loop_ + RUSTFLAGS="${DENY} ${PROFILE_FLAGS}" RUST_BACKTRACE=1 cargo test -- --skip sudo_ --skip loop_ sudo_test: - RUSTFLAGS="${DENY}" RUST_BACKTRACE=1 RUST_TEST_THREADS=1 CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER='sudo -E' cargo test + RUSTFLAGS="${DENY} ${PROFILE_FLAGS}" RUST_BACKTRACE=1 RUST_TEST_THREADS=1 CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER='sudo -E' cargo test clippy: RUSTFLAGS="${DENY}" \ From 818d12a951157c07c662bbc076ae8ce4be4e861b Mon Sep 17 00:00:00 2001 From: mulhern Date: Mon, 13 Nov 2023 18:59:29 -0500 Subject: [PATCH 3/4] Add coverage target to weekly GitHub workflow Signed-off-by: mulhern --- .github/workflows/weekly.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/.github/workflows/weekly.yml b/.github/workflows/weekly.yml index febe54f7..415c7cdf 100644 --- a/.github/workflows/weekly.yml +++ b/.github/workflows/weekly.yml @@ -27,3 +27,35 @@ jobs: ${{ matrix.dependencies }} - name: ${{ matrix.task }} run: ${{ matrix.task }} + + coverage: + strategy: + matrix: + include: + - toolchain: 1.73.0 # CURRENT DEVELOPMENT RUST TOOLCHAIN + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@master + with: + components: cargo + toolchain: ${{ matrix.toolchain }} + - name: Install dependencies + run: | + sudo apt-get -q update + sudo apt-get -y install libdevmapper-dev + - name: Set toolchain override with sudo + # yamllint disable rule:line-length + run: sudo /home/runner/.cargo/bin/rustup override set ${{ matrix.toolchain }} + - name: Install cargo-binutils + run: sudo PATH=$GITHUB_WORKSPACE/.cargo/bin:$PATH CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER='sudo -E' /home/runner/.cargo/bin/cargo install cargo-binutils + - name: Add component llvm-tools-preview + run: sudo /home/runner/.cargo/bin/rustup component add llvm-tools-preview + - name: Run all tests on ${{ matrix.toolchain }} toolchain with profiling + run: sudo PATH=$GITHUB_WORKSPACE/.cargo/bin:$PATH PROFILE=1 make -f Makefile sudo_test + - name: Merge raw coverage files + run: | + sudo PATH=$GITHUB_WORKSPACE/.cargo/bin:$PATH CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER='sudo -E' /root/.cargo/bin/rust-profdata merge --sparse *.profraw -o result.profdata + sudo rm *.profraw + - name: Generate coverage report + run: sudo PATH=$GITHUB_WORKSPACE/.cargo/bin:$PATH CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER='sudo -E' /root/.cargo/bin/rust-cov report -object $(find target/debug/deps/ -regex ".*devicemapper-[0-9a-f]*") -instr-profile=result.profdata --summary-only From c42dbda01c34e9e998c2189585bddf1c77fa91da Mon Sep 17 00:00:00 2001 From: mulhern Date: Mon, 13 Nov 2023 19:42:56 -0500 Subject: [PATCH 4/4] TEMPORARY Signed-off-by: mulhern --- .github/workflows/weekly.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/weekly.yml b/.github/workflows/weekly.yml index 415c7cdf..1f5e6919 100644 --- a/.github/workflows/weekly.yml +++ b/.github/workflows/weekly.yml @@ -3,6 +3,19 @@ name: devicemapper weekly # yamllint disable-line rule:truthy on: + push: + branches: + - master + paths-ignore: + - 'CHANGES.txt' + - '**/README.md' + pull_request: + branches: + - master + paths-ignore: + - 'CHANGES.txt' + - '**/README.md' + schedule: - cron: 20 3 * * 2 workflow_dispatch: